Skip to content

Fix test that leaks files into the repo#120

Merged
chlowell merged 1 commit into
microsoft:mainfrom
chlowell:test-spam
Mar 12, 2026
Merged

Fix test that leaks files into the repo#120
chlowell merged 1 commit into
microsoft:mainfrom
chlowell:test-spam

Conversation

@chlowell

Copy link
Copy Markdown
Member

Running go test ./cmd/waza/... left two untracked files in the repo:

cmd/waza/.override-cache/
cmd/waza/<timestamp>-session.jsonl

These were created by TestRunCommandForSpec_NilCmd_OverridesTrials, which calls runCommandForSpec directly without first resetting the package-level flag variables. When it ran after TestRunCommand_CLIFlagsOverrideWazaYaml, it inherited that test's globals:

  • sessionLog = true → wrote a .jsonl session log to the working directory
  • enableCache = true + runCacheDir = ".override-cache" → created a cache directory in the working directory

Because this test doesn't os.Chdir into a temp dir (unlike the .waza.yaml integration tests), those files landed in cmd/waza/ — the default working directory for go test.

Fix

Added resetRunGlobals() at the top of the test, matching the convention used by every other test in the file. This resets sessionLog, enableCache, and all other flag variables to their zero/default values before the test runs.

Also removed the manual save/restore block for trials, outputPath, contextDir, and formatresetRunGlobals() already covers these, and the partial restore was the root cause (it didn't restore sessionLog, enableCache, or runCacheDir).

Copilot AI review requested due to automatic review settings March 12, 2026 17:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a test isolation issue in cmd/waza where package-level flag globals could leak between tests, causing go test ./cmd/waza/... to leave untracked cache/session-log artifacts in the repo.

Changes:

  • Reset run-command package globals at the start of TestRunCommandForSpec_NilCmd_OverridesTrials via resetRunGlobals().
  • Remove the partial manual save/restore block that didn’t cover all relevant globals (e.g., session logging and cache settings).

@chlowell chlowell marked this pull request as ready for review March 12, 2026 17:26
@chlowell chlowell enabled auto-merge (squash) March 12, 2026 17:26
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@3f73d31). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #120   +/-   ##
=======================================
  Coverage        ?   73.32%           
=======================================
  Files           ?      135           
  Lines           ?    15521           
  Branches        ?        0           
=======================================
  Hits            ?    11381           
  Misses          ?     3308           
  Partials        ?      832           
Flag Coverage Δ
go-implementation 73.32% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@chlowell chlowell merged commit 03c57bf into microsoft:main Mar 12, 2026
11 of 12 checks passed
@chlowell chlowell deleted the test-spam branch March 12, 2026 19:54
@spboyer spboyer mentioned this pull request Mar 12, 2026
4 tasks
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.

4 participants