# HG changeset patch # User Christian Ebert # Date 1272637809 -7200 # Node ID a3594a64511fe8e3f390683b879a3cbf6e3d69c6 # Parent dc8fe24c628e700bf214c49632df8b3dd6d02ca1# Parent e5bfe51eeea9b9603eab3871617add68ba3ae246 Merge with stable diff -r dc8fe24c628e -r a3594a64511f tests/run-tests.py --- a/tests/run-tests.py Mon Apr 26 04:01:13 2010 +0200 +++ b/tests/run-tests.py Fri Apr 30 16:30:09 2010 +0200 @@ -83,34 +83,43 @@ def parseargs(): parser = optparse.OptionParser("%prog [options] [tests]") + + # keep these sorted + parser.add_option("--blacklist", action="append", + help="skip tests listed in the specified blacklist file") parser.add_option("-C", "--annotate", action="store_true", help="output files annotated with coverage") parser.add_option("--child", type="int", help="run as child process, summary to given fd") parser.add_option("-c", "--cover", action="store_true", help="print a test coverage report") + parser.add_option("-d", "--debug", action="store_true", + help="debug mode: write output of test scripts to console" + " rather than capturing and diff'ing it (disables timeout)") parser.add_option("-f", "--first", action="store_true", help="exit on the first test failure") + parser.add_option("--inotify", action="store_true", + help="enable inotify extension when running tests") parser.add_option("-i", "--interactive", action="store_true", help="prompt to accept changed output") parser.add_option("-j", "--jobs", type="int", help="number of jobs to run in parallel" " (default: $%s or %d)" % defaults['jobs']) - parser.add_option("-k", "--keywords", - help="run tests matching keywords") parser.add_option("--keep-tmpdir", action="store_true", help="keep temporary directory after running tests") - parser.add_option("--tmpdir", type="string", - help="run tests in the given temporary directory" - " (implies --keep-tmpdir)") - parser.add_option("-d", "--debug", action="store_true", - help="debug mode: write output of test scripts to console" - " rather than capturing and diff'ing it (disables timeout)") - parser.add_option("-R", "--restart", action="store_true", - help="restart at last error") + parser.add_option("-k", "--keywords", + help="run tests matching keywords") + parser.add_option("-l", "--local", action="store_true", + help="shortcut for --with-hg=/../hg") + parser.add_option("-n", "--nodiff", action="store_true", + help="skip showing test changes") parser.add_option("-p", "--port", type="int", help="port on which servers should listen" " (default: $%s or %d)" % defaults['port']) + parser.add_option("--pure", action="store_true", + help="use pure Python code instead of C extensions") + parser.add_option("-R", "--restart", action="store_true", + help="restart at last error") parser.add_option("-r", "--retest", action="store_true", help="retest failed tests") parser.add_option("-S", "--noskips", action="store_true", @@ -118,24 +127,19 @@ parser.add_option("-t", "--timeout", type="int", help="kill errant tests after TIMEOUT seconds" " (default: $%s or %d)" % defaults['timeout']) + parser.add_option("--tmpdir", type="string", + help="run tests in the given temporary directory" + " (implies --keep-tmpdir)") parser.add_option("-v", "--verbose", action="store_true", help="output verbose messages") - parser.add_option("-n", "--nodiff", action="store_true", - help="skip showing test changes") + parser.add_option("--view", type="string", + help="external diff viewer") parser.add_option("--with-hg", type="string", metavar="HG", help="test using specified hg script rather than a " "temporary installation") - parser.add_option("--local", action="store_true", - help="shortcut for --with-hg=/../hg") - parser.add_option("--pure", action="store_true", - help="use pure Python code instead of C extensions") parser.add_option("-3", "--py3k-warnings", action="store_true", help="enable Py3k warnings on Python 2.6+") - parser.add_option("--inotify", action="store_true", - help="enable inotify extension when running tests") - parser.add_option("--blacklist", action="append", - help="skip tests listed in the specified blacklist file") for option, default in defaults.items(): defaults[option] = int(os.environ.get(*default)) @@ -571,6 +575,7 @@ mark = '.' skipped = (ret == SKIPPED_STATUS) + # If we're not in --debug mode and reference output file exists, # check test output against it. if options.debug: @@ -582,6 +587,13 @@ else: refout = [] + if (ret != 0 or out != refout) and not skipped and not options.debug: + # Save errors to a file for diagnosis + f = open(err, "wb") + for line in out: + f.write(line) + f.close() + if skipped: mark = 's' if out is None: # debug mode: nothing to parse @@ -603,7 +615,10 @@ else: fail("output changed") if not options.nodiff: - showdiff(refout, out, ref, err) + if options.view: + os.system("%s %s %s" % (options.view, ref, err)) + else: + showdiff(refout, out, ref, err) ret = 1 elif ret: mark = '!' @@ -613,13 +628,6 @@ sys.stdout.write(mark) sys.stdout.flush() - if ret != 0 and not skipped and not options.debug: - # Save errors to a file for diagnosis - f = open(err, "wb") - for line in out: - f.write(line) - f.close() - killdaemons() os.chdir(TESTDIR)