Skip to content

prove: do not select tests the change deletes - #4

Merged
jerryfane merged 2 commits into
mainfrom
fix/deleted-tests
Sep 26, 2026
Merged

jerryfane merged 2 commits into
mainfrom
fix/deleted-tests

Conversation

@jerryfane

Copy link
Copy Markdown
Contributor

Found while trying test-check on gitmoot (gitmoot#2261): tests the change deleted were still selected for per-test proving, then reported test_not_run. A test declaration on a removed line now clears the current test, so the deleted body is not attributed to any test; a rename still selects the new name. Regression test TestChangedTestNamesSkipsDeletedAndRenamedAwayTests fails on main ([TestKeep TestGone TestNewName]) and passes here.

@jerryfane

Copy link
Copy Markdown
Contributor Author

Agent: g7-review
Runtime: omp
Job: local-review-review-router-18d8cce018b3e4d5-1

Decision: approved
Summary: Executed review of PR #4 at exact head 34499a1 (diff aa04331..34499a1: internal/prove/prove.go, internal/prove/review_fixes_test.go, skills/test-check/SKILL.md). The pair of commits is correct: (1) a removed test declaration now resets current to "" so changed lines below a -func TestX( / -def test_x( line are never attributed to the deleted test (prove.go:331-342); (2) the new union filter re-reads every changed test file from the working tree and keeps only names still declared (prove.go:350-370), which is the right catch-all for hunk headers, since git labels hunks with the OLD file's function — verified live: the second commit's own regression fixture produces @@ func TestGone( and the deleted name is dropped, in both Go and Python. Verified requester's checklist end to end in a scratch copy: pure renames select nothing (changedPaths uses --no-renames, so the old path is unreadable and contributes no declarations); rename+edit selects the edited test; deleted tests never reach names via hunk headers; a name that enters names ONLY via an old-file hunk header is still kept when declared in a different changed test file (union semantics — verified, a_test.go header names TestMoved, b_test.go declares it, result [TestKeep TestOther TestMoved]); untracked test files contribute all their tests (untracked files are in testFiles, so the declared-scan also keeps same-name filtered entries — the seen-map dedupe hazard I suspected is unreachable via Run's call path); a fully deleted test file selects nothing; edited tracked tests are still selected. End-to-end Run() check: a fix + test-deletion change proves only TestAtThree — no test_not_run for the deleted name (the gitmoot#2261 failure mode). Filter is safe: every legitimate name comes from a + decl (declared in new content by construction) or a context/hunk-header decl still present in the file; filtered names share the names[:0] backing array correctly (write index <= read
[truncated]

Tests Run

  • CGO_ENABLED=0 go vet ./... — clean
  • CGO_ENABLED=0 go build ./... — clean
  • CGO_ENABLED=0 go test ./... — all 5 packages ok (cmd/test-check 0.156s, check 0.004s, jev 0.006s, prove 2.522s, source 0.080s)
  • CGO_ENABLED=0 go test ./internal/prove/ -run ChangedTestNames -v — 3/3 PASS including new TestChangedTestNamesSkipsDeletedAndRenamedAwayTests and TestChangedTestNamesIgnoresDeletedTestNamedByHunkHeader
  • Scratch copy ($HOME/scratch/tc-review, workspace untouched): 8 added scratch tests all PASS — TestScratchRenameOnlySelectsNothing, TestScratchRenamePlusEditSelectsTest, TestScratchPythonDeletedViaHunkHeader (fixture verified to emit '@@ def test_gone(' hunk header), TestScratchUntrackedFileContributesAll, TestScratchDeletedTestDeclaredInOtherChangedFileIsKept (fixture verified '@@ func TestMoved(' in a_test.go while TestMoved declared in b_test.go → kept), TestScratchDeletedFileSelectsNothing, TestScratchEditedTestStillSelected, TestScratchDeletedNameBlocksSameNameInUntrackedFile
  • CGO_ENABLED=0 go test -run TestScratchRunDropsDeletedTestEndToEnd — PASS: full prove.Run on a fix+test-deletion change yields report.Tests=[TestAtThree:proven], outcome proven, no test_not_run for the deleted TestGone (fixture verified to emit '@@ func TestGone(' hunk header)

Raw runtime output was retained in local Gitmoot state and is not posted here.

@jerryfane

Copy link
Copy Markdown
Contributor Author

Independent review-only job local-review-review-router-18d8cce018b3e4d5-1 (g7-review, devin/swe-2) approved exact head 34499a1685f73d95a7f2c3bb434700e6d19f6bda with no open findings. CI is green at this head. Merged locally onto current main (with #2): vet and go test ./... are clean. Merging.

@jerryfane
jerryfane merged commit 612ee14 into main Sep 26, 2026
1 check passed
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