95 parser.add_option("--keep-tmpdir", action="store_true", |
95 parser.add_option("--keep-tmpdir", action="store_true", |
96 help="keep temporary directory after running tests") |
96 help="keep temporary directory after running tests") |
97 parser.add_option("--tmpdir", type="string", |
97 parser.add_option("--tmpdir", type="string", |
98 help="run tests in the given temporary directory" |
98 help="run tests in the given temporary directory" |
99 " (implies --keep-tmpdir)") |
99 " (implies --keep-tmpdir)") |
|
100 parser.add_option("-d", "--debug", action="store_true", |
|
101 help="debug mode: write output of test scripts to console" |
|
102 " rather than capturing and diff'ing it (disables timeout)") |
100 parser.add_option("-R", "--restart", action="store_true", |
103 parser.add_option("-R", "--restart", action="store_true", |
101 help="restart at last error") |
104 help="restart at last error") |
102 parser.add_option("-p", "--port", type="int", |
105 parser.add_option("-p", "--port", type="int", |
103 help="port on which servers should listen" |
106 help="port on which servers should listen" |
104 " (default: $%s or %d)" % defaults['port']) |
107 " (default: $%s or %d)" % defaults['port']) |
177 if options.jobs < 1: |
181 if options.jobs < 1: |
178 parser.error('--jobs must be positive') |
182 parser.error('--jobs must be positive') |
179 if options.interactive and options.jobs > 1: |
183 if options.interactive and options.jobs > 1: |
180 print '(--interactive overrides --jobs)' |
184 print '(--interactive overrides --jobs)' |
181 options.jobs = 1 |
185 options.jobs = 1 |
|
186 if options.interactive and options.debug: |
|
187 parser.error("-i/--interactive and -d/--debug are incompatible") |
|
188 if options.debug: |
|
189 if options.timeout != defaults['timeout']: |
|
190 sys.stderr.write( |
|
191 'warning: --timeout option ignored with --debug\n') |
|
192 options.timeout = 0 |
182 if options.py3k_warnings: |
193 if options.py3k_warnings: |
183 if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0): |
194 if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0): |
184 parser.error('--py3k-warnings can only be used on Python 2.6+') |
195 parser.error('--py3k-warnings can only be used on Python 2.6+') |
185 |
196 |
186 return (options, args) |
197 return (options, args) |
372 def alarmed(signum, frame): |
383 def alarmed(signum, frame): |
373 raise Timeout |
384 raise Timeout |
374 |
385 |
375 def run(cmd, options): |
386 def run(cmd, options): |
376 """Run command in a sub-process, capturing the output (stdout and stderr). |
387 """Run command in a sub-process, capturing the output (stdout and stderr). |
377 Return the exist code, and output.""" |
388 Return a tuple (exitcode, output). output is None in debug mode.""" |
378 # TODO: Use subprocess.Popen if we're running on Python 2.4 |
389 # TODO: Use subprocess.Popen if we're running on Python 2.4 |
|
390 if options.debug: |
|
391 proc = subprocess.Popen(cmd, shell=True) |
|
392 ret = proc.wait() |
|
393 return (ret, None) |
|
394 |
379 if os.name == 'nt' or sys.platform.startswith('java'): |
395 if os.name == 'nt' or sys.platform.startswith('java'): |
380 tochild, fromchild = os.popen4(cmd) |
396 tochild, fromchild = os.popen4(cmd) |
381 tochild.close() |
397 tochild.close() |
382 output = fromchild.read() |
398 output = fromchild.read() |
383 ret = fromchild.close() |
399 ret = fromchild.close() |
485 signal.alarm(0) |
501 signal.alarm(0) |
486 |
502 |
487 mark = '.' |
503 mark = '.' |
488 |
504 |
489 skipped = (ret == SKIPPED_STATUS) |
505 skipped = (ret == SKIPPED_STATUS) |
490 # If reference output file exists, check test output against it |
506 # If we're not in --debug mode and reference output file exists, |
491 if os.path.exists(ref): |
507 # check test output against it. |
|
508 if options.debug: |
|
509 refout = None # to match out == None |
|
510 elif os.path.exists(ref): |
492 f = open(ref, "r") |
511 f = open(ref, "r") |
493 refout = splitnewlines(f.read()) |
512 refout = splitnewlines(f.read()) |
494 f.close() |
513 f.close() |
495 else: |
514 else: |
496 refout = [] |
515 refout = [] |
|
516 |
497 if skipped: |
517 if skipped: |
498 mark = 's' |
518 mark = 's' |
499 missing, failed = parsehghaveoutput(out) |
519 if out is None: # debug mode: nothing to parse |
|
520 missing = ['unknown'] |
|
521 failed = None |
|
522 else: |
|
523 missing, failed = parsehghaveoutput(out) |
500 if not missing: |
524 if not missing: |
501 missing = ['irrelevant'] |
525 missing = ['irrelevant'] |
502 if failed: |
526 if failed: |
503 fail("hghave failed checking for %s" % failed[-1]) |
527 fail("hghave failed checking for %s" % failed[-1]) |
504 skipped = False |
528 skipped = False |