Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/conformance/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@
ROOT = Path(__file__).resolve().parents[2]


# A compiler launcher in front of the toolchain runs as part of the build and
# lands in the recording, so a diff test would describe whichever launcher the
# machine happens to have installed. Tests that want one put it on PATH
# themselves.
LAUNCHERS = frozenset({"ccache", "distcc", "icecc", "sccache"})


@pytest.fixture
def plain_environment() -> dict[str, str]:
"""The environment with any compiler launcher taken off `PATH`."""
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))


def pytest_addoption(parser: pytest.Parser) -> None:
parser.addoption(
"--update-expectations",
Expand Down
11 changes: 6 additions & 5 deletions tests/conformance/test_build_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ def tool_of(pid: int) -> str:


@pytest.mark.parametrize("case", sorted(CASES))
def test_build_system(case, buildprof: Path, tmp_path: Path, request):
def test_build_system(
case, buildprof: Path, tmp_path: Path, request, plain_environment: dict
):
for tool in REQUIRED_TOOLS[case]:
if shutil.which(tool) is None:
message = f"{tool} is not installed in this environment"
Expand All @@ -214,14 +216,13 @@ def test_build_system(case, buildprof: Path, tmp_path: Path, request):
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=env,
env=plain_environment,
)
assert result.returncode == 0, f"{case} build failed:\n{result.stdout}{result.stderr}"
assert trace.is_file(), f"{case} produced no trace"
Expand All @@ -241,7 +242,7 @@ def test_build_system(case, buildprof: Path, tmp_path: Path, request):
)


def test_npm_build(buildprof: Path, tmp_path: Path):
def test_npm_build(buildprof: Path, tmp_path: Path, plain_environment: dict):
for tool in ("npm", "node"):
if shutil.which(tool) is None:
message = f"{tool} is not installed in this environment"
Expand All @@ -254,7 +255,7 @@ def test_npm_build(buildprof: Path, tmp_path: Path):
result = subprocess.run(
[str(buildprof), "--no-open", "-o", str(trace), "--", *command],
cwd=tmp_path,
env=dict(os.environ, LC_ALL="C", npm_config_cache=str(tmp_path / ".npm")),
env=dict(plain_environment, npm_config_cache=str(tmp_path / ".npm")),
text=True,
capture_output=True,
timeout=60,
Expand Down
Loading