Rework pipeline tests (#19366)

* Rework pipeline tests

* Try to fix Flax tests

* Try to put it before

* Use a new decorator instead

* Remove ignore marker since it doesn't work

* Filter pipeline tests

* Woopsie

* Use the fitlered list

* Clean up and fake modif

* Remove init

* Revert fake modif
This commit is contained in:
Sylvain Gugger
2022-10-07 18:01:58 -04:00
committed by GitHub
parent 983451a13e
commit 9ac586b3c8
27 changed files with 95 additions and 149 deletions

View File

@@ -619,6 +619,25 @@ def infer_tests_to_run(output_file, diff_with_last_commit=False, filters=None, j
json.dump(test_map, fp, ensure_ascii=False)
def filter_pipeline_tests(output_file):
if not os.path.isfile(output_file):
print("No test file found.")
return
with open(output_file, "r", encoding="utf-8") as f:
test_files = f.read().split(" ")
if len(test_files) == 0:
print("No tests to filter.")
return
if test_files == ["tests"]:
test_files = [os.path.join("tests", f) for f in os.listdir("tests") if f not in ["__init__.py", "pipelines"]]
else:
test_files = [f for f in test_files if not f.startswith(os.path.join("tests", "pipelines"))]
with open(output_file, "w", encoding="utf-8") as f:
f.write(" ".join(test_files))
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
@@ -645,6 +664,11 @@ if __name__ == "__main__":
default=["tests"],
help="Only keep the test files matching one of those filters.",
)
parser.add_argument(
"--filter_pipeline_tests",
action="store_true",
help="Will filter the pipeline tests outside of the generated list of tests.",
)
parser.add_argument(
"--print_dependencies_of",
type=str,
@@ -656,6 +680,8 @@ if __name__ == "__main__":
print_tree_deps_of(args.print_dependencies_of)
elif args.sanity_check:
sanity_check()
elif args.filter_pipeline_tests:
filter_pipeline_tests(args.output_file)
else:
repo = Repo(PATH_TO_TRANFORMERS)