From 527176ca977e29e3e5a80f952284eb1802220fb6 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 26 Jan 2026 09:03:19 +1100 Subject: [PATCH] test_driver: reduce default concurrency to reduce flakiness Unlimited concurrency frequently makes system tests fail when when run as "tests/test_driver.py" or "cargo xtask check". Add a workaround until we fix them. Use $(nproc), which is already the default for RUST_TEST_THREADS and CARGO_BUILD_JOBS, and it works pretty reliably on my laptop. It's possible that we can increase it a bit to make it faster, but until the tests are improved, we can't increase it much without risking failures. Ref: https://github.com/fish-shell/fish-shell/pull/12292#discussion_r2713370474 Tracking issue: #11815 --- tests/test_driver.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_driver.py b/tests/test_driver.py index 4e669ceaf..fe14a8f90 100755 --- a/tests/test_driver.py +++ b/tests/test_driver.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import argparse import asyncio +import multiprocessing import os import resource import shutil @@ -122,8 +123,10 @@ async def main(): argparser.add_argument( "--max-concurrency", type=int, - help="Maximum number of tests to run concurrently. The default is to run all tests concurrently.", - default=os.environ.get("FISH_TEST_MAX_CONCURRENCY"), + help="Maximum number of tests to run concurrently. The default is the number of logical CPUs.", + default=os.environ.get( + "FISH_TEST_MAX_CONCURRENCY", multiprocessing.cpu_count() + ), ) argparser.add_argument( "fish", @@ -134,7 +137,7 @@ async def main(): args = argparser.parse_args() max_concurrency = args.max_concurrency - if max_concurrency is not None and max_concurrency < 1: + if max_concurrency < 1: print("--max-concurrency must be at least 1") sys.exit(1) @@ -208,7 +211,7 @@ async def main(): tmp_root / "fish_test_helper", ) - semaphore = asyncio.Semaphore(max_concurrency) if max_concurrency else None + semaphore = asyncio.Semaphore(max_concurrency) async def run(f, arg) -> TestResult: # TODO(python>3.8): use "async with"