Skip to content

Commit 165e568

Browse files
authored
Add --conitinue flag to test runner. NFC (#20845)
When combined with `--failfast` this allows you to continue where you left off.
1 parent 3e481f6 commit 165e568

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

test/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
NON_ZERO = -1
7878

7979
TEST_ROOT = path_from_root('test')
80+
LAST_TEST = path_from_root('out/last_test.txt')
8081

8182
WEBIDL_BINDER = shared.bat_suffix(path_from_root('tools/webidl_binder'))
8283

@@ -902,6 +903,7 @@ def setUp(self):
902903
else:
903904
print('Creating new test output directory')
904905
ensure_dir(self.working_dir)
906+
utils.write_file(LAST_TEST, self.id() + '\n')
905907
os.chdir(self.working_dir)
906908

907909
def runningInParallel(self):

test/runner.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,9 @@ def parse_args(args):
382382
parser.add_argument('tests', nargs='*')
383383
parser.add_argument('--failfast', action='store_const', const=True, default=False)
384384
parser.add_argument('--start-at', metavar='NAME', help='Skip all tests up until <NAME>')
385+
parser.add_argument('--continue', dest='_continue', action='store_true',
386+
help='Resume from the last run test.'
387+
'Useful when combined with --failfast')
385388
parser.add_argument('--force64', action='store_const', const=True, default=None)
386389
parser.add_argument('--crossplatform-only', action='store_true')
387390
return parser.parse_args()
@@ -465,6 +468,11 @@ def prepend_default(arg):
465468
tests = tests_with_expanded_wildcards(tests, all_tests)
466469
tests = skip_requested_tests(tests, modules)
467470
tests = args_for_random_tests(tests, modules)
471+
472+
if not options.start_at and options._continue:
473+
if os.path.exists(common.LAST_TEST):
474+
options.start_at = utils.read_file(common.LAST_TEST).strip()
475+
468476
suites, unmatched_tests = load_test_suites(tests, modules, options.start_at)
469477
if unmatched_tests:
470478
print('ERROR: could not find the following tests: ' + ' '.join(unmatched_tests))

0 commit comments

Comments
 (0)