Skip to content

Add per-test hard timeout configuration#768

Merged
MatthewMckee4 merged 1 commit into
mainfrom
matt/timeout-config
May 6, 2026
Merged

Add per-test hard timeout configuration#768
MatthewMckee4 merged 1 commit into
mainfrom
matt/timeout-config

Conversation

@MatthewMckee4
Copy link
Copy Markdown
Owner

Summary

Adds a timeout setting under [test] and a matching --timeout=SECONDS CLI flag that applies a hard per-test limit to every test in the run. Tests exceeding the limit are killed and reported as failures, reusing the same machinery as @karva.tags.timeout (sync tests run inside a ThreadPoolExecutor; async tests are wrapped in asyncio.wait_for). A test-level decorator still wins when both are set, so individual tests can opt into a longer or shorter window.

[tool.karva.profile.default.test]
timeout = 120.0
karva test --timeout=120

Closes #557. The issue also sketched per-filter overrides via [[profile.default.overrides]]; that is left for a follow-up since karva does not yet have an overrides mechanism.

Test Plan

ci

Adds a `timeout` setting under `[test]` and a matching `--timeout=SECONDS` CLI flag that applies a hard per-test limit to every test in the run. Tests exceeding the limit are killed and reported as failures, mirroring the existing `@karva.tags.timeout` decorator. The decorator still wins when both are set, so individual tests can opt into a longer or shorter window.

Closes #557
@MatthewMckee4 MatthewMckee4 added cli Related to the command-line interface extensions/tags Related to Karva tags or pytest marks configuration Related to configuring Karva labels May 6, 2026
@MatthewMckee4 MatthewMckee4 merged commit 0ff8c68 into main May 6, 2026
12 checks passed
@MatthewMckee4 MatthewMckee4 deleted the matt/timeout-config branch May 6, 2026 07:08
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 6, 2026

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 1 untouched benchmark


Comparing matt/timeout-config (d97f3df) with main (56b23da)

Open in CodSpeed

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

Labels

cli Related to the command-line interface configuration Related to configuring Karva extensions/tags Related to Karva tags or pytest marks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Per-test hard timeouts

1 participant