-
Notifications
You must be signed in to change notification settings - Fork 432
Expand file tree
/
Copy pathrender-output-dir.test.ts
More file actions
54 lines (48 loc) · 1.41 KB
/
render-output-dir.test.ts
File metadata and controls
54 lines (48 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* render-output-dir.test.ts
*
* Test for Windows file locking issue with --output-dir flag
* Regression test for: https://github.com/quarto-dev/quarto-cli/issues/13625
*
* Copyright (C) 2020-2025 Posit Software, PBC
*
*/
import { existsSync, safeRemoveSync } from "../../../src/deno_ral/fs.ts";
import { docs } from "../../utils.ts";
import { isWindows } from "../../../src/deno_ral/platform.ts";
import { fileExists, pathDoNotExists } from "../../verify.ts";
import { testRender } from "./render.ts";
import type { Verify } from "../../test.ts";
const inputDir = docs("render-output-dir/");
const quartoDir = ".quarto";
const outputDir = "output-test-dir";
const cleanupDirs = async () => {
if (existsSync(outputDir)) {
safeRemoveSync(outputDir, { recursive: true });
}
if (existsSync(quartoDir)) {
safeRemoveSync(quartoDir, { recursive: true });
}
};
const testOutputDirRender = (
quartoVerify: Verify,
extraArgs: string[] = [],
) => {
testRender(
"test.qmd",
"html",
false,
[quartoVerify],
{
cwd: () => inputDir,
setup: cleanupDirs,
teardown: cleanupDirs,
},
["--output-dir", outputDir, ...extraArgs],
outputDir,
);
};
// Test 1: Default behavior (clean=true) - .quarto should be removed
testOutputDirRender(pathDoNotExists(quartoDir));
// Test 2: With --no-clean flag - .quarto should be preserved
testOutputDirRender(fileExists(quartoDir), ["--no-clean"]);