Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/command/render/freeze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ export function freezeExecuteResult(
result: ExecuteResult,
) {
// resolve includes within executeResult
// nb: Beware to not modify the original result object
const innerResult = {
...result,
includes: result.includes ? { ...result.includes } : undefined,
} as ExecuteResult;
const resolveIncludes = (
name: "include-in-header" | "include-before-body" | "include-after-body",
Expand Down
4 changes: 2 additions & 2 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Python Environments
.env
.venv
env/
venv/
/env/
/venv/
ENV/
env.bak/
venv.bak/
Expand Down
4 changes: 2 additions & 2 deletions tests/docs/smoke-all/2024/06/19/9208.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ _quarto:
html:
noErrors: true
printsMessage:
- WARN
- 'code-link.*ignored'
level: WARN
regex: 'code-link.*ignored'
ensureHtmlElements:
- []
- ['pre.downlit']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ _quarto:
pdf:
noErrors: true
printsMessage:
- WARN
- 'missing hyphenation.*hyphen-spanish'
level: WARN
regex: 'missing hyphenation.*hyphen-spanish'
---

```{r}
Expand Down
4 changes: 2 additions & 2 deletions tests/docs/smoke-all/2024/09/30/10931-2.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ _quarto:
tests:
pptx:
printsMessage:
- INFO
- 'WARNING.*FloatRefTargets require'
level: INFO
regex: 'WARNING.*FloatRefTargets require'
ensurePptxXpath:
-
- 2
Expand Down
1 change: 1 addition & 0 deletions tests/docs/smoke-all/2025/03/05/12204/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.quarto/
2 changes: 2 additions & 0 deletions tests/docs/smoke-all/2025/03/05/12204/_quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project:
type: default
15 changes: 15 additions & 0 deletions tests/docs/smoke-all/2025/03/05/12204/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
format: html
engine: julia
_quarto:
tests:
html:
printsMessage:
level: INFO
regex: 'FATAL[\s\S]*Error resolving header-includes'
negate: true
---

```{julia}
?for
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ _quarto:
- ['[\s\S]+\\begin\{table\}\[htbp\][\s\S]+', '[\s\S]+\\caption\{\\label\{mod\}']
- []
printsMessage:
- INFO
- 'WARNING(.*)Raw LaTeX table found with non-tbl label:'
level: INFO
regex: 'WARNING(.*)Raw LaTeX table found with non-tbl label:'
---

This document has a raw LaTeX table with no intent to use quarto crossref. It uses a label with `tbl-` id.
Expand Down
2 changes: 1 addition & 1 deletion tests/smoke/env/check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ testQuartoCmd(
[],
[
noErrorsOrWarnings,
printsMessage("INFO", /Version: 99\.9\.9/),
printsMessage({level: "INFO", regex: /Version: 99\.9\.9/}),
],
);
4 changes: 2 additions & 2 deletions tests/smoke/env/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ testQuartoCmd(
["list"],
[
noErrorsOrWarnings,
printsMessage("INFO", /tinytex\s+/),
// printsMessage("INFO", /chromium\s+/),
printsMessage({level: "INFO", regex: /tinytex\s+/}),
// printsMessage({level: "INFO", regex: /chromium\s+/}),
// temporarily disabled until we get puppeteer back
],
);
4 changes: 2 additions & 2 deletions tests/smoke/jupyter/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test({
verify: [
folderExists(cacheFolder),
// this will check only for the second render that should be read from cache
printsMessage("INFO", /Notebook read from cache/)
printsMessage({ level: "INFO", regex: /Notebook read from cache/})
],
type: "smoke",
});
Expand Down Expand Up @@ -82,7 +82,7 @@ test({
verify: [
folderExists(cacheFolder2),
// this will check only for the second render that should be read from cache
printsMessage("INFO", /Notebook read from cache/)
printsMessage({level: "INFO", regex: /Notebook read from cache/})
],
type: "smoke",
});
4 changes: 2 additions & 2 deletions tests/smoke/project/project-prepost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ testQuartoCmd(



// Tests that if the pre-renderf script mutates the output directory
// Tests that if the pre-render script mutates the output directory
// we throw an error that complains about this.
const mutateRenderDir = docs("project/prepost/invalid-mutate");
const mutateRenderDirAbs = join(Deno.cwd(), mutateRenderDir);
Expand All @@ -45,7 +45,7 @@ const mutateRenderOutDir = join(mutateRenderDirAbs, "_site");
testQuartoCmd(
"render",
[mutateRenderDir],
[printsMessage("ERROR", /output-dir may not be mutated/gm)],
[printsMessage({level: "ERROR", regex: /output-dir may not be mutated/gm})],
{
teardown: async () => {
const mdClean = join(mutateRenderDirAbs, "_metadata.yml");
Expand Down
4 changes: 2 additions & 2 deletions tests/smoke/smoke-all.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function resolveTestSpecs(
verifyFns.push(verifyMap[key](outputFile.outputPath, ...value));
}
} else if (key === "printsMessage") {
verifyFns.push(verifyMap[key](...value));
verifyFns.push(verifyMap[key](value));
} else if (verifyMap[key]) {
// FIXME: We should find another way that having this requirement of keep-* in the metadata
if (key === "ensureTypstFileRegexMatches") {
Expand Down Expand Up @@ -325,7 +325,7 @@ Promise.all(testFilesPromises).then(() => {
for (const project of testedProjects) {
// Clean project output directory
const projectOutDir = join(project, findProjectOutputDir(project));
if (safeExistsSync(projectOutDir)) {
if (projectOutDir !== project && safeExistsSync(projectOutDir)) {
safeRemoveSync(projectOutDir, { recursive: true });
}
// Clean hidden .quarto directory
Expand Down
2 changes: 1 addition & 1 deletion tests/smoke/use/template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ensureDirSync(nonEmptyWorkingDir);
testQuartoCmd(
"use",
["template", "quarto-journals/jasa", "--no-prompt"],
[printsMessage("ERROR", /directory isn't empty/), directoryContainsOnlyAllowedPaths(nonEmptyWorkingDir, [nonEmptyFileName])],
[printsMessage({level: "ERROR", regex: /directory isn't empty/}), directoryContainsOnlyAllowedPaths(nonEmptyWorkingDir, [nonEmptyFileName])],
{
setup: () => {
Deno.writeTextFileSync(join(nonEmptyWorkingDir, nonEmptyFileName), "Just making a non-empty file!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const testYamlValidationFails = (file: string) => {
testQuartoCmd(
"render",
[yamlDocs(file, "html").input, "--to", "html", "--quiet"],
[printsMessage("ERROR", /Validation of YAML cell metadata failed/)],
[printsMessage({level: "ERROR", regex: /Validation of YAML cell metadata failed/})],
);
};

Expand Down
2 changes: 1 addition & 1 deletion tests/smoke/yaml/config-yaml-validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ const input = docs("yaml/bad-config-yaml/subfolder/bad-config-yaml.qmd");
testQuartoCmd(
"render",
[input],
[printsMessage("ERROR", /bad-config-yaml[\/\\]+_quarto[.]yml validation failed/)]
[printsMessage({level: "ERROR", regex: /bad-config-yaml[\/\\]+_quarto[.]yml validation failed/})]
);
24 changes: 15 additions & 9 deletions tests/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,26 @@ export const noErrorsOrWarnings: Verify = {
},
};

export const printsMessage = (
level: "DEBUG" | "INFO" | "WARN" | "ERROR",
regex: RegExp | string,
): Verify => {
export const printsMessage = (options: {
level: "DEBUG" | "INFO" | "WARN" | "ERROR";
regex: string | RegExp;
negate?: boolean;
}): Verify => {
const { level, regex: regexPattern, negate = false } = options; // Set default here
return {
name: `${level} matches ${String(regex)}`,
name: `${level} matches ${String(regexPattern)}`,
verify: (outputs: ExecuteOutput[]) => {
if (typeof regex === "string") {
regex = new RegExp(regex);
}
const regex = typeof regexPattern === "string"
? new RegExp(regexPattern)
: regexPattern;

const printedMessage = outputs.some((output) => {
return output.levelName === level && output.msg.match(regex);
});
assert(printedMessage, `Missing ${level} ${String(regex)}`);
assert(
negate ? !printedMessage : printedMessage,
`${negate ? "Found" : "Missing"} ${level} ${String(regex)}`
);
return Promise.resolve();
},
};
Expand Down
Loading