Skip to content

Share fixture and verdict helpers in the project inspection tests - #180

Draft
Deicyde wants to merge 4 commits into
mainfrom
golf/project-inspect-test-helpers
Draft

Deicyde wants to merge 4 commits into
mainfrom
golf/project-inspect-test-helpers

Conversation

@Deicyde

@Deicyde Deicyde commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

This PR only changes tests: tests/test_project_inspect.py goes from 2222 to 2133 lines (+60/-149), with one commit per item. The same 272 cases run. #174, which cleans up the code these tests cover, edits other files.

  • _write_overrides. Eight tests wrote .lake/package-overrides.json themselves instead of calling the helper. Three of them did so because they needed a schema version other than 1.1.0. The helper now takes schema_version, and all eight call it.
  • _assert_mathlib_unused. Eight tests repeated the same three assertions: no Mathlib, indeterminate compatibility, and a mathlib-manifest-unused diagnostic. The helper's docstring names the verdict: a locked Mathlib that no requirement pulls in decides no release pair.
  • _unreadable. Ten assertions filtered the diagnostics for unreadable-file paths inline. _unreadable(result) returns the same list in the same order.
  • Parametrization. Tests that differ only in data become cases:
    • test_equivalent_mathlib_url_spellings_match and three single-case lock-spelling tests become test_equivalent_lock_spellings_match_the_catalog, with named cases: url-scheme-host-case, url-dot-git, url-trailing-slash, subdir-current-directory and uppercase-commit. Three of the cases now also check the release, which already held.
    • test_integer_manifest_versions_are_read joins the newer 1.x test as test_integer_and_newer_1x_manifest_versions_are_read.
    • The A versus «A» duplicate-name test joins the three cases of test_toml_simple_name_fallback_matches_the_equivalent_escape, which had the same body. The merged test keeps the name test_duplicate_target_names_are_compared_as_lean_names.

#90 also edits this file. It merges with this branch without adding a conflict, but it already conflicts with main, so the two cannot be test-merged yet. Merged with #174, the file passes (272).

Validation at exact head 1bb31599: ruff check autoform_cli servers tests is clean, and tests/test_project_inspect.py passes (272).

Eight tests wrote .lake/package-overrides.json by hand instead of
calling the helper that already did it. _write_overrides takes a
schema_version keyword for the legacy-layout cases, and the files it
writes are byte-identical to the hand-written ones.
Eight tests repeated the same three assertions: no Mathlib, an
indeterminate status and a mathlib-manifest-unused diagnostic. They now
call _assert_mathlib_unused.
Ten assertions filtered the diagnostics for unreadable-file paths
inline. _unreadable(result) returns the same list in the same order.
- Four lock-spelling tests join the URL-spelling parametrization as
  named cases. Three of them now also check the release, which already
  held.
- The integer manifest version joins the newer 1.x version test.
- The A versus «A» duplicate-name test joins the escape test with the
  same body.
The case count is unchanged.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 7, 2026
@Deicyde

Deicyde commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

Review at 1bb3159

Verdict: merge-ready. The refactor is test-only, runs the same 272 cases and keeps every check. CI is green at this head.

How it was checked:

  • Same cases. pytest --collect-only at main 89dff279 and at this head both give 272 cases. The 12 ids that changed fold into three parametrized tests with the same total:
    • 1 + 2 + 3 lock-spelling tests become 5 named cases. The old URL-spelling test had 2 cases, plus three single tests.
    • The integer and newer-1.x version tests (1 + 2) become 3 cases.
    • The duplicate-name test and the TOML fallback test (1 + 3) become 4 cases.
  • Same inputs and bodies.
    • Each lock-spelling case passes the same _mathlib(...) keyword its old test did.
    • [7, "1.3.0", "1.9.0"] runs the unchanged version body.
    • The ("A", "«A»") case formats to the old duplicate test's exact lakefile, and the two old bodies were already identical.
    • Three lock-spelling cases gain a release assertion; nothing is dropped.
  • Helpers.
    • _write_overrides writes byte-identical JSON: same key order, same json.dumps defaults, same mkdir.
    • _unreadable(result) is the inline filter. x in _unreadable(result) equals the old any(...).
    • _assert_mathlib_unused is the same three assertions.
    • The three inline unreadable-file filters left in the file also check severity, so leaving them inline is right.
  • CI. The real-Lean job selects tests/test_project_inspect.py::test_stale_inherited_mathlib_is_ignored_by_real_lake by node id. That test keeps its name at this head.

Landing

Posted by PR swarm: Review #173 #174 #180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant