Skip to content

test: prune and speed up root tests m-z - #365

Merged
lanyue-llk merged 7 commits into
mainfrom
tests/prune-root-m
Nov 24, 2026
Merged

lanyue-llk merged 7 commits into
mainfrom
tests/prune-root-m

Conversation

@lanyue-llk

Copy link
Copy Markdown
Contributor

Purpose

Review every top-level test file tests/test_[m-z]*.py (206 files) for necessity and cost, as part of the suite speed target in #356.

xychart-beta
    title "tests/test_[m-z]*.py at -n 8 (same host, before/after)"
    x-axis ["wall s", "summed s / 10", "tests / 100"]
    bar [195, 122, 46.5]
    bar [46, 31, 36.8]
Loading
Scope tests/test_[m-z]*.py Before After
Collected tests (incl. params) 4,646 3,681 (−21%)
Lines 55,059 53,594 (−2.7%)
Summed durations (--durations=0) 1,220 s ~305 s (−75%)
Wall time at -n 8 --dist worksteal 195 s 46 s
Result 1 failed (moli dns timeout flake) 3,659 passed, 22 skipped

Line count moved little: most of the gain came from shared builds, synthetic populations and table-driven loops that keep every distinct case, not from wholesale deletion. The remaining tests are mainly release-gate, evidence and hash-binding negative controls.

Changes by reason

Fixed

Test Change
test_moli_provider, test_native_cdp_port, test_native_route_contract, test_packaging_hygiene, test_native_runtime_configuration macOS assesses each newly created executable on first launch (~1.4 s). Tests wrote a fresh fake binary per test, and inside 1–2 s fetch budgets that caused timeouts (the dns failure on main). Fake binaries are now per class/module, rewritten in place, and the moli class warms its binary in setUpClass.
test_moli_provider::test_cancel_permission_error_preserves_timeout… Failed ~1 in 8 (the 0.1 s deadline could cancel before the child started). Validate first; 0.5 s deadline.
test_moli_provider::test_timeout_stops_a_browser_child… Waits for child exit instead of sleep(2.1).
test_run_benchmark The CLI's fixed delay=.5 is replaced by a no-op sleep in tests (13 s → 1.8 s).

Shrunk (same behaviour, cheaper input)

Test Change Still covers
test_risk_control_dataset::test_every_contract_validates… (50 s) Validates all 100 contracts; scores positive + adjacent negative for the 20 smallest bodies (region counts 1–5, composite, repeated labels) full contract validation
test_popular_sites_current::test_every_case… (30 s) Verifies the frozen source tree once instead of per case same hash checks
test_public_tree_privacy (15–31 s) Hostname regex gains a lookbehind; same matches on the whole tracked tree (diffed), 4× faster same gate
test_webmainbench_assembly (44 s), test_webmainbench_certification_commands (17 s), test_webmainbench_sample_case_correction 5-case synthetic populations instead of 545/200 all negative controls
test_wcxb_scoring, _latency_collection, _profile_admission, _report_languages Module-scoped 511-case cohort / report builds, copied per test
test_report_templates (36 s → 2 s), test_report_software_versions, test_resource_cohort_boundary, test_optional_reports, test_provider_evidence_boundary, saved-matrix evidence/composition One module/class build, copied or restored per mutation
test_report_browser_interactions (101 s → 20 s) One display/theme per test except the width-dependent rank test; negative theme timeouts 3 s → 0.6 s both negative controls kept
test_scoring_regressions Keeps only the root-cause FP/FN pairing check; verdicts of every control are scored by tests/benchmarks/webfetch/test_standalone_evaluation.py::test_declared_acceptance_scenarios (escaped-pipe field check: test_review_table_literal_serialization.py)
Parametrize matrices across ~40 files Cut to one case per distinct branch (e.g. selected-native origin status 54 → 22, not-called admission 36 → 9, publish interruptions 18 → 8, preflight params 30 → 17)

Merged (table-driven, every case kept)

Moli debug-log parser (8 → 1), config validation (13 + class → 1), dynamic hints/completion; native-route release negative controls (22 → 1 with subtests); provider registry (44 → 1); package contents (39 → 17); moli version chart validation; failure-category and filter-default tests; record-io, report-language resolution (24 → 1), reference lifecycle track × kind (28 → 1); WCXB cohort defects, assembly, latency authority, metric value tables, owner-command help (54 → 1).

Deleted

Reason Tests Still covered by
Source/text greps moli resource-route string grep, test_runtime_entrypoints (9 pyproject/Makefile/ci.yml/.env.example greps), CSS/JS greps in test_webmainbench_report and test_report_presentation, title-label grep, catalog-examples AST scan runtime policy gates kept (uv pin, no system Python, publishing does not load .env)
Non-contract wording / pinned catalog strings 5 guide-wording tests in test_report_body_scope, 5 catalog-string tests in test_report_capabilities, translation-map sentences, 3 pinned historical release IDs in test_report_changes, saved-matrix English wording tests whole-catalog translation and untranslated-narrative gates
Owned by lexbench-webfetch 8 test_risk_control_dataset tests of compiler/frozen-data shape, test_retrieval_hints frozen-dataset check lexbench package; run-profile hash bindings kept here
Duplicates test_risk_control_report.py (reran the same 100-case build; assertions moved into test_certified_report_preserves_certificate_bound_files, now also building English), test_timeout_is_failure, legacy completion-wait duplicates, refresh_restores_baseline_pages, test_historical_train_count_remains_1497, duplicate canonical-options test, private cache-structure tests in test_publication_privacy test_public_evidence_views::test_privacy_check_reuses_only_identical_bytes etc.
Removed code portable_cli failure-sources.json case (nothing reads the file)
Unused fixtures tests/conftest.py::validated_catalog, tests/helpers.py::shipped_suite_validations (no users after #361)

Verification

  • uv run --frozen --all-extras python -m pytest tests/test_[m-z]*.py -q -n 8 --dist worksteal: 3,659 passed, 22 skipped; tests/test_moli_provider.py 6/6 repeated runs green.
  • tests/baselines, architecture tests, tests/benchmarks/webfetch and the non-scope files importing scope helpers: 11,369 passed.
  • make lint-check passes. uv run --frozen lexbench-webfetch version: scoring_source_sha256 0fe8931734e1ba7282e1e9c8303eea958d20fdcee83d84e87cdc7e08cd08169e (unchanged). No production code changed.

Left for follow-up (not changed here)

  • webmainbench_assembly.py:106 calls load_source without expected_count=profile["case_count"] (certification passes it); tests patch it. Passing it would remove the monkeypatch.
  • Seams that would cut more: a parameter for the runner CLI's fixed 0.5 s delay and unstoppable-worker wait; a sample-size parameter in webmainbench_case_correction.apply (hard-codes 200); caching native_projection_source() (re-hashed >7,000 times per baseline run); skipping AST work for files without Han characters in check_source_languages.
  • test_scoring.py::ScoringTests and test_reference_quality.py test lexbench_webfetch code and arguably belong upstream; kept because upstream coverage is thin.
  • test_release_metadata::test_installed_benchmarks_match_their_frozen_catalogs (~6 s) loads every websearch dataset; kept as the only check.

Part of #356

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Review complete · e04144f

No findings in this review.

@lanyue-llk
lanyue-llk merged commit bad32ba into main Nov 24, 2026
10 checks passed
@lanyue-llk
lanyue-llk deleted the tests/prune-root-m branch November 24, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant