Skip to content

CLI tests: parallel test files rebuild dist-client while others run it #192

Closed

Description

@FredApps

What went wrong?

Something else: the CLI package's test suite fails intermittently because test files rebuild dist-client while other test files are running it.

DiffCI version

main at 40aa308 (CLI 0.3.54)

Command you ran

npm test in packages/diffci-cli

Environment

Ubuntu, Node.js 24.22.1, npm 11, terminal.

What happens

scripts/run-tests.mjs runs every test file with one node --test call, so the files run in parallel processes. Four of them compile the client into the same directory before they start:

  • tests/client/check-plan-cli.test.ts (before)
  • tests/client/plan-cli.test.ts (before)
  • tests/client/mcp.test.ts (before)
  • tests/client/cli-help.test.ts (inside the test)

Each runs tsc -p tsconfig.client.json, which rewrites every file in dist-client/. When one file's build overlaps with another file's run of dist-client/src/client/cli.js, that CLI loads a half-written module and exits with a syntax error. A full run on main failed this way:

✖ reports all three failure groups and exits nonzero for misses or unattributed failures
  AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
  + 'file:///.../packages/diffci-cli/dist-client/src/preflight/fingerprint.js:58\n' +
  +   '        normalizeErrorText(input.errorText).slice(0, 200), // bounded - a fingerprint is an \n' +
  +   'SyntaxError: Unexpected end of input\n' +

The next run of the same commit passed that test, so the failure depends on timing.

What you expected

dist-client is compiled at most once for a given source state during a test run, and no test rewrites it while another test is executing it.

Regression test

The linked pull request moves the build into one shared helper (tests/helpers/build-client.ts) that takes a lock and skips the build when dist-client is newer than every source file. tests/client/build-client.test.ts fails on main (it lists the four files above that still compile dist-client themselves) and passes with the fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions