# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# IMPORTANT: nextest processes this file in linear order. The
# first override to set any setting wins. Order any overrides
# from most-to-least specific.
#
# Take the following config items by example:
#
# [[profile.default.overrides]] # <-- override 1
# filter = 'package(~vmm_tests)'
# threads-required = 3
#
# [[profile.default.overrides]] # <-- override 2
# filter = 'package(~vmm_tests) and test(very_heavy)'
# threads-required = 35
#
# If a test is named "my_very_heavy_test", nextest will
# apply ***threads-required = 3***, since override 1
# is first in the file and matches.
#
# See:
# https://nexte.st/docs/configuration/per-test-overrides/#override-precedence
# https://nexte.st/docs/configuration/?h=hierar#hierarchical-configuration

[[profile.ci.overrides]]
# use fuzzy-matching for the package() to allow out-of-tree tests to use the
# same profile
filter = 'package(~vmm_tests)'
# VMM tests contain their own watchdog timer, but keep an extra long timer
# here as a backup.
slow-timeout = { period = "10m", terminate-after = 2 }

[[profile.default.overrides]]
filter = 'package(~vmm_tests) and test(very_heavy)'
# Extra heavy tests have even more VPs. Internal runners fail when 32vp tests
# are not run one at a time.
threads-required = 32

[[profile.default.overrides]]
filter = 'package(~vmm_tests) and test(heavy) and not (test(very_heavy))'
# Require more threads for heavy tests with more VPs to avoid unreliability
# due to contention on the physical cores.
threads-required = 4

[[profile.default.overrides]]
# use fuzzy-matching for the package() to allow out-of-tree tests to use the
# same profile
filter = 'package(~vmm_tests)'
# Limit the amount of simultaneous tests by requiring two threads per test.
# This is mostly to avoid running out of memory. Our test runners have 32 cores
# and 128GB of memory, and most tests use 4GB, so total memory usage should be
# about 4GB * (32 cores / (2 threads/test)) = 64GB < 128GB.
# For local dev runs, you may need to manually restrict the number of
# threads running via the -j cli arg.
threads-required = 2
# Use the same slow timeout as ci, but never terminate
slow-timeout = { period = "10m" }

[[profile.ci.overrides]]
# allow loom based tests more time, as they take a while
filter = 'test(loom)'
slow-timeout = { period = "30s", terminate-after = 2 }

# Profile for AI agent runs. Minimizes output noise: only prints slow, failing,
# and flaky tests. Agents should use: cargo nextest run -p <pkg> --profile agent
[profile.agent]
# Only show slow and failing tests during the run (hide PASS lines).
status-level = "slow"
# Show failures and flaky tests in the final summary.
final-status-level = "flaky"
# Mark tests slow after 5s, kill after 30s (6 periods).
slow-timeout = { period = "5s", terminate-after = 6 }
# Print failure output immediately so humans watching can see it.
failure-output = "immediate"
# Don't fail fast--let the agent see all failures at once.
fail-fast = false

# Profile for CI runs.
[profile.ci]
# Set the default timeout to 1 second, with tests terminated after 10 seconds
slow-timeout = { period = "1s", terminate-after = 10 }
# Print out output for failing tests at the end of the run.
failure-output = "final"
# Do not cancel the test run on the first failure.
fail-fast = false

[profile.ci.junit]
path = "junit.xml"
store-success-output = "true"