From 3c3ef05779685474887bc153a6fdecc16434029f Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Mon, 7 Sep 2026 23:13:45 -0400 Subject: [PATCH] test(codex-operations): normalize collector stdout newlines on Windows `collector orders tied skill mentions deterministically` compared a whole output line for equality after splitting stdout on `\n`. The collector is a Python script and Python's text-mode stdout writes the platform newline, so on Windows each line arrives as `\r\n` and the split leaves a trailing `\r` on the compared line. The suite's other assertions use `.includes()`, which the `\r` does not disturb, so this was the only case that went red. The collector's platform-native line endings are correct for a CLI, so the defect is the test. `runCollector` now folds `\r\n` to `\n` in `stdout` and `stderr` once, for every case, instead of each assertion guarding for itself. Co-Authored-By: Claude Fable 5.1 --- tests/codex-operations.test.mjs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/codex-operations.test.mjs b/tests/codex-operations.test.mjs index cc1bc90..3562717 100644 --- a/tests/codex-operations.test.mjs +++ b/tests/codex-operations.test.mjs @@ -37,14 +37,23 @@ function findPython() { const python = findPython(); const skip = python ? false : "Python 3 is not available"; +const toLf = (text) => (typeof text === "string" ? text.replaceAll("\r\n", "\n") : text); + function runCollector(args, env) { if (!python) { throw new Error("runCollector needs Python; give this test the shared { skip } guard"); } - return spawnSync(python.command, [...python.prefix, collector, ...args], { + const result = spawnSync(python.command, [...python.prefix, collector, ...args], { encoding: "utf8", env, }); + // Python's text-mode stdout writes the platform newline, so on Windows every + // line the collector prints arrives as `\r\n`. That is correct for the tool + // and invisible to a `.includes()` assertion, but a test that splits on `\n` + // and compares a whole line for equality reads the trailing `\r` as a content + // difference. Normalize once here so every assertion below sees the same text + // on every platform; the collector itself is unchanged. + return { ...result, stdout: toLf(result.stdout), stderr: toLf(result.stderr) }; } async function makeTempDir(t, prefix) {