Skip to content

Commit e119044

Browse files
committed
Add R package-availability probe to #14683 CI investigation
Probes whether Rscript can load rmarkdown/knitr from callR's actual spawn cwd (the project dir) before the real render runs, so a CI-only failure shows package/environment state instead of just "no HTML". Uses a script file rather than inline -e code: an -e argument with embedded quotes gets mis-tokenized by cmd.exe when Rscript resolves to a .bat shim (e.g. rig-managed R installs) — the same reason callR always passes a script file, never inline -e.
1 parent 9e37e02 commit e119044

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎tests/unit/preview-subdir-knitr-cwd.test.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { assert } from "testing/asserts";
3232
import { dirname, isAbsolute, join } from "../../src/deno_ral/path.ts";
3333
import { existsSync } from "../../src/deno_ral/fs.ts";
3434
import { which } from "../../src/core/path.ts";
35+
import { rBinaryPath } from "../../src/core/resources.ts";
3536
import { projectContext } from "../../src/project/project-context.ts";
3637
import { singleFileProjectContext } from "../../src/project/types/single-file/single-file.ts";
3738
import { notebookContext } from "../../src/render/notebook/notebook-context.ts";
@@ -66,6 +67,36 @@ unitTest(
6667
(await singleFileProjectContext(file, nbContext));
6768

6869
try {
70+
// Temporary diagnostic (#14683 CI investigation): prove whether R can
71+
// load rmarkdown/knitr from callR's actual spawn cwd (the project dir)
72+
// on CI before blaming the render pipeline for the missing output.
73+
{
74+
// Pass a script file (not inline -e code) — an -e argument containing
75+
// double quotes gets re-tokenized by cmd.exe when Rscript resolves to
76+
// a .bat shim (e.g. rig-managed installs), corrupting the call.
77+
// Production callR never uses -e for the same reason (rmd.R is a file).
78+
const rscript = await rBinaryPath("Rscript");
79+
const probeScript = join(e2eBase, "probe.R");
80+
Deno.writeTextFileSync(
81+
probeScript,
82+
'cat("LIBPATHS:", paste(.libPaths(), collapse="|"), "\\n")\n' +
83+
"library(rmarkdown)\nlibrary(knitr)\ncat(\"PKG_OK\\n\")\n",
84+
);
85+
const probe = new Deno.Command(rscript, {
86+
args: [probeScript],
87+
cwd: e2eProjDir,
88+
stdout: "piped",
89+
stderr: "piped",
90+
});
91+
const probeResult = await probe.output();
92+
assert(
93+
probeResult.success,
94+
`R probe failed (code ${probeResult.code}) rscript=${rscript} in cwd=${e2eProjDir}\n` +
95+
`STDOUT:\n${new TextDecoder().decode(probeResult.stdout)}\n` +
96+
`STDERR:\n${new TextDecoder().decode(probeResult.stderr)}`,
97+
);
98+
}
99+
69100
// Mimic preview cmd.ts: resolve the preview format first, using the
70101
// bare filename. This seeds the shared context's fileInformationCache.
71102
const services = renderServices(nbContext);

0 commit comments

Comments
 (0)