Repository navigation
Fix two integration tests that time out when npm test runs in a terminal - #680
Conversation
…rminal When `node --test` writes to a terminal it sets FORCE_COLOR for each test file, and the grandchild these tests spawn inherits it. console.log then colours the pid it prints, so kill-tree's match never succeeds and the test times out after 60 seconds, and orphan-pipe reads NaN and reports that the orphan never sent its pid. CI has no terminal, so only a local `npm test` failed. Writing the pid as a string leaves it uncoloured either way.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
## Why 41 commits have reached trunk since `v1.2.1`, and milestone `v2.0.0-beta.1` has 77 closed issues and none open. The main changes are the redesign on the WordPress Design System (#591), a settings dialog with language, theme, PHP version and debug flags (#638 to #651), and translation of the whole interface (#634 to #664). This is a beta: it ships with `--prerelease`, so `releases/latest` stays on `v1.2.1`. `electron-builder` names the artifacts after `package.json`, so the version has to move before the tag and artifacts exist. ## What changes - **The version.** The three root version fields in `package.json` and `package-lock.json` move from `1.2.1` to `2.0.0-beta.1`. No dependency versions change. - **The first shipped translations.** `npm run i18n:download` added a catalog for each of the seven locales at 80% or more on translate.wordpress.org. None was removed, and no right-to-left locale was held back. | Locale | Translated | Strings | | --- | --- | --- | | cs | 94% | 1001 | | en-ca | 100% | 1062 | | en-gb | 100% | 1062 | | gl | 100% | 1062 | | hu | 100% | 1062 | | nl | 100% | 1062 | | pl | 96% | 1028 | ## How to test this **Platforms:** any for steps 1 to 3. The artifact checks need macOS for `Info.plist` and Windows for the `.exe`. **Starting state:** this branch checked out with `node_modules` installed. Run every command from the repository root. 1. `npm run lint` is clean and `npm test` passes. 2. `node -e "console.log(require('./package.json').version)"` prints `2.0.0-beta.1`. 3. `python3 -c "import json;d=json.load(open('package-lock.json'));print(d['version'], d['packages']['']['version'])"` prints `2.0.0-beta.1 2.0.0-beta.1`. 4. On the Buildkite build for the current head, the artifacts are named `wordpress-contributor-toolkit-2.0.0-beta.1-*`. The `app.asar` root holds exactly `node_modules`, `package.json` and `src`, with npm 11 under `node_modules/npm` and no `.codesigning`. On macOS, `CFBundleShortVersionString` reads `2.0.0-beta.1`. 5. In the installed app, set the language to Dutch in the settings and relaunch. The interface is in Dutch. **What must not have happened:** no dependency version may change. `git diff trunk -- . ':!src/languages'` shows exactly three changed lines, all of them the root version. ## Risks and limitations `npm test` run from an interactive terminal fails two integration tests on macOS. That is a test bug, fixed separately in #680. It does not affect CI or the app. ## Related Milestone `v2.0.0-beta.1`. Release notes follow on the release. --- <details> <summary>Review outcome (required — see AGENTS.md)</summary> 0 [fix here] · 0 [follow-up]. Automatic checks only, as in #533: this change has no logic to review. - **Review:** completed, deterministic layer, in session; head `9853082` / base `5d5f701` (trunk). `npm run lint` passes, `npm test` passes (2098 tests, 0 failures, 2 skipped), both files are valid JSON, and the diff outside `src/languages/` is the three root version fields. Outcome: nothing to fix. - **Since review:** none. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
@coderabbitai review |
✅ Action performedReview finished.
|
Why
Running
npm testfrom an interactive terminal fails two integration tests on macOS.kill-tree.integration.test.cjstimes out after 60 seconds andorphan-pipe.integration.test.cjsreports "the orphan never reported its pid". CI has no terminal, so it stays green and only local runs fail.What changes
When
node --testwrites to a terminal, it setsFORCE_COLORfor each test file. Thenodegrandchild each test spawns inherits it, soconsole.log(process.pid)prints the pid in ANSI colour codes (\x1b[33m51099\x1b[39m). kill-tree's/^(\d+)/mnever matches, and orphan-pipe'sNumber()returnsNaN.The grandchild now writes the pid with
process.stdout.write(process.pid + "\n"). A string is never coloured, so the output is the same with or without a terminal.electron-node-compat.test.cjsalready does this. Only the two test files change.How to test this
Platforms: macOS (or Linux). Both tests are POSIX only and Windows skips them.
Starting state: a checkout with
node_modulesinstalled and the Node version from.nvmrc. Run every command from the repository root.trunk, runnpm testin an interactive terminal. Both tests fail, kill-tree after 60 seconds.trunk, runFORCE_COLOR=1 npm test > out.txt 2>&1(no terminal). The same two tests fail. That showsFORCE_COLORalone is the trigger.What must not have happened: the tests must still check what they did before. kill-tree should still need the forced group signal to end the grandchild, and orphan-pipe should still see
exitwithoutclosewhile the orphan holds the pipes. Both assertions are unchanged.Risks and limitations
None known. This is a test-only change. The self-review found nothing to fix.
Related
Bug introduced with the tests themselves, in #479 (kill-tree) and #513 (orphan-pipe).
Design decisions and alternatives considered
FORCE_COLORfrom the spawn'senv. Rejected: it fixes the variable we know about, butconsole.logoutput can still change with other settings. A plain string can't.Review outcome (required — see AGENTS.md)
0 [fix here] · 0 [follow-up]
.github/instructions/code-review.instructions.md, judgement pass by a fresh-context agent; reviewed head9ae7ac8/ base5d5f701(trunk).npm run lintpasses.npm testpasses (2098 tests, 0 failures) without a terminal, under a pseudo-terminal, withFORCE_COLOR=1, and on Electron's bundled Node vianpm run test:electron. Outcome: no findings.The reviewer suggested a rule for the instructions file: a child process whose output a test parses should write it with
process.stdout.writeand a string, notconsole.log. Left out of this PR to keep it to the fix.Screenshots or recording
Nothing on screen changes.
🤖 Generated with Claude Code