Format prioritized list of modules and tests to update. Returns: List of formatted lines
(
cpython_prefix: str,
lib_prefix: str,
limit: int | None = None,
include_done: bool = False,
verbose: bool = False,
)
| 527 | |
| 528 | |
| 529 | def format_all_todo( |
| 530 | cpython_prefix: str, |
| 531 | lib_prefix: str, |
| 532 | limit: int | None = None, |
| 533 | include_done: bool = False, |
| 534 | verbose: bool = False, |
| 535 | ) -> list[str]: |
| 536 | """Format prioritized list of modules and tests to update. |
| 537 | |
| 538 | Returns: |
| 539 | List of formatted lines |
| 540 | """ |
| 541 | from update_lib.cmd_deps import get_all_modules |
| 542 | from update_lib.deps import is_up_to_date |
| 543 | |
| 544 | lines = [] |
| 545 | |
| 546 | # Build lib status map for test scoring |
| 547 | lib_status = {} |
| 548 | for name in get_all_modules(cpython_prefix): |
| 549 | lib_status[name] = is_up_to_date(name, cpython_prefix, lib_prefix) |
| 550 | |
| 551 | # Compute test todo (always include all to find libs with pending tests) |
| 552 | test_todo = compute_test_todo_list( |
| 553 | cpython_prefix, lib_prefix, include_done=True, lib_status=lib_status |
| 554 | ) |
| 555 | |
| 556 | # Build test_by_lib map (only for tests with corresponding lib) |
| 557 | test_by_lib: dict[str, list[dict]] = {} |
| 558 | no_lib_tests = [] |
| 559 | # Set of libs that have pending tests |
| 560 | libs_with_pending_tests = set() |
| 561 | for test in test_todo: |
| 562 | if test["score"] == 1: # no lib |
| 563 | if not test["up_to_date"] or include_done: |
| 564 | no_lib_tests.append(test) |
| 565 | else: |
| 566 | lib_name = test["lib_name"] |
| 567 | if lib_name not in test_by_lib: |
| 568 | test_by_lib[lib_name] = [] |
| 569 | test_by_lib[lib_name].append(test) |
| 570 | if not test["up_to_date"]: |
| 571 | libs_with_pending_tests.add(lib_name) |
| 572 | |
| 573 | # Sort each lib's tests by test_order (from DEPENDENCIES) |
| 574 | for tests in test_by_lib.values(): |
| 575 | tests.sort(key=lambda x: x.get("test_order", 0)) |
| 576 | |
| 577 | # Compute lib todo - include libs with pending tests even if lib is done |
| 578 | lib_todo_base = compute_todo_list(cpython_prefix, lib_prefix, include_done=True) |
| 579 | |
| 580 | # Filter lib todo: include if lib is not done OR has pending test |
| 581 | lib_todo = [] |
| 582 | for item in lib_todo_base: |
| 583 | lib_not_done = not item["up_to_date"] |
| 584 | has_pending_test = item["name"] in libs_with_pending_tests |
| 585 | |
| 586 | if include_done or lib_not_done or has_pending_test: |
no test coverage detected