From dfeb5aa6a9d0cb95c008854c4e67ceecfeff6ccc Mon Sep 17 00:00:00 2001 From: Yih-Dar <2521628+ydshieh@users.noreply.github.com> Date: Fri, 28 Apr 2023 22:25:34 +0200 Subject: [PATCH] extend the test files (#23043) * fix --------- Co-authored-by: ydshieh --- .circleci/config.yml | 8 ++++++++ .circleci/create_circleci_config.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 78ed6b02b8..63c6162fc1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,6 +63,12 @@ jobs: else touch test_preparation/examples_test_list.txt fi + - run: | + if [ -f filtered_test_list_cross_tests.txt ]; then + mv filtered_test_list_cross_tests.txt test_preparation/filtered_test_list_cross_tests.txt + else + touch test_preparation/filtered_test_list_cross_tests.txt + fi - store_artifacts: path: test_preparation/test_list.txt - store_artifacts: @@ -78,6 +84,8 @@ jobs: - run: cp test_preparation/generated_config.yml test_preparation/generated_config.txt - store_artifacts: path: test_preparation/generated_config.txt + - store_artifacts: + path: test_preparation/filtered_test_list_cross_tests.txt - continuation/continue: configuration_path: test_preparation/generated_config.yml diff --git a/.circleci/create_circleci_config.py b/.circleci/create_circleci_config.py index a5ebdc85f6..53c0279c4a 100644 --- a/.circleci/create_circleci_config.py +++ b/.circleci/create_circleci_config.py @@ -447,6 +447,34 @@ def create_circleci_config(folder=None): if len(test_list) > 0: jobs.extend(REGULAR_TESTS) + extended_tests_to_run = set(test_list.split()) + # Extend the test files for cross test jobs + for job in jobs: + if job.job_name in ["tests_torch_and_tf", "tests_torch_and_flax"]: + for test_path in copy.copy(extended_tests_to_run): + dir_path, fn = os.path.split(test_path) + if fn.startswith("test_modeling_tf_"): + fn = fn.replace("test_modeling_tf_", "test_modeling_") + elif fn.startswith("test_modeling_flax_"): + fn = fn.replace("test_modeling_flax_", "test_modeling_") + else: + if job.job_name == "test_torch_and_tf": + fn = fn.replace("test_modeling_", "test_modeling_tf_") + elif job.job_name == "test_torch_and_flax": + fn = fn.replace("test_modeling_", "test_modeling_flax_") + new_test_file = str(os.path.join(dir_path, fn)) + if os.path.isfile(new_test_file): + if new_test_file not in extended_tests_to_run: + extended_tests_to_run.add(new_test_file) + extended_tests_to_run = sorted(extended_tests_to_run) + for job in jobs: + if job.job_name in ["tests_torch_and_tf", "tests_torch_and_flax"]: + job.tests_to_run = extended_tests_to_run + fn = "filtered_test_list_cross_tests.txt" + f_path = os.path.join(folder, fn) + with open(f_path, "w") as fp: + fp.write(" ".join(extended_tests_to_run)) + example_file = os.path.join(folder, "examples_test_list.txt") if os.path.exists(example_file) and os.path.getsize(example_file) > 0: jobs.extend(EXAMPLES_TESTS)