Return a list of python and Markdown files where doc example have been modified between: - the current head and the main branch if `diff_with_last_commit=False` (default) - the current head and its parent commit otherwise. Returns: `List[str]`: The list of Python and Markd
(diff_with_last_commit: bool = False)
| 404 | |
| 405 | |
| 406 | def get_doctest_files(diff_with_last_commit: bool = False) -> List[str]: |
| 407 | """ |
| 408 | Return a list of python and Markdown files where doc example have been modified between: |
| 409 | |
| 410 | - the current head and the main branch if `diff_with_last_commit=False` (default) |
| 411 | - the current head and its parent commit otherwise. |
| 412 | |
| 413 | Returns: |
| 414 | `List[str]`: The list of Python and Markdown files with a diff (files added or renamed are always returned, files |
| 415 | modified are returned if the diff in the file is only in doctest examples). |
| 416 | """ |
| 417 | repo = Repo(PATH_TO_REPO) |
| 418 | |
| 419 | test_files_to_run = [] # noqa |
| 420 | if not diff_with_last_commit: |
| 421 | upstream_main = repo.remotes.origin.refs.main |
| 422 | print(f"main is at {upstream_main.commit}") |
| 423 | print(f"Current head is at {repo.head.commit}") |
| 424 | |
| 425 | branching_commits = repo.merge_base(upstream_main, repo.head) |
| 426 | for commit in branching_commits: |
| 427 | print(f"Branching commit: {commit}") |
| 428 | test_files_to_run = get_diff_for_doctesting(repo, repo.head.commit, branching_commits) |
| 429 | else: |
| 430 | print(f"main is at {repo.head.commit}") |
| 431 | parent_commits = repo.head.commit.parents |
| 432 | for commit in parent_commits: |
| 433 | print(f"Parent commit: {commit}") |
| 434 | test_files_to_run = get_diff_for_doctesting(repo, repo.head.commit, parent_commits) |
| 435 | |
| 436 | all_test_files_to_run = get_all_doctest_files() |
| 437 | |
| 438 | # Add to the test files to run any removed entry from "utils/not_doctested.txt". |
| 439 | new_test_files = get_new_doctest_files(repo, repo.head.commit, upstream_main.commit) |
| 440 | test_files_to_run = list(set(test_files_to_run + new_test_files)) |
| 441 | |
| 442 | # Do not run slow doctest tests on CircleCI |
| 443 | with open("utils/slow_documentation_tests.txt") as fp: |
| 444 | slow_documentation_tests = set(fp.read().strip().split("\n")) |
| 445 | test_files_to_run = [ |
| 446 | x for x in test_files_to_run if x in all_test_files_to_run and x not in slow_documentation_tests |
| 447 | ] |
| 448 | |
| 449 | # Make sure we did not end up with a test file that was removed |
| 450 | test_files_to_run = [f for f in test_files_to_run if (PATH_TO_REPO / f).exists()] |
| 451 | |
| 452 | return sorted(test_files_to_run) |
| 453 | |
| 454 | |
| 455 | # (:?^|\n) -> Non-catching group for the beginning of the doc or a new line. |
nothing calls this directly
no test coverage detected
searching dependent graphs…