Run doctest for new files (#25588)

fix

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
Yih-Dar
2023-08-21 11:08:38 +02:00
committed by GitHub
parent 9627c3da4a
commit f09db47a71
3 changed files with 998 additions and 8 deletions

View File

@@ -396,17 +396,22 @@ def get_doctest_files(diff_with_last_commit: bool = False) -> List[str]:
print(f"Parent commit: {commit}")
test_files_to_run = get_diff_for_doctesting(repo, repo.head.commit, parent_commits)
# This is the full list of doctest tests
with open("utils/documentation_tests.txt") as fp:
documentation_tests = set(fp.read().strip().split("\n"))
# These are files not doctested yet.
with open("utils/not_doctested.txt") as fp:
not_doctested = set(fp.read().strip().split("\n"))
# Do not run slow doctest tests
with open("utils/slow_documentation_tests.txt") as fp:
slow_documentation_tests = set(fp.read().strip().split("\n"))
# So far we don't have 100% coverage for doctest. This line will be removed once we achieve 100%.
test_files_to_run = [
x for x in test_files_to_run if x in documentation_tests and x not in slow_documentation_tests
]
test_files_to_run = [x for x in test_files_to_run if x not in not_doctested and x not in slow_documentation_tests]
# The file `utils/not_doctested.txt` doesn't contain all files that are not doc-tested, so we need more filters.
# 1. only include files in `src` or `docs/source/en/`
test_files_to_run = [x for x in test_files_to_run if x.startswith(("src/", "docs/source/en/"))]
# 2. not include init files
test_files_to_run = [x for x in test_files_to_run if not x.endswith(("__init__.py",))]
# Make sure we did not end up with a test file that was removed
test_files_to_run = [f for f in test_files_to_run if (PATH_TO_REPO / f).exists()]