diff --git a/test/runner.node.mjs b/test/runner.node.mjs index 56bb3e0869..e39c1a0bf7 100755 --- a/test/runner.node.mjs +++ b/test/runner.node.mjs @@ -11,6 +11,7 @@ import { appendFileSync, readdirSync, rmSync, + writeFileSync, } from "node:fs"; import { spawn, spawnSync } from "node:child_process"; import { tmpdir, hostname, userInfo, homedir } from "node:os"; @@ -106,8 +107,14 @@ async function runTests(target, filters) { if (isBuildKite) { const { ok, testPath, error, stdout, stdoutPreview } = result; + const logsPath = join(cwd, "logs"); - mkdirSync(logsPath, { recursive: true }); + const logFilePath = join(logsPath, `${testPath}.log`); + mkdirSync(dirname(logFilePath), { recursive: true }); + writeFileSync(logFilePath, stripAnsi(stdout)); + if (!ok) { + uploadArtifactsToBuildKite(logFilePath); + } const statusFilePath = join(logsPath, ok ? "PASSED.txt" : "FAILED.txt"); appendFileSync(statusFilePath, `${testPath}\n`); @@ -115,12 +122,6 @@ async function runTests(target, filters) { uploadArtifactsToBuildKite(statusFilePath); } - const logFilePath = join(logsPath, `${testPath}.log`); - appendFileSync(logFilePath, stripAnsi(stdout)); - if (!ok) { - uploadArtifactsToBuildKite(logFilePath); - } - const markdown = formatTestToMarkdown(result); if (markdown) { reportAnnotationToBuildKite(title, markdown);