@@ -82,6 +82,23 @@ def parse_dry_run_output(output):
8282 return tests
8383
8484
85+ def changed_files_in_test_root (repo_root , base_ref ):
86+ output = run_git (repo_root , "diff" , "--name-only" , base_ref , "--" , TEST_ROOT_RELATIVE .as_posix ())
87+ prefix = TEST_ROOT_RELATIVE .as_posix () + "/"
88+ return [line [len (prefix ) :] for line in output .splitlines () if line .startswith (prefix )]
89+
90+
91+ def find_modified_tests (repo_root , base_ref , pr_tests ):
92+ tests_by_input_path = {}
93+ for test in pr_tests :
94+ tests_by_input_path .setdefault (test .partition ("?" )[0 ], set ()).add (test )
95+
96+ modified_tests = set ()
97+ for relative_path in changed_files_in_test_root (repo_root , base_ref ):
98+ modified_tests .update (tests_by_input_path .get (relative_path , ()))
99+ return modified_tests
100+
101+
85102def dry_run_tests (test_web_binary , test_root , python_executable , results_dir ):
86103 command = [
87104 str (test_web_binary ),
@@ -115,7 +132,11 @@ def discover_candidates(args, repo_root, test_web_binary, base_worktree, scratch
115132 base_tests = dry_run_tests (test_web_binary , base_test_root , args .python_executable , scratch_dir / "dry-run-base" )
116133 log (f" { len (base_tests )} tests discovered." )
117134
118- return sorted (pr_tests - base_tests )
135+ new_tests = pr_tests - base_tests
136+ modified_tests = find_modified_tests (repo_root , args .base_ref , pr_tests ) - new_tests
137+ log (f" { len (new_tests )} new and { len (modified_tests )} modified test(s) found." )
138+
139+ return sorted (new_tests ) + sorted (modified_tests )
119140
120141
121142def parse_concurrency_levels (spec ):
@@ -288,7 +309,7 @@ def main(argv):
288309 cleanup_worktree (repo_root , base_worktree_path , scratch_dir )
289310
290311 if not candidates :
291- log ("No new tests: nothing to check." )
312+ log ("No new or modified tests: nothing to check." )
292313 return 0
293314
294315 log (f"{ len (candidates )} candidate test(s) to check at parallelism levels { levels } ." )
0 commit comments