34 help="output files annotated with coverage") |
34 help="output files annotated with coverage") |
35 parser.add_option("-r", "--retest", action="store_true", |
35 parser.add_option("-r", "--retest", action="store_true", |
36 help="retest failed tests") |
36 help="retest failed tests") |
37 parser.add_option("-f", "--first", action="store_true", |
37 parser.add_option("-f", "--first", action="store_true", |
38 help="exit on the first test failure") |
38 help="exit on the first test failure") |
|
39 parser.add_option("-R", "--restart", action="store_true", |
|
40 help="restart at last error") |
39 |
41 |
40 parser.set_defaults(timeout=180) |
42 parser.set_defaults(timeout=180) |
41 (options, args) = parser.parse_args() |
43 (options, args) = parser.parse_args() |
42 verbose = options.verbose |
44 verbose = options.verbose |
43 coverage = options.cover or options.cover_stdlib or options.annotate |
45 coverage = options.cover or options.cover_stdlib or options.annotate |
353 options.timeout) |
355 options.timeout) |
354 except AttributeError: |
356 except AttributeError: |
355 print 'WARNING: cannot run tests with timeouts' |
357 print 'WARNING: cannot run tests with timeouts' |
356 options.timeout = 0 |
358 options.timeout = 0 |
357 |
359 |
358 tests = 0 |
360 tested = 0 |
359 failed = 0 |
361 failed = 0 |
360 skipped = 0 |
362 skipped = 0 |
361 |
363 |
362 if len(args) == 0: |
364 if len(args) == 0: |
363 args = os.listdir(".") |
365 args = os.listdir(".") |
364 args.sort() |
366 args.sort() |
365 |
367 |
|
368 |
|
369 tests = [] |
366 for test in args: |
370 for test in args: |
367 if (test.startswith("test-") and '~' not in test and |
371 if (test.startswith("test-") and '~' not in test and |
368 ('.' not in test or test.endswith('.py') or |
372 ('.' not in test or test.endswith('.py') or |
369 test.endswith('.bat'))): |
373 test.endswith('.bat'))): |
370 if options.retest and not os.path.exists(test + ".err"): |
374 tests.append(test) |
371 skipped += 1 |
375 |
372 continue |
376 if options.restart: |
373 ret = run_one(test) |
377 orig = list(tests) |
374 if ret is None: |
378 while tests: |
375 skipped += 1 |
379 if os.path.exists(tests[0] + ".err"): |
376 elif not ret: |
380 break |
377 failed += 1 |
381 tests.pop(0) |
378 if options.first: |
382 if not tests: |
379 break |
383 print "running all tests" |
380 tests += 1 |
384 tests = orig |
381 |
385 |
382 print "\n# Ran %d tests, %d skipped, %d failed." % (tests, skipped, |
386 for test in tests: |
|
387 if options.retest and not os.path.exists(test + ".err"): |
|
388 skipped += 1 |
|
389 continue |
|
390 ret = run_one(test) |
|
391 if ret is None: |
|
392 skipped += 1 |
|
393 elif not ret: |
|
394 failed += 1 |
|
395 if options.first: |
|
396 break |
|
397 tested += 1 |
|
398 |
|
399 print "\n# Ran %d tests, %d skipped, %d failed." % (tested, skipped, |
383 failed) |
400 failed) |
384 if coverage: |
401 if coverage: |
385 output_coverage() |
402 output_coverage() |
386 except KeyboardInterrupt: |
403 except KeyboardInterrupt: |
387 failed = True |
404 failed = True |