From caf1d1aaed2a060f273460163a8464056988fb2d Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Tue, 1 Dec 2026 17:40:57 +0000 Subject: [PATCH] Fix Windows CI with Node 26.14 Why: Since Node 26.14.0, the Windows CI job fails before any test runs: `npx mocha` looks for D:\a\rescript\mocha\bin\mocha.js, one directory above the checkout. Node 26.13.1 worked, and nothing else changed. The test scripts now resolve Mocha's CLI script from node_modules and run it with node, like other scripts. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Kbf3gH9cXWp3xtBmfRV3Du Signed-off-by: Christoph Knittel --- changes/mocha-without-npx.internal.md | 1 + lib_dev/process.js | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 changes/mocha-without-npx.internal.md diff --git a/changes/mocha-without-npx.internal.md b/changes/mocha-without-npx.internal.md new file mode 100644 index 00000000000..38874a07496 --- /dev/null +++ b/changes/mocha-without-npx.internal.md @@ -0,0 +1 @@ +- Run Mocha in the test scripts without npx, which failed on Windows with Node 26.14.0. diff --git a/lib_dev/process.js b/lib_dev/process.js index 380d144cc40..d050075389d 100644 --- a/lib_dev/process.js +++ b/lib_dev/process.js @@ -1,5 +1,6 @@ import * as child_process from "node:child_process"; import * as fs from "node:fs/promises"; +import { createRequire } from "node:module"; import * as path from "node:path"; import { bsc_exe, rescript_exe } from "#cli/bins"; @@ -15,6 +16,8 @@ import { bsc_exe, rescript_exe } from "#cli/bins"; * }} ExecResult */ +const mochaBin = createRequire(import.meta.url).resolve("mocha/bin/mocha.js"); + const signals = { SIGINT: 2, SIGQUIT: 3, @@ -126,9 +129,9 @@ export function setup(cwd = process.cwd()) { * @return {Promise} */ mocha(args = [], options = {}) { - // `yarn mocha` works, but format output differently - // No more efforts here since we're plannig to drop Mocha - return exec("npx", ["mocha", ...args], options); + // Run Mocha's CLI script with Node directly. On Windows, `npx mocha` + // failed with Node 26.14.0 to find the script it should run. + return exec("node", [mochaBin, ...args], options); }, /**