Capture output in DockerContainer.environment_executor to fix command substitutions in CIBW_ENVIRONMENT on Linux
This commit is contained in:
@@ -182,7 +182,7 @@ class DockerContainer:
|
|||||||
|
|
||||||
def environment_executor(self, command: List[str], environment: Dict[str, str]) -> str:
|
def environment_executor(self, command: List[str], environment: Dict[str, str]) -> str:
|
||||||
# used as an EnvironmentExecutor to evaluate commands and capture output
|
# used as an EnvironmentExecutor to evaluate commands and capture output
|
||||||
return self.call(command, env=environment)
|
return self.call(command, env=environment, capture_output=True)
|
||||||
|
|
||||||
|
|
||||||
def shell_quote(path: PurePath) -> str:
|
def shell_quote(path: PurePath) -> str:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from pathlib import Path, PurePath
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from cibuildwheel.docker_container import DockerContainer
|
from cibuildwheel.docker_container import DockerContainer
|
||||||
|
from cibuildwheel.environment import EnvironmentAssignment
|
||||||
|
|
||||||
# for these tests we use manylinux2014 images, because they're available on
|
# for these tests we use manylinux2014 images, because they're available on
|
||||||
# multi architectures and include python3.8
|
# multi architectures and include python3.8
|
||||||
@@ -145,3 +146,10 @@ def test_dir_operations(tmp_path: Path):
|
|||||||
container.copy_out(dst_dir, new_test_dir)
|
container.copy_out(dst_dir, new_test_dir)
|
||||||
|
|
||||||
assert test_binary_data == (new_test_dir / 'test.dat').read_bytes()
|
assert test_binary_data == (new_test_dir / 'test.dat').read_bytes()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.docker
|
||||||
|
def test_environment_executor():
|
||||||
|
with DockerContainer(DEFAULT_IMAGE) as container:
|
||||||
|
assignment = EnvironmentAssignment("TEST=$(echo 42)")
|
||||||
|
assert assignment.evaluated_value({}, container.environment_executor) == "42"
|
||||||
|
|||||||
Reference in New Issue
Block a user