|
| 1 | +/* |
| 2 | + * render-symlink-embed-resources.test.ts |
| 3 | + * |
| 4 | + * Regression test for https://github.com/quarto-dev/quarto-cli/issues/13890 |
| 5 | + * |
| 6 | + * When rendering a qmd via a symlinked path with embed-resources: true, |
| 7 | + * the cleanup should not fail due to path mismatch between symlink and real path. |
| 8 | + * |
| 9 | + * Copyright (C) 2020-2025 Posit Software, PBC |
| 10 | + */ |
| 11 | + |
| 12 | +import { testQuartoCmd } from "../../test.ts"; |
| 13 | +import { noErrors, fileExists } from "../../verify.ts"; |
| 14 | +import { docs } from "../../utils.ts"; |
| 15 | +import { join, dirname, resolve } from "../../../src/deno_ral/path.ts"; |
| 16 | +import { existsSync } from "../../../src/deno_ral/fs.ts"; |
| 17 | +import { isWindows } from "../../../src/deno_ral/platform.ts"; |
| 18 | + |
| 19 | +const testDir = docs("render/symlink-embed-resources"); |
| 20 | +const testFile = "test.qmd"; |
| 21 | +const symlinkDir = join(dirname(testDir), "symlink-embed-resources-link"); |
| 22 | + |
| 23 | +testQuartoCmd( |
| 24 | + "render", |
| 25 | + [join(symlinkDir, testFile)], |
| 26 | + [ |
| 27 | + noErrors, |
| 28 | + fileExists(join(symlinkDir, "test.html")), |
| 29 | + ], |
| 30 | + { |
| 31 | + ignore: isWindows, |
| 32 | + setup: async () => { |
| 33 | + if (existsSync(symlinkDir)) { |
| 34 | + await Deno.remove(symlinkDir); |
| 35 | + } |
| 36 | + // Use absolute paths for symlink to ensure correct resolution |
| 37 | + Deno.symlinkSync(resolve(testDir), resolve(symlinkDir)); |
| 38 | + }, |
| 39 | + teardown: async () => { |
| 40 | + const htmlViaSymlink = join(symlinkDir, "test.html"); |
| 41 | + if (existsSync(htmlViaSymlink)) { |
| 42 | + await Deno.remove(htmlViaSymlink); |
| 43 | + } |
| 44 | + if (existsSync(symlinkDir)) { |
| 45 | + await Deno.remove(symlinkDir); |
| 46 | + } |
| 47 | + const realHtml = join(testDir, "test.html"); |
| 48 | + if (existsSync(realHtml)) { |
| 49 | + await Deno.remove(realHtml); |
| 50 | + } |
| 51 | + }, |
| 52 | + }, |
| 53 | + "Render via symlink with embed-resources (issue #13890)", |
| 54 | +); |
0 commit comments