Skip to content

fixes #26716; findNodeJs returns "" when NodeJS is missing - #26879

Open
konaito wants to merge 1 commit into
nim-lang:develfrom
konaito:fix-26716-testament-nodejs
Open

konaito wants to merge 1 commit into
nim-lang:develfrom
konaito:fix-26716-testament-nodejs

Conversation

@konaito

@konaito konaito commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

fixes #26716

testament/testament.nim and compiler/docgen.nim check findNodeJs() == "" and handle a missing NodeJS there (testament fails the JS test with "nodejs binary not in PATH", docgen skips JS runnableExamples). But since #18978 findNodeJs raises IOError instead of returning "", so those branches never run: testament stops at the first JS test of the category and leaves testresults/<category>.json unclosed, and nim doc --backend:js on a file with runnableExamples crashes.

Fix: findNodeJs returns "" when NodeJS is not found, as before #18978. nim js -r, the only caller that relied on the exception, now reports the missing NodeJS itself with rawMessage(errGenerated). The alternative was to catch the exception in testament, but that would leave the same crash in docgen.

Verification, on macOS arm64, with NodeJS removed from PATH (env -i PATH=<nim bin>:/usr/bin:/bin:/usr/sbin:/sbin):

  • testament cat let: before, it stopped at tests/let/timportc.nim js with Error: unhandled exception: NodeJS not found in PATH [IOError], and 3 of the 7 tests ran. After, all 7 run, timportc.nim js fails with nodejs binary not in PATH (reExeNotFound), and let.json is valid JSON.
  • nim js -r a.nim: Error: NodeJS not found in PATH; please install it first, see https://nodejs.org/en/download, exit code 1, no stack trace.
  • nim doc --backend:js on a file with a runnableExample: before, the IOError crash; after, exit code 0 and the HTML is written.

With NodeJS in PATH, testament cat let passes all 7 (including the JS test), and nim js -r and nim doc --backend:js run the code with node as before.

testament and docgen already check `findNodeJs() == ""`, but findNodeJs raised IOError, so a missing NodeJS stopped the whole testament category. `nim js -r` now reports the missing NodeJS itself.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

testament: a missing Node.js stops the whole category instead of failing the JS tests

1 participant