ECC/tests/lib
Jamkris d904edc615 test(lib): make concurrent-write test actually concurrent + use regex matcher for assert.throws
Two round-1 review findings in `tests/lib/session-bridge.test.js`,
both about test correctness rather than the underlying fix:

1. **greptile P1 + coderabbitai Major + cubic P2 (all three): concurrent-write test ran sequentially.**

   The test spawned two child processes with two consecutive
   `spawnSync` calls. Because `spawnSync` blocks until the child
   exits, the second writer started *after* the first finished —
   the two writers never overlapped, so the rename race the fix
   targets was never actually exercised. The test would have passed
   with the old broken `${target}.tmp` suffix.

   Fix: introduce a one-off "race runner" helper that runs inside
   its own subprocess and uses async `spawn` to start both writers
   simultaneously. The runner waits for both to exit (the event
   loop is local to the runner subprocess, so this stays compatible
   with the synchronous test harness used elsewhere in this file)
   and reports both exit codes plus stderrs on stdout. The test
   then calls the runner via `spawnSync` and parses the result.
   Both writer children now overlap for the duration of their 200
   `writeBridgeAtomic` calls each, which is enough wall time to
   reliably trigger the rename race against the pre-fix code.

   Verified: with the fixed `${target}.${pid}.${nonce}.tmp` suffix,
   the test passes; with the old fixed `${target}.tmp` suffix
   reintroduced, it fails as expected (one writer hits ENOENT on
   roughly half its rename calls).

2. **greptile P2 + cubic P3: `assert.throws` used a string as the second argument.**

   Node deprecated passing a string as the second argument to
   `assert.throws` years ago: the string is silently treated as
   the assertion failure message (what to print when the function
   does *not* throw) rather than as an error matcher. The check
   passed for any thrown error, not just the rename failure.

   Fix: pass a regex matcher as the second arg and keep the
   explanatory text as the third. The regex matches `EISDIR`,
   `EPERM`, `ENOTDIR`, or `ENOENT` because `renameSync` of a
   regular tmp file onto an existing directory raises different
   codes on Linux / macOS / BSD — making the matcher portable
   across CI runners.

Test count unchanged at 14; `npm test` green; `npm run lint` clean.

The two helper files (`tests/__tmp_bridge_writer.js`,
`tests/__tmp_bridge_race_runner.js`) are written and unlinked
inside the test's try/finally so they never persist beyond the
test run.
2026-05-19 04:57:10 -04:00
..
agent-compress.test.js feat: agent description compression with lazy loading (#696) 2026-03-20 03:53:22 -07:00
changed-files-store.test.js fix: port safe ci cleanup from backlog 2026-04-01 16:09:54 -07:00
command-plugin-root.test.js fix: salvage remaining stale queue fixes (#1754) 2026-05-11 16:41:08 -04:00
cost-estimate.test.js feat: add ECC statusline observability hooks 2026-05-11 23:44:06 -04:00
inspection.test.js feat: agent compression, inspection logic, governance hooks (#491, #485, #482) (#688) 2026-03-20 01:38:13 -07:00
install-config.test.js feat: add install catalog and project config autodetection 2026-03-27 05:56:39 -04:00
install-executor.test.js feat: add Ruby and Rails rules 2026-05-13 06:27:08 -04:00
install-lifecycle.test.js test: cover install lifecycle edge paths 2026-04-29 17:56:25 -04:00
install-manifests.test.js feat: add zed install target 2026-05-17 07:06:49 -04:00
install-request.test.js fix(installer): harden locale docs install 2026-05-17 20:46:04 -04:00
install-state.test.js fix: harden release surface version and packaging sync (#1388) 2026-04-12 22:33:32 -07:00
install-targets.test.js feat: add zed install target 2026-05-17 07:06:49 -04:00
locale-install.test.js fix(installer): harden locale docs install 2026-05-17 20:46:04 -04:00
mcp-config.test.js feat: support disabling bundled mcp servers 2026-04-05 14:37:28 -07:00
observer-sessions.test.js fix: port continuous-learning observer fixes 2026-05-11 03:35:42 -04:00
orchestration-session.test.js fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
package-manager.test.js fix: harden Trae install ownership (#1013) 2026-03-30 02:01:54 -04:00
project-detect.test.js docs: salvage F# agent and language guidance 2026-05-11 21:43:17 -04:00
resolve-ecc-root.test.js fix: salvage remaining stale queue fixes (#1754) 2026-05-11 16:41:08 -04:00
resolve-formatter.test.js fix: harden Trae install ownership (#1013) 2026-03-30 02:01:54 -04:00
selective-install.test.js test: normalize zed install path assertion 2026-05-17 07:27:05 -04:00
session-adapters.test.js test: cover session adapter edge cases 2026-04-29 18:21:31 -04:00
session-aliases.test.js fix: narrow unicode cleanup scope 2026-03-29 21:21:18 -04:00
session-bridge.test.js test(lib): make concurrent-write test actually concurrent + use regex matcher for assert.throws 2026-05-19 04:57:10 -04:00
session-manager.test.js test: cover canonical session duplicate precedence 2026-03-25 04:01:23 -04:00
shell-split.test.js fix(hooks): allow tmux-wrapped dev server commands (#321) 2026-03-07 14:47:49 -08:00
skill-dashboard.test.js test: cover skill dashboard edge paths 2026-04-29 19:15:47 -04:00
skill-evolution.test.js test: cover skill tracker edge paths 2026-04-29 19:21:03 -04:00
skill-improvement.test.js feat: self-improving skills loop — observe, inspect, amend, evaluate 2026-03-14 23:21:18 -07:00
state-store.test.js feat: sync GitHub queue into work items 2026-05-11 13:07:29 -04:00
tmux-worktree-orchestrator.test.js fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
utils.test.js fix: respect home overrides in hook utilities 2026-04-02 18:22:07 -07:00