Skip to content

W-23517830: Add isolated-process test for bad-library-path initialization in the DataWeave Node.js binding#134

Merged
mlischetti merged 1 commit into
masterfrom
W-23517830-isolated-badpath-init-test
Jul 21, 2026
Merged

W-23517830: Add isolated-process test for bad-library-path initialization in the DataWeave Node.js binding#134
mlischetti merged 1 commit into
masterfrom
W-23517830-isolated-badpath-init-test

Conversation

@mlischetti

Copy link
Copy Markdown
Contributor

What

A bad/nonexistent dwlib path makes initialize() throw a DataWeaveError only as the first native init in a process — the runtime is loaded process-globally / ref-counted, so once any good init has run, a later bad-path init is tolerated. That made it order-dependent (flaky) in the shared lane.

Approach

Run it in a dedicated child process, making it order- and vitest-pool-independent:

  • tests/integration/fixtures/bad-lib-init.cjs — child fixture that requires the built dist/ entry, asserts the DataWeaveError, and signals via stdout sentinel + exit code (no-throw / wrong-error / native crash all surface as a non-zero child exit).
  • tests/integration/init-bad-path.test.ts — spawns the fixture with execFileSync (throws on non-zero exit) and asserts the OK:DataWeaveError sentinel; guards on the built entry existing.
  • edge-cases.test.ts — NOTE updated to point at the new test.

Note: vitest's default forks pool already isolates per file, so a plain test file would pass today — but relying on that would reintroduce the exact hidden process-global coupling this test guards against. The spawned child is robust to pool/config changes.

Testing

  • tsc --noEmit clean
  • npm run test:unit70 passed
  • npm run test:integration35 passed, deterministic across repeated runs

🤖 Generated with Claude Code

Cover the bad-library-path initialize() case that could not be asserted in
the shared integration lane. A bad/nonexistent dwlib path makes
initialize() throw a DataWeaveError only as the FIRST native init in a
process (the runtime is loaded process-globally / ref-counted), so this
runs in a dedicated child process — order- and vitest-pool-independent.

- tests/integration/fixtures/bad-lib-init.cjs: child fixture that requires
  the built dist/ entry, asserts the DataWeaveError, and signals via
  stdout sentinel + exit code (a no-throw / wrong-error / native crash all
  surface as a non-zero child exit).
- tests/integration/init-bad-path.test.ts: spawns the fixture with
  execFileSync (throws on non-zero exit) and asserts the OK sentinel;
  guards on the built entry existing with a clear message.
- edge-cases.test.ts: update the NOTE to point at the new test instead of
  describing it as an open follow-up.

Verified: tsc clean, 70 unit tests pass, 35 integration tests pass
(deterministic across repeated runs) against the real native library.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mlischetti
mlischetti requested a review from a team as a code owner July 21, 2026 16:02
@mlischetti
mlischetti merged commit 33ba19c into master Jul 21, 2026
4 checks passed
@mlischetti
mlischetti deleted the W-23517830-isolated-badpath-init-test branch July 21, 2026 17:11
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.

2 participants