Skip to content

Commit ed683a3

Browse files
claude: Add --keep-outputs flag to test scripts
Add a flag to preserve test output artifacts (PDF, typ, tex, etc.) instead of deleting them after tests run. Usage: ./run-fast-tests.sh --keep-outputs docs/smoke-all/test.qmd ./run-fast-tests.sh -k docs/smoke-all/test.qmd Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 654336d commit ed683a3

4 files changed

Lines changed: 31 additions & 3 deletions

File tree

‎tests/run-tests.sh‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,26 @@ if [[ "$RUNNER_DEBUG" == "1" ]] || [[ "$QUARTO_TEST_VERBOSE" == "true" ]]; then
1515
VERBOSE_MODE=true
1616
fi
1717

18+
# Check if keep-outputs mode is enabled
19+
KEEP_OUTPUTS=false
20+
FILTERED_ARGS=()
21+
for arg in "$@"; do
22+
case $arg in
23+
--keep-outputs|-k)
24+
KEEP_OUTPUTS=true
25+
;;
26+
*)
27+
FILTERED_ARGS+=("$arg")
28+
;;
29+
esac
30+
done
31+
set -- "${FILTERED_ARGS[@]}"
32+
33+
if [[ "$KEEP_OUTPUTS" == "true" ]]; then
34+
export QUARTO_TEST_KEEP_OUTPUTS=true
35+
echo "> Keep outputs mode enabled - test artifacts will not be deleted"
36+
fi
37+
1838
source $SCRIPT_PATH/../package/scripts/common/utils.sh
1939

2040
export QUARTO_ROOT="$(cd "$SCRIPT_PATH/.." > /dev/null 2>&1 && pwd)"

‎tests/smoke/render/render.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,16 @@ export function testRender(
8383
}
8484

8585
export function cleanoutput(
86-
input: string,
87-
to: string,
86+
input: string,
87+
to: string,
8888
projectOutDir?: string,
8989
projectRoot?: string,
9090
// deno-lint-ignore no-explicit-any
9191
metadata?: Record<string, any>,
9292
) {
93+
if (Deno.env.get("QUARTO_TEST_KEEP_OUTPUTS")) {
94+
return;
95+
}
9396
const out = outputForInput(input, to, projectOutDir, projectRoot, metadata);
9497
if (safeExistsSync(out.outputPath)) {
9598
safeRemoveSync(out.outputPath);

‎tests/smoke/smoke-all.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ function registerPostRenderCleanupFile(file: string): void {
155155
postRenderCleanupFiles.push(file);
156156
}
157157
const postRenderCleanup = () => {
158+
if (Deno.env.get("QUARTO_TEST_KEEP_OUTPUTS")) {
159+
return;
160+
}
158161
for (const file of postRenderCleanupFiles) {
159162
console.log(`Cleaning up ${file} in ${Deno.cwd()}`);
160163
if (safeExistsSync(file)) {

‎tests/verify.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,9 @@ export const verifyKeepFileRegexMatches = (
600600
try {
601601
await regexChecker(file, matches, noMatches);
602602
} finally {
603-
await safeRemoveSync(file);
603+
if (!Deno.env.get("QUARTO_TEST_KEEP_OUTPUTS")) {
604+
await safeRemoveSync(file);
605+
}
604606
}
605607
}
606608
return verifyFileRegexMatches(keptFileChecker, `Inspecting intermediate ${keptFile} for Regex matches`)(keptFile, matchesUntyped, noMatchesUntyped);

0 commit comments

Comments
 (0)