From 2ce304d5d9c8ac14b550e9a5e50ba25a86a6045f Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Mon, 3 Feb 2020 14:26:53 +0100 Subject: [PATCH] Add test checking cibuildwheel detects when PATH is messed up by CIBW_ENVIRONMENT --- test/05_environment/cibuildwheel_test.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/05_environment/cibuildwheel_test.py b/test/05_environment/cibuildwheel_test.py index 4f0b922d..ab467111 100644 --- a/test/05_environment/cibuildwheel_test.py +++ b/test/05_environment/cibuildwheel_test.py @@ -1,5 +1,6 @@ import os - +import pytest +import subprocess import utils @@ -17,3 +18,15 @@ def test(): # also check that we got the right wheels built expected_wheels = utils.expected_wheels('spam', '0.1.0') assert set(actual_wheels) == set(expected_wheels) + + +def test_overridden_path(tmp_path): + project_dir = os.path.dirname(__file__) + + # mess up PATH, somehow + with pytest.raises(subprocess.CalledProcessError): + utils.cibuildwheel_run(project_dir, output_dir=tmp_path, add_env={ + 'CIBW_ENVIRONMENT': '''SOMETHING="$(mkdir new_path && touch new_path/python)" PATH="$(realpath new_path):$PATH"''', + 'CIBW_ENVIRONMENT_WINDOWS': '''SOMETHING="$(mkdir new_path && type nul > new_path/python.exe)" PATH="$CD\\new_path;$PATH"''', + }) + assert len(os.listdir(str(tmp_path))) == 0