Skip to content

Commit 0da1254

Browse files
matt2eclaude
andauthored
test: stop tests leaving temp dirs and a flake-check fixture behind (#1977)
Signed-off-by: Matt Toohey <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 177d375 commit 0da1254

7 files changed

Lines changed: 32 additions & 9 deletions

File tree

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ coverage/
2222
.buzz/
2323
.scratch/
2424

25+
# Left by an interrupted tests/integration/flake-check.test.mjs run.
26+
tests/fixtures/design-system/flake-selection-*/
27+
2528
# Local deployment settings and credentials never belong in Git.
2629
.npmrc
2730
.env

‎biome.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"!!src-tauri/target",
2020
"!!src-tauri/gen",
2121
"!!target",
22-
"!!test-results"
22+
"!!test-results",
23+
"!!tests/fixtures/design-system/flake-selection-*"
2324
]
2425
},
2526
"formatter": {

‎src-tauri/src/relay/tests.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,13 +519,14 @@ fn isolated_agent_ipc_probe() {
519519
}
520520
use tauri::test::{get_ipc_response, mock_builder, INVOKE_KEY};
521521
use tauri::Manager;
522+
// The probe owns the spool dir, so it is removed when the probe returns
523+
// or panics.
524+
let spools = tempfile::tempdir().unwrap();
522525
let app = mock_builder()
523526
.manage(IdentityHost::fixture())
524527
.manage(FederatedIdentity::new().unwrap())
525528
.manage(Uploads::default())
526-
.manage(Spools::new(Ok(
527-
std::env::temp_dir().join(format!("buzz-spool-ipc-{}", uuid::Uuid::new_v4()))
528-
)))
529+
.manage(Spools::new(Ok(spools.path().to_owned())))
529530
.manage(crate::archive::ArchiveHost::default())
530531
.invoke_handler(crate::commands())
531532
.build(crate::app_context())

‎tests/integration/flake-check.test.mjs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ test("test bodies span the listed test's call; groups, hooks and helpers are out
170170

171171
test("the selection executes every case of a multiline Vitest parameterized test", (t) => {
172172
const root = fileURLToPath(new URL("../../", import.meta.url));
173+
// Vitest only collects files its include globs match under the repository,
174+
// so the fixture cannot live in a temp dir. vitest.config.ts excludes it
175+
// unless this is set; the Vitest processes below inherit it.
176+
process.env.BUZZ_FLAKE_CHECK_FIXTURE = "1";
177+
t.after(() => delete process.env.BUZZ_FLAKE_CHECK_FIXTURE);
173178
const dir = mkdtempSync(
174179
join(root, "tests/fixtures/design-system/flake-selection-"),
175180
);

‎tests/integration/preview-feed.test.mjs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ function fixture(dir, version = "0.0.0-preview.22.1") {
107107
};
108108
}
109109

110-
test("preview candidate requires verified archive and updater-enabled binary with CLI 2.11.x signatures", () => {
110+
test("preview candidate requires verified archive and updater-enabled binary with CLI 2.11.x signatures", (t) => {
111111
const dir = mkdtempSync(join(tmpdir(), "preview-feed-"));
112+
t.after(() => rmSync(dir, { recursive: true, force: true }));
112113
const { assetDir, archive, binary, sig, manifest, sign, execute } =
113114
fixture(dir);
114115
const archiveBytes = readFileSync(archive);
@@ -166,8 +167,9 @@ test("preview candidate requires verified archive and updater-enabled binary wit
166167
assert.match(execute("verify").stderr, /updater public key/);
167168
});
168169

169-
test("preview feed signs every desktop installer into its updater target", () => {
170+
test("preview feed signs every desktop installer into its updater target", (t) => {
170171
const dir = mkdtempSync(join(tmpdir(), "preview-platforms-"));
172+
t.after(() => rmSync(dir, { recursive: true, force: true }));
171173
const { installers, manifest, execute } = fixture(dir);
172174
assert.equal(execute("generate").status, 0, execute("generate").stderr);
173175
const { platforms } = JSON.parse(readFileSync(manifest, "utf8"));
@@ -197,8 +199,9 @@ test("preview feed signs every desktop installer into its updater target", () =>
197199
assert.match(execute("generate").stderr, /ENOENT/);
198200
});
199201

200-
test("preview rollback compares the complete canonical SemVer without number rounding", () => {
202+
test("preview rollback compares the complete canonical SemVer without number rounding", (t) => {
201203
const dir = mkdtempSync(join(tmpdir(), "preview-versions-"));
204+
t.after(() => rmSync(dir, { recursive: true, force: true }));
202205
const { manifest, execute } = fixture(dir);
203206
assert.equal(execute("generate").status, 0);
204207
const current = join(dir, "current.json");

‎tsconfig.design.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"vite.message-gallery.config.ts",
88
"vite.design.config.ts",
99
"vitest.design.config.ts"
10-
]
10+
],
11+
"exclude": ["tests/fixtures/design-system/flake-selection-*"]
1112
}

‎vitest.config.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from "vitest/config";
1+
import { configDefaults, defineConfig } from "vitest/config";
22
import { fixtureAliases } from "./tests/relay-config.ts";
33
const workerLimit = process.env.BUZZ_TEST_WORKERS;
44
const maxWorkers = workerLimit === undefined ? undefined : Number(workerLimit);
@@ -27,5 +27,14 @@ export default defineConfig({
2727
"tests/browser/perf/**/*.test.mjs",
2828
"tests/fixtures/design-system/**/*.test.{ts,tsx}",
2929
],
30+
// flake-check.test.mjs writes a suite here with a test that fails if it
31+
// runs, and opts in for its own runs. A copy that an interrupted run
32+
// leaves behind stays out of every other run.
33+
exclude: process.env.BUZZ_FLAKE_CHECK_FIXTURE
34+
? configDefaults.exclude
35+
: [
36+
...configDefaults.exclude,
37+
"tests/fixtures/design-system/flake-selection-*/**",
38+
],
3039
},
3140
});

0 commit comments

Comments
 (0)