diff --git a/tests/conformance/conftest.py b/tests/conformance/conftest.py index 80bf0ea..411536e 100644 --- a/tests/conformance/conftest.py +++ b/tests/conformance/conftest.py @@ -21,14 +21,24 @@ @pytest.fixture -def plain_environment() -> dict[str, str]: - """The environment with any compiler launcher taken off `PATH`.""" +def plain_toolchain(monkeypatch: pytest.MonkeyPatch) -> None: + """Takes any compiler launcher off `PATH` for the whole test. + + Not just for the recording: CMake and Meson resolve the compiler when they + configure, and write the path they found into the build files, so a + launcher they saw would be used however the recording is run. + """ directories = [ directory for directory in os.environ.get("PATH", "").split(os.pathsep) if not LAUNCHERS & set(Path(directory).parts) ] - return dict(os.environ, LC_ALL="C", PATH=os.pathsep.join(directories)) + monkeypatch.setenv("PATH", os.pathsep.join(directories)) + # Meson goes looking for a launcher binary rather than taking the one in + # front of the compiler on PATH, and only leaves the compiler alone when + # it is told which one to use. + monkeypatch.setenv("CC", "cc") + monkeypatch.setenv("CXX", "c++") def pytest_addoption(parser: pytest.Parser) -> None: diff --git a/tests/conformance/test_build_systems.py b/tests/conformance/test_build_systems.py index 7fe5d12..6d92532 100644 --- a/tests/conformance/test_build_systems.py +++ b/tests/conformance/test_build_systems.py @@ -200,9 +200,7 @@ def tool_of(pid: int) -> str: @pytest.mark.parametrize("case", sorted(CASES)) -def test_build_system( - case, buildprof: Path, tmp_path: Path, request, plain_environment: dict -): +def test_build_system(case, buildprof: Path, tmp_path: Path, request, plain_toolchain): for tool in REQUIRED_TOOLS[case]: if shutil.which(tool) is None: message = f"{tool} is not installed in this environment" @@ -216,13 +214,14 @@ def test_build_system( command = build(project) trace = tmp_path / f"{case}.pftrace" + env = dict(os.environ, LC_ALL="C") result = subprocess.run( [str(buildprof), "-o", str(trace), "--", *command], cwd=project, text=True, capture_output=True, timeout=300, - env=plain_environment, + env=env, ) assert result.returncode == 0, f"{case} build failed:\n{result.stdout}{result.stderr}" assert trace.is_file(), f"{case} produced no trace" @@ -242,7 +241,7 @@ def test_build_system( ) -def test_npm_build(buildprof: Path, tmp_path: Path, plain_environment: dict): +def test_npm_build(buildprof: Path, tmp_path: Path, plain_toolchain): for tool in ("npm", "node"): if shutil.which(tool) is None: message = f"{tool} is not installed in this environment" @@ -255,7 +254,7 @@ def test_npm_build(buildprof: Path, tmp_path: Path, plain_environment: dict): result = subprocess.run( [str(buildprof), "--no-open", "-o", str(trace), "--", *command], cwd=tmp_path, - env=dict(plain_environment, npm_config_cache=str(tmp_path / ".npm")), + env=dict(os.environ, LC_ALL="C", npm_config_cache=str(tmp_path / ".npm")), text=True, capture_output=True, timeout=60,