Skip to content

Commit 67a749f

Browse files
committed
test: add unit test for inputExtensionDirs at filesystem root
Verify that inputExtensionDirs terminates when projectDir is "/" instead of looping forever. Covers the fix for #14254.
1 parent 07deb8e commit 67a749f

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/unit/extension-dirs.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* extension-dirs.test.ts
3+
*
4+
* Copyright (C) 2020-2026 Posit Software, PBC
5+
*
6+
*/
7+
8+
import { unitTest } from "../test.ts";
9+
import { assert } from "testing/asserts";
10+
import { inputExtensionDirs } from "../../src/extension/extension.ts";
11+
12+
// Test for issue #14254: inputExtensionDirs should not hang when
13+
// projectDir is the filesystem root.
14+
// deno-lint-ignore require-await
15+
unitTest("extension-dirs - no infinite loop at filesystem root", async () => {
16+
const tempDir = Deno.makeTempDirSync({ prefix: "quarto-test-ext" });
17+
const tempFile = `${tempDir}/test.qmd`;
18+
Deno.writeTextFileSync(tempFile, "---\ntitle: test\n---\n");
19+
20+
// With projectDir = "/", the dirname loop must terminate at root.
21+
// If the root guard is missing, this call hangs forever.
22+
const dirs = inputExtensionDirs(tempFile, "/");
23+
assert(Array.isArray(dirs), "inputExtensionDirs should return an array");
24+
25+
Deno.removeSync(tempDir, { recursive: true });
26+
});

0 commit comments

Comments
 (0)