From 8adabdbb8a8a848b56396a5edcdab1c5632842d5 Mon Sep 17 00:00:00 2001 From: Isaac Lim <285327050+isaaclimmy@users.noreply.github.com> Date: Sat, 7 Nov 2026 03:15:07 +0800 Subject: [PATCH] =?UTF-8?q?Defer=20the=20Makefile=E2=80=99s=20pytest-xdist?= =?UTF-8?q?=20probe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 4 ++-- tests/test_makefile.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 12e3ed1..64663a9 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,8 @@ test: ## Run the full test suite (mirrors CI) # about 35 s with it (#1256). Without it the run is serial, and the ten slowest tests are listed either way. # Each worker's BLAS is limited to one thread: with all of them multi-threaded the CPU is oversubscribed and the # CPU-heavy explainer smoke test hit its 30 s timeout once. -XDIST := $(shell $(PY) -c "import importlib.util as u; print('-n auto' if u.find_spec('xdist') else '')" 2>/dev/null) -XDIST_ENV := $(if $(XDIST),OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 VECLIB_MAXIMUM_THREADS=1,) +XDIST = $(shell $(PY) -c "import importlib.util as u; print('-n auto' if u.find_spec('xdist') else '')" 2>/dev/null) +XDIST_ENV = $(if $(XDIST),OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 VECLIB_MAXIMUM_THREADS=1,) test-fast: ## Run the suite without the slow model-training benchmark tests or the Chromium tests (make test-browser), in parallel when pytest-xdist is installed (CI still runs everything) $(XDIST_ENV) $(PY) -m pytest tests/ -q -m "not slow" --ignore=tests/browser $(XDIST) --durations=10 diff --git a/tests/test_makefile.py b/tests/test_makefile.py index 4ad8209..12ecbf1 100644 --- a/tests/test_makefile.py +++ b/tests/test_makefile.py @@ -1,4 +1,5 @@ """The Makefile's targets say what the documentation says they do.""" +import os import re import subprocess from pathlib import Path @@ -10,6 +11,17 @@ def dry_run(target: str) -> str: return subprocess.run(["make", "-n", target], cwd=ROOT, capture_output=True, text=True, check=True).stdout +def test_help_does_not_run_python(tmp_path, monkeypatch): + python = tmp_path / "python3" + python.write_text('#!/bin/sh\n: > "$0.called"\nexit 1\n', encoding="utf-8") + python.chmod(0o755) + monkeypatch.setenv("PATH", str(tmp_path), prepend=os.pathsep) + + subprocess.run(["make", "help"], cwd=ROOT, capture_output=True, check=True) + + assert not python.with_suffix(".called").exists() + + def test_test_fast_leaves_the_browser_tests_to_make_test_browser(): # #1263: with Playwright installed `pytest tests/` also collected tests/browser (1,476 tests instead of 1,464) recipe = dry_run("test-fast")