Per-test settings¶
Nextest supports overriding some settings for subsets of tests, using the filterset and Rust cfg() syntaxes.
Overrides are set via the [[profile.<name>.overrides]] list.
Selecting tests¶
At least one of these fields must be specified:
filter- Filterset expression selecting tests this override applies to.
platform- Host and/or target platforms this override applies to. Either a string,
or a map with
hostandtargetkeys for cross-compiling. See Specifying platforms for more information.
Supported overrides¶
priority0.9.91- Priority for matching tests; higher values run sooner. A number from -100 to 100, inclusive. Default: 0.
retries- Retry policy for matching tests.
flaky-result0.9.131- Whether to treat matching flaky tests as passing or failing.
threads-required- Number of threads each matching test reserves from the pool.
test-group- Assigns matching tests to a test group.
slow-timeout- Time after which matching tests are considered slow, plus optional termination policy.
bench.slow-timeout0.9.117- Time after which matching benchmarks are considered slow, plus optional termination policy. Replaces
slow-timeoutwhen runningcargo nextest bench. leak-timeout- Time to wait for child processes to exit after a matching test completes.
success-outputandfailure-output- When to display output for matching successful and failed tests, respectively.
junit.store-success-outputandjunit.store-failure-output- Whether to store successful and failed output, respectively, for matching tests in the JUnit XML report.
junit.flaky-fail-status0.9.131- How matching flaky-fail tests are reported in the JUnit XML report: as
"failure"(default) or"success". default-filter0.9.84- Replaces
default-filterfor matching platforms. Requiresplatformand must not be combined withfilter. run-extra-args0.9.86- Extra arguments to pass to matching test binaries.
Example¶
[profile.ci]
retries = 1
[[profile.ci.overrides]]
filter = 'test(/\btest_network_/)'
retries = 4
[[profile.ci.overrides]]
platform = 'x86_64-unknown-linux-gnu'
slow-timeout = "5m"
[[profile.ci.overrides]]
filter = 'test(/\btest_filesystem_/)'
platform = { host = 'cfg(target_os = "macos")' }
leak-timeout = "500ms"
success-output = "immediate"
When --profile ci is specified:
- for test names that start with
test_network_(including test names likemy_module::test_network_), retry tests up to 4 times - on
x86_64-unknown-linux-gnu, set a slow timeout of 5 minutes - on macOS hosts, for test names that start with
test_filesystem_(including test names likemy_module::test_filesystem_), set a leak timeout of 500 milliseconds, and show success output immediately.
Override precedence¶
Overrides are configured as an ordered list, and are applied in the following order. For a given test T and a given setting S, overrides are applied in the following order:
- Command-line arguments and environment variables for S, if specified, take precedence over all overrides. See Hierarchical configuration for more.
- If nextest is run with
--profile my-profile, the first override withinprofile.my-profile.overridesthat matches T and configures S is applied. - Otherwise, the first override within
profile.default.overridesthat matches T and configures S is applied. - Otherwise, if nextest is run with
--profile my-profile, the global configuration for that profile is applied, if it configures S. - If none of the above conditions apply, the global configuration specified by
profile.defaultis applied.
Precedence is evaluated separately for each override. If a particular override does not configure a setting, it is ignored for that setting.
Example¶
[profile.default]
retries = 0 # this is the default, so it doesn't need to be specified
slow-timeout = "30s"
[[profile.default.overrides]]
filter = 'package(my-package)'
retries = 2
slow-timeout = "45s"
[profile.ci]
retries = 1
slow-timeout = { period = "15s", terminate-after = 2 }
[[profile.ci.overrides]]
filter = 'package(my-package) and test(/^flaky::/)'
retries = 3
If nextest is run with --retries 5, all tests are retried 5 times. The slow timeout settings are evaluated as listed below.
Otherwise, if nextest is run with --profile ci:
- Tests in
my-packagethat begin withflaky::are retried 3 times, and are run with a slow timeout of 45 seconds. - Other tests in
my-packageare retried 2 times and are run with a slow timeout of 45 seconds. - All other tests are retried up to one time and are run with a slow-timeout of 15 seconds. Tests that take longer than 30 seconds are terminated.
If nextest is run without --profile:
- Tests in
my-packageare retried 2 times and with a slow timeout of 45 seconds. - Other tests are retried 0 times with a slow timeout of 30 seconds.