MCPcopy Index your code
hub / github.com/RustPython/RustPython / compute_test_todo_list

Function compute_test_todo_list

scripts/update_lib/cmd_todo.py:306–380  ·  view source on GitHub ↗

Compute prioritized list of tests to update. Scoring: - If corresponding lib is up-to-date: score = 0 (ready) - If no corresponding lib: score = 1 (independent) - If corresponding lib is NOT up-to-date: score = 2 (wait for lib) Returns: List of dicts with te

(
    cpython_prefix: str,
    lib_prefix: str,
    include_done: bool = False,
    lib_status: dict[str, bool] | None = None,
)

Source from the content-addressed store, hash-verified

304
305
306def compute_test_todo_list(
307 cpython_prefix: str,
308 lib_prefix: str,
309 include_done: bool = False,
310 lib_status: dict[str, bool] | None = None,
311) -> list[dict]:
312 """Compute prioritized list of tests to update.
313
314 Scoring:
315 - If corresponding lib is up-to-date: score = 0 (ready)
316 - If no corresponding lib: score = 1 (independent)
317 - If corresponding lib is NOT up-to-date: score = 2 (wait for lib)
318
319 Returns:
320 List of dicts with test info, sorted by priority
321 """
322 all_tests = get_all_tests(cpython_prefix)
323 test_to_lib, lib_test_order = _build_test_to_lib_map(cpython_prefix)
324
325 result = []
326 for test_name in all_tests:
327 up_to_date = is_test_up_to_date(test_name, cpython_prefix, lib_prefix)
328
329 if up_to_date and not include_done:
330 continue
331
332 tracked = is_test_tracked(test_name, cpython_prefix, lib_prefix)
333
334 # Check DEPENDENCIES mapping first, then fall back to simple extraction
335 if test_name in test_to_lib:
336 lib_name = test_to_lib[test_name]
337 # Get order from DEPENDENCIES
338 test_order = lib_test_order[lib_name].index(test_name)
339 else:
340 # Extract lib name from test name:
341 # - test_foo -> foo
342 # - datetimetester -> datetime
343 # - xmltests -> xml
344 lib_name = (
345 test_name.removeprefix("test_")
346 .removeprefix("_test")
347 .removesuffix("tester")
348 .removesuffix("tests")
349 )
350 test_order = 0 # Default order for tests not in DEPENDENCIES
351
352 # Check if corresponding lib is up-to-date
353 # Scoring: 0 = lib ready (highest priority), 1 = no lib, 2 = lib pending
354 if lib_status and lib_name in lib_status:
355 lib_up_to_date = lib_status[lib_name]
356 if lib_up_to_date:
357 score = 0 # Lib is ready, can update test
358 else:
359 score = 2 # Wait for lib first
360 else:
361 score = 1 # No corresponding lib (independent test)
362
363 todo_count = count_test_todos(test_name, lib_prefix) if tracked else 0

Callers 1

format_all_todoFunction · 0.85

Calls 10

is_test_up_to_dateFunction · 0.90
is_test_trackedFunction · 0.90
count_test_todosFunction · 0.90
get_all_testsFunction · 0.85
_build_test_to_lib_mapFunction · 0.85
indexMethod · 0.45
removesuffixMethod · 0.45
removeprefixMethod · 0.45
appendMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected