Skip to content

test: allow 20 seconds per test for slow CI machines - #340

Merged
mindsers merged 2 commits into
developfrom
bugfix/repository-hooks-test-timeout
Oct 29, 2026
Merged

mindsers merged 2 commits into
developfrom
bugfix/repository-hooks-test-timeout

Conversation

@mindsers

@mindsers mindsers commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Raises vitest's default test timeout from 5 to 20 seconds, so tests stop failing on slow CI runners for reasons that have nothing to do with the code.

Context. configfile is a CLI that deploys dotfiles from a git repository. Many of its tests are end-to-end: each creates a sandbox with a git repository standing in for the remote and clones of it, then runs the CLI a few times. The CLI runs inside the test process, but it runs git, and so do the tests to set things up: one test easily starts a dozen git processes.

What failed. On #339, a docs-only change, one macOS job failed: tests/repository-hooks.test.ts › "says after adopt when the sync brought changes the post_update script did not see" took 5323 ms, over vitest's 5000 ms default. Rerunning the job passed.

Why the config, not that test. In that run, the whole machine was slow: tests across the suite took about twice their usual time. In the last four green runs, the slowest test relying on the default timeout took about 2.8 s. In the failing run, several tests/adopt.test.ts tests took 3 to 4 s (up to 4.15 s), close behind the one that failed. Raising the timeout of that one test would only move the failure to the next.

The change.

  • vitest.config.ts: testTimeout: 20_000, with a comment saying why.
  • tests/e2e.test.ts: the "signals during scripts run" block drops its own { timeout: 20_000 }, which is now the default.
  • tests/e2e.test.ts, tests/lock.test.ts: the tests that start 8 or 16 processes at once keep their 30 seconds. Four of them did not say why; they now do, like the others ("Eight processes: allow for slow, busy CI machines.").
  • tests/helpers.ts: the doc comment of git() sat above gitSetting(), which has its own, so it documented nothing. It moves back above git(). Found during review; no behavior change.

Trade-off. A test that hangs now fails after 20 seconds instead of 5. It is still reported as a timeout; the suite takes about 30 seconds locally and 2 minutes on CI.

No change to configfile itself, so no CHANGELOG entry.

Other Informations

Review order: vitest.config.ts, then tests/e2e.test.ts and tests/lock.test.ts (comments and timeouts only), then tests/helpers.ts.

Checking the new default. From a clone, after pnpm install, a test that takes 6 seconds passes on this branch and times out on develop:

cat > tests/zz-timeout-probe.test.ts <<'EOF'
import { setTimeout as sleep } from 'node:timers/promises'
import { it } from 'vitest'
it('outlives the old default', async () => { await sleep(6000) })
EOF
pnpm vitest run tests/zz-timeout-probe.test.ts
rm tests/zz-timeout-probe.test.ts

Tested: pnpm lint, pnpm typecheck and pnpm test (811 tests) pass locally on macOS.

Most tests run git and the CLI several times. On a slow CI runner they
take about twice as long as usual, and one went over vitest's 5 second
default. Raise the default to 20 seconds instead of patching that test:
others were close behind it. The signal tests' own 20 second timeout is
now the default and goes away.
The timeout comment claimed most tests run the CLI and git, and gave a
measurement that will not stay true: many tests run git several times,
which is the reason. The 30 second tests that did not say why now do.
The doc comment of git() moves back above it, from above gitSetting().
@mindsers
mindsers merged commit c4f273b into develop Oct 29, 2026
11 checks passed
@mindsers
mindsers deleted the bugfix/repository-hooks-test-timeout branch October 29, 2026 01:30
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.

1 participant