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
This commit is contained in:
Johannes Altmanninger
2026-01-26 09:03:19 +11:00
parent 0cd8d64607
commit 527176ca97

View File

@@ -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"