Skip to content

Batched test runner cannot run on macOS, and one-process runs give batch-size-dependent failure counts #5439

Closed

Description

@wlilley93

Client or integration

Other / not listed

Area

Testing and CI

Summary

Two separate problems, one causing the other to go unnoticed.

1. scripts/ci/run-bun-test-batches.sh cannot run on macOS. It requires GNU
timeout (macOS ships none) and mapfile (a bash 4 builtin; macOS ships bash
3.2). Both fail before a single test executes — exit 69 with one line, or
line 174: mapfile: command not found. A macOS contributor cannot run the
batched runner at all, so the only available option is bun run test, which is
the method .github/workflows/ci.yml:309 explains is not safe.

2. Running the suite in one process gives a failure count that is a function
of batch size, not of the code.
Same branch, same 1438 files, same commit:

method failures
bun run test (one process) 9, then wedged at 627 of 1435 files
one process per tests/<domain> 468
batches of 12 73
batches of 8 53

The 20 failures unique to batch-12 all pass in isolation
(codex-shim-autorestore 9/9, images/loop 52/52,
service-tier-capability 36/36). The proximate causes are cross-test global
state: tests/server/config.test.ts calls process.chdir; five files under
tests/server/ assign process.env.OPENCODEX_HOME without restoring it, which
trips the real-home guard (refusing to write the real OpenCodex home … from a test process); and the spend ledger is single-owner, producing 61
SpendLedgerOwnerErrors in one process.

CI already works around this with 12-file batches and a one-file-per-process
sweep. The request is to make that workaround runnable off Linux, and ideally
to fix the leaks so the count stops depending on the slicing.

Reproduction

  1. On macOS with no coreutils: bash scripts/ci/run-bun-test-batches.sh 1/4
    → GNU timeout is required to bound Bun test batches., exit 69.
  2. With GNU timeout present but system bash:
    → scripts/ci/run-bun-test-batches.sh: line 174: mapfile: command not found.
  3. bun test tests/server in one process → 354 failures. Then
    bun test tests/server/cancel-body-on-abort.test.ts alone → 13 pass, 0 fail.

Version

2.61.0 (fork of dev at 1687636)

Operating system

macOS 26.2, arm64 (M4 Pro), bash 3.2.57, Bun 1.4.1

Provider and model

Not provider-specific — test harness only.

Logs or error output

GNU timeout is required to bound Bun test batches.
scripts/ci/run-bun-test-batches.sh: line 174: mapfile: command not found
error: refusing to write the real OpenCodex home (/Users/<user>/.opencodex) from a test process.
  Point OPENCODEX_HOME at a temp directory for this test, or inject persistence instead of
  calling the global writer

Screenshots and supporting files

None.

Redacted configuration

Not configuration-dependent; reproduced on a clean checkout of dev.

Checks

  • I searched existing issues before opening this one
  • I can reproduce this on the latest version

Activity

  1. added
    bugSomething isn't working
    platformOS/service/tray/ACL (Windows-heavy, not Windows-only)
    on Sep 21, 2026
  2. FredAmartey commented on Sep 22, 2026

    @FredAmartey
    Contributor

    Findings for the three files this issue lists as failing only in batches, run on current dev with Bun 1.4.0 and, for the last one, at 168763619 with Bun 1.4.1 as reported:

    One thing that explains why the counts move with the slicing: Bun runs a directory's files in the order the filesystem lists them, not in the order they are passed, so the z- prefix on z-fulfill and z-handler-activation does not make them run last. #5482 fixes one more failure from the same family, a resolver mock that recursed into another file's mock.

  3. lidge-jun commented on Sep 24, 2026

    @lidge-jun
    Owner

    Fixed on dev. #5456 made scripts/ci/run-bun-test-batches.sh run on stock macOS (bash 3.2, no GNU timeout), #5672 carried the first set of cross-test state leaks, and bundle #5740 (squash-merged as e535c65) fixed eleven more files that left state for later files in the same Bun process. Measured one-process runs on macOS after #5740: tests/server 3008 pass / 0 fail (357 failures on dev before), tests/images 220 / 0 (8 before). Please reopen with the counts if a batch size still changes the result.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplatformOS/service/tray/ACL (Windows-heavy, not Windows-only)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions