Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions cli/cmd/ao/dedup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,7 @@ func TestMergeDedupGroups_DryRun(t *testing.T) {

func TestRunDedup_NoDirs(t *testing.T) {
tmp := t.TempDir()
origDir, _ := os.Getwd()
os.Chdir(tmp)
defer func() { _ = os.Chdir(origDir) }()
t.Chdir(tmp)
r, w, _ := os.Pipe()
origStdout := os.Stdout
os.Stdout = w
Expand All @@ -610,9 +608,7 @@ func TestRunDedup_NoDirs(t *testing.T) {
func TestRunDedup_EmptyDirs(t *testing.T) {
tmp := t.TempDir()
os.MkdirAll(filepath.Join(tmp, ".agents", "learnings"), 0o755)
origDir, _ := os.Getwd()
os.Chdir(tmp)
defer func() { _ = os.Chdir(origDir) }()
t.Chdir(tmp)
r, w, _ := os.Pipe()
origStdout := os.Stdout
os.Stdout = w
Expand All @@ -634,9 +630,7 @@ func TestRunDedup_TextOutput(t *testing.T) {
ld := filepath.Join(tmp, ".agents", "learnings")
os.MkdirAll(ld, 0o755)
os.WriteFile(filepath.Join(ld, "a.md"), []byte("---\ntitle: A\n---\nUnique A."), 0o644)
origDir, _ := os.Getwd()
os.Chdir(tmp)
defer func() { _ = os.Chdir(origDir) }()
t.Chdir(tmp)
origOutput := output
output = "table"
defer func() { output = origOutput }()
Expand Down Expand Up @@ -664,9 +658,7 @@ func TestRunDedup_TextOutputWithDuplicates(t *testing.T) {
body := "Identical body."
os.WriteFile(filepath.Join(ld, "d1.md"), []byte("---\ntitle: D1\n---\n"+body), 0o644)
os.WriteFile(filepath.Join(ld, "d2.md"), []byte("---\ntitle: D2\n---\n"+body), 0o644)
origDir, _ := os.Getwd()
os.Chdir(tmp)
defer func() { _ = os.Chdir(origDir) }()
t.Chdir(tmp)
origOutput := output
output = "table"
defer func() { output = origOutput }()
Expand All @@ -693,9 +685,7 @@ func TestRunDedup_MergeDryRun(t *testing.T) {
body := "Same merge."
os.WriteFile(filepath.Join(ld, "m1.md"), []byte("---\nutility: 0.9\n---\n"+body), 0o644)
os.WriteFile(filepath.Join(ld, "m2.md"), []byte("---\nutility: 0.3\n---\n"+body), 0o644)
origDir, _ := os.Getwd()
os.Chdir(tmp)
defer func() { _ = os.Chdir(origDir) }()
t.Chdir(tmp)
origMerge := dedupMerge
dedupMerge = true
defer func() { dedupMerge = origMerge }()
Expand Down Expand Up @@ -723,9 +713,7 @@ func TestRunDedup_MergeNoDuplicates(t *testing.T) {
ld := filepath.Join(tmp, ".agents", "learnings")
os.MkdirAll(ld, 0o755)
os.WriteFile(filepath.Join(ld, "u.md"), []byte("---\ntitle: U\n---\nUnique."), 0o644)
origDir, _ := os.Getwd()
os.Chdir(tmp)
defer func() { _ = os.Chdir(origDir) }()
t.Chdir(tmp)
origMerge := dedupMerge
dedupMerge = true
defer func() { dedupMerge = origMerge }()
Expand Down
4 changes: 3 additions & 1 deletion scripts/check-test-isolation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$REPO_ROOT"

# Baselines captured 2026-06-03 (excludes the testutil_test.go helper home).
# CHDIR lowered to 137 (ag-4nif): dedup_test.go migrated 6 raw os.Chdir blocks to t.Chdir,
# combined with the in-flight migrations already on main, locks the merged actual count.
# os.Setenv lowered 22->12 on 2026-06-06 (ag-k38x #bulk-migration). The remaining 12
# are intentional and cannot use t.Setenv: TestMain sites (no *testing.T), string-literal
# fixtures in fix_cliconfig_test.go, and unset-semantics helpers (t.Setenv cannot unset).
BASELINE_CHDIR=163
BASELINE_CHDIR=137
BASELINE_SETENV=12

chdir=$(grep -rho --include='*_test.go' --exclude='testutil_test.go' 'os\.Chdir(' cli 2>/dev/null | wc -l | tr -d ' ')
Expand Down
Loading