test(cli): migrate dedup_test.go to t.Chdir + lock isolation ratchet 163->151 (ag-4nif #dedup-tchdir)#773
Merged
Merged
Conversation
…163->151 (ag-4nif #dedup-tchdir) Migrate dedup_test.go's 6 manual `os.Getwd()/os.Chdir/defer-restore` blocks to Go 1.20+ t.Chdir(tmp), which auto-restores cwd AND refuses t.Parallel — pre-empting the latent flake class flagged by ag-4nif/ag-k38x. No t.Parallel in the file; behavior-preserving. Each block held two `os.Chdir(` refs (the call + the defer), so 6 blocks drop the repo-wide test-isolation count by 12 (163->151). Lower BASELINE_CHDIR in scripts/check-test-isolation.sh to lock the gain (the ratchet is only-goes-down). Scope: os.Chdir only. The 3 redundant os.Setenv restores in rpi_reliability_test.go are already handled by the open PR #772 (ag-k38x), so they are deliberately NOT touched here to avoid a merge collision. ag-k38x is the canonical tracker; ag-4nif/ag-y4ac are its duplicates. Closes-scenario: ag-4nif#dedup-tchdir Bounded-context: BC5-Runtime Evidence: scripts/check-test-isolation.sh PASS (os.Chdir=151/151); go build ./... + go vet ./cmd/ao + go test ./cmd/ao -run 'TestRunDedup|TestMergeDedupGroups' (17 pass); gofmt clean
4af5f3d to
e268d0b
Compare
boshu2
added a commit
that referenced
this pull request
Jun 6, 2026
…e-tchdir-w2) (#786) ## What Collapse 7 identical `os.Getwd()` + `os.Chdir(tmpDir)` + `t.Cleanup(restore)` blocks in `cli/cmd/ao/curate_test.go` to `t.Chdir(tmpDir)`. Bare downstream `err =` first-uses promoted to `err :=` (the removed block held the only function-scope `err`). ## Why `t.Chdir` auto-restores cwd on cleanup **and** refuses to run under `t.Parallel` — pre-empting the process-global-cwd flake class (cf. ag-jfzs). This is one wave of the ag-k38x / ag-y4ac test-isolation sweep (`finish-the-job`: ~133 sites already use the safe idiom). ## Scope / collision-safety - `os.Chdir` in `_test.go`: **163 → 149 (-14)**. `os.Setenv` untouched (owned by in-flight setenv ratchet **PR #772**). - **`BASELINE_CHDIR` intentionally NOT lowered** — that single line is the contention point with in-flight **PR #772/#773**; the ratchet stays green because count-below-baseline is a NOTE, not a failure (`149 <= 163`). A later wave locks the baseline once those settle. - Non-overlapping with PR #772 (rpi setenv) and PR #773 (dedup_test.go os.Chdir). ## Verification - `gofmt -l` clean · `go build ./...` · `go vet ./cmd/ao` clean - `go test ./cmd/ao -run TestCurate` → 14 pass - `scripts/check-test-isolation.sh` → PASS (os.Chdir=149/163, os.Setenv=22/22) - `scripts/pre-push-gate.sh --fast` → passed Closes-scenario: ag-y4ac#curate-tchdir-w2 Bounded-context: BC5-Runtime Evidence: .ntm/bo-queue/2026-06-06-ag-y4ac-pr-curate-tchdir.md
…etenv-w1 # Conflicts: # scripts/check-test-isolation.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Migrate
dedup_test.go's 6 manualorigDir, _ := os.Getwd(); os.Chdir(tmp); defer os.Chdir(origDir)blocks to Go 1.20+t.Chdir(tmp)— auto-restores cwd and refusest.Parallel, pre-empting the latent flake class flagged by ag-4nif / ag-k38x (raw forms mutate process-global cwd). Not.Parallelin the file; behavior-preserving.Each block held two
os.Chdir(references (the call + the defer restore), so 6 blocks drop the repo-wide test-isolation count by 12 (163→151). I loweredBASELINE_CHDIRinscripts/check-test-isolation.shto lock the gain (the ratchet is only-goes-down).Scope / no-collision note
os.Chdironly. The 3 redundantos.Setenvrestores inrpi_reliability_test.goare already handled by the open PR #772 (ag-k38x) — I deliberately do not touch that file here, to avoid a merge collision (an earlier draft of this branch did; it was reverted). ag-k38x is the canonical tracker; ag-4nif/ag-y4ac are duplicates — worth closing as dup-of-ag-k38x during triage.Evidence
Net: −19 / +8 across
dedup_test.go+ the ratchet baseline.Closes-scenario: ag-4nif#dedup-tchdir
Bounded-context: BC5-Runtime
Evidence: ratchet PASS + go build/vet/test (17 pass) + gofmt clean