Skip to content

Commit 7bd16b8

Browse files
authored
Fix test_fetcher when setup is updated (#13566)
* Fix test_fetcher when setup is updated * Remove example
1 parent 054b601 commit 7bd16b8

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

utils/tests_fetcher.py

+24-20
Original file line numberDiff line numberDiff line change
@@ -417,26 +417,30 @@ def infer_tests_to_run(output_file, diff_with_last_commit=False, filters=None):
417417
print(f"\n### IMPACTED FILES ###\n{_print_list(impacted_files)}")
418418

419419
# Grab the corresponding test files:
420-
test_files_to_run = []
421-
for f in impacted_files:
422-
# Modified test files are always added
423-
if f.startswith("tests/"):
424-
test_files_to_run.append(f)
425-
else:
426-
new_tests = module_to_test_file(f)
427-
if new_tests is not None:
428-
if isinstance(new_tests, str):
429-
test_files_to_run.append(new_tests)
430-
else:
431-
test_files_to_run.extend(new_tests)
432-
433-
# Remove duplicates
434-
test_files_to_run = sorted(list(set(test_files_to_run)))
435-
# Make sure we did not end up with a test file that was removed
436-
test_files_to_run = [f for f in test_files_to_run if os.path.isfile(f) or os.path.isdir(f)]
437-
if filters is not None:
438-
for filter in filters:
439-
test_files_to_run = [f for f in test_files_to_run if f.startswith(filter)]
420+
if "setup.py" in impacted_files:
421+
test_files_to_run = ["tests"]
422+
else:
423+
# Grab the corresponding test files:
424+
test_files_to_run = []
425+
for f in impacted_files:
426+
# Modified test files are always added
427+
if f.startswith("tests/"):
428+
test_files_to_run.append(f)
429+
else:
430+
new_tests = module_to_test_file(f)
431+
if new_tests is not None:
432+
if isinstance(new_tests, str):
433+
test_files_to_run.append(new_tests)
434+
else:
435+
test_files_to_run.extend(new_tests)
436+
437+
# Remove duplicates
438+
test_files_to_run = sorted(list(set(test_files_to_run)))
439+
# Make sure we did not end up with a test file that was removed
440+
test_files_to_run = [f for f in test_files_to_run if os.path.isfile(f) or os.path.isdir(f)]
441+
if filters is not None:
442+
for filter in filters:
443+
test_files_to_run = [f for f in test_files_to_run if f.startswith(filter)]
440444

441445
print(f"\n### TEST TO RUN ###\n{_print_list(test_files_to_run)}")
442446
if len(test_files_to_run) > 0:

0 commit comments

Comments
 (0)