Skip to content

Commit dae0e92

Browse files
committed
Add a test for the --no-clean flag
1 parent 97fdd13 commit dae0e92

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

tests/smoke/render/render-output-dir.test.ts

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
import { existsSync, safeRemoveSync } from "../../../src/deno_ral/fs.ts";
1111
import { docs } from "../../utils.ts";
1212
import { isWindows } from "../../../src/deno_ral/platform.ts";
13-
import { pathDoNotExists } from "../../verify.ts";
13+
import { fileExists, pathDoNotExists } from "../../verify.ts";
1414
import { testRender } from "./render.ts";
1515

1616
if (isWindows) {
17-
const inputDir = docs("render-output-dir/");
18-
const quartoDir = ".quarto"
19-
const outputDir = "output-test-dir"
17+
const inputDir = docs("render-output-dir/");
18+
const quartoDir = ".quarto";
19+
const outputDir = "output-test-dir";
2020

21+
// Test 1: Default behavior (clean=true) - .quarto should be removed
2122
testRender(
2223
"test.qmd",
2324
"html",
@@ -39,11 +40,41 @@ if (isWindows) {
3940
safeRemoveSync(outputDir, { recursive: true });
4041
}
4142
if (existsSync(quartoDir)) {
42-
safeRemoveSync(quartoDir, { recursive: true });
43+
safeRemoveSync(quartoDir, { recursive: true });
4344
}
4445
},
45-
},
46+
},
4647
["--output-dir", outputDir],
4748
outputDir,
4849
);
50+
51+
// Test 2: With --no-clean flag - .quarto should be preserved
52+
testRender(
53+
"test.qmd",
54+
"html",
55+
false,
56+
[fileExists(quartoDir)],
57+
{
58+
cwd: () => inputDir,
59+
setup: async () => {
60+
// Ensure output and quarto dirs are removed before test
61+
if (existsSync(outputDir)) {
62+
safeRemoveSync(outputDir, { recursive: true });
63+
}
64+
if (existsSync(quartoDir)) {
65+
safeRemoveSync(quartoDir, { recursive: true });
66+
}
67+
},
68+
teardown: async () => {
69+
if (existsSync(outputDir)) {
70+
safeRemoveSync(outputDir, { recursive: true });
71+
}
72+
if (existsSync(quartoDir)) {
73+
safeRemoveSync(quartoDir, { recursive: true });
74+
}
75+
},
76+
},
77+
["--output-dir", outputDir, "--no-clean"],
78+
outputDir,
79+
);
4980
}

0 commit comments

Comments
 (0)