From e387170381b083ae424936a481f30be002501d88 Mon Sep 17 00:00:00 2001 From: tequ Date: Sat, 4 Jul 2026 13:21:31 +0900 Subject: [PATCH] Fix unreliable integration test directory cleanup Test setup/teardown used fs.rmdirSync, which fails when the target directory is not empty or no longer exists. That left stale artifacts between runs and made cleanup brittle. Use fs.rmSync with recursive and force so directories are removed reliably regardless of contents or prior existence. --- test/integration/build.test.ts | 8 ++++---- test/integration/init.test.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/integration/build.test.ts b/test/integration/build.test.ts index b539848..4a6b9f9 100644 --- a/test/integration/build.test.ts +++ b/test/integration/build.test.ts @@ -37,14 +37,14 @@ describe("Build Tests", () => { beforeEach(() => { // Ensure output directory does not exist if (fs.existsSync(outDir)) { - fs.rmdirSync(outDir, { recursive: true }); + fs.rmSync(outDir, { recursive: true, force: true }); } }); afterEach(() => { // Clean up if (fs.existsSync(outDir)) { - fs.rmdirSync(outDir, { recursive: true }); + fs.rmSync(outDir, { recursive: true, force: true }); } }); @@ -122,14 +122,14 @@ describe("Build Tests", () => { beforeEach(() => { // Ensure output directory does not exist if (fs.existsSync(outDir)) { - fs.rmdirSync(outDir, { recursive: true }); + fs.rmSync(outDir, { recursive: true, force: true }); } }); afterEach(() => { // Clean up if (fs.existsSync(outDir)) { - fs.rmdirSync(outDir, { recursive: true }); + fs.rmSync(outDir, { recursive: true, force: true }); } }); diff --git a/test/integration/init.test.ts b/test/integration/init.test.ts index d5ca183..55b520b 100644 --- a/test/integration/init.test.ts +++ b/test/integration/init.test.ts @@ -37,20 +37,20 @@ describe("Init Tests", () => { beforeEach(() => { // Clean up any existing directories if (fs.existsSync(projectPathC)) { - fs.rmdirSync(projectPathC, { recursive: true }); + fs.rmSync(projectPathC, { recursive: true, force: true }); } if (fs.existsSync(projectPathJS)) { - fs.rmdirSync(projectPathJS, { recursive: true }); + fs.rmSync(projectPathJS, { recursive: true, force: true }); } }); afterEach(() => { // Clean up created directories if (fs.existsSync(projectPathC)) { - fs.rmdirSync(projectPathC, { recursive: true }); + fs.rmSync(projectPathC, { recursive: true, force: true }); } if (fs.existsSync(projectPathJS)) { - fs.rmdirSync(projectPathJS, { recursive: true }); + fs.rmSync(projectPathJS, { recursive: true, force: true }); } });