# # A less memory-exploding version of regrtester.py. # It runs only a fraction of the tests. # # No longer needed! Memory explosion is gone. import sys, re, psyco, os, time assert len(sys.argv) >= 2 match = re.match(r"(\d+)[/](\d+)", sys.argv[1]) assert match, "syntax: regrtester2.py n/m [-nodump] [seed]" n = int(match.group(1)) m = int(match.group(2)) forever = 0 == m == n assert (0 <= n < m) or forever import test.regrtest import regrtester def confirm_still_in_psyco(): return __in_psyco__ USED_SEED_NAME = 'regrtester2.seed.used' LOCAL_SEED_NAME = 'regrtester2.seed.local' tests = [s for s in test.regrtest.findtests() if s not in test.regrtest.NOTTESTS] if not forever: tests = [s for s in tests if hash(s) % m == n] if __name__ == '__main__': if len(sys.argv) > 2 and sys.argv[2] == '-nodump': dump = 0 del sys.argv[2] else: dump = 1 import random, time seed = time.ctime() if len(sys.argv) > 2: seed = sys.argv[2] del sys.argv[2] elif os.path.exists(LOCAL_SEED_NAME): seed = file(LOCAL_SEED_NAME).read().strip() f = file(USED_SEED_NAME, 'w') f.write(seed) f.close() print 'Random seed is %r' % seed, '-- saved in', USED_SEED_NAME random.seed(seed) random.shuffle(tests) fully_in_psyco = confirm_still_in_psyco() runs = 1 while 1: if forever: print """ ====================================================================== ======= ======= === forever === = running the regrtester2.py in an endless loop = run # %d = = === hit ctl-c twice to stop === ===== ======= ====================================================================== """ % runs try: try: test.regrtest.main(tests) #, verbose=1) except KeyboardInterrupt: file('interrupt.tmp', 'w').close() raise SystemExit except SystemExit: if forever: print "+++ end of test, you can interrupt now +++" try: time.sleep(1) except KeyboardInterrupt: raise SystemExit runs += 1 continue raise finally: if dump: psyco.dumpcodebuf() if fully_in_psyco: assert confirm_still_in_psyco() psyco.stop()