diff --git a/tests/data/pixi_build/config-pickup-test/pixi.toml b/tests/data/pixi_build/config-pickup-test/pixi.toml new file mode 100644 index 0000000..f559a84 --- /dev/null +++ b/tests/data/pixi_build/config-pickup-test/pixi.toml @@ -0,0 +1,18 @@ +[workspace] +channels = [] +platforms = ["win-64", "linux-64", "osx-arm64", "osx-64"] +preview = ["pixi-build"] + +[dependencies] +simple-config-test = { path = "." } + +[tasks] +start = "simple-config-test" + +[package] +name = "simple-config-test" +version = "0.1.0" + +[package.build] +backend = { name = "pixi-build-rattler-build", version = "*" } +channels = ["https://broken.url/conda-forge"] diff --git a/tests/data/pixi_build/config-pickup-test/recipe.yaml b/tests/data/pixi_build/config-pickup-test/recipe.yaml new file mode 100644 index 0000000..8626923 --- /dev/null +++ b/tests/data/pixi_build/config-pickup-test/recipe.yaml @@ -0,0 +1,21 @@ +package: + name: simple-config-test + version: 0.1.0 + +build: + number: 0 + script: + - if: win + then: + - mkdir -p %PREFIX%\bin + - echo @echo off > %PREFIX%\bin\simple-config-test.bat + - echo echo Build backend works >> %PREFIX%\bin\simple-config-test.bat + else: + - mkdir -p $PREFIX/bin + - echo "#!/usr/bin/env bash" > $PREFIX/bin/simple-config-test + - echo "echo Build backend works" >> $PREFIX/bin/simple-config-test + - chmod +x $PREFIX/bin/simple-config-test + +requirements: + host: + - fd-find diff --git a/tests/integration_python/test_config_pickup.py b/tests/integration_python/test_config_pickup.py new file mode 100644 index 0000000..3fd2c5a --- /dev/null +++ b/tests/integration_python/test_config_pickup.py @@ -0,0 +1,37 @@ +import shutil +from pathlib import Path + +import tomli_w +import tomllib + +from .common import verify_cli_command + + +def test_config_pickup_by_build_backends( + pixi: Path, build_data: Path, tmp_pixi_workspace: Path +) -> None: + """ + Test that pixi build backends pick up config from .pixi/config.toml. + + First tests with working config, then verifies the config is actually + being used by checking the log output for mirror usage. + """ + # Copy our test workspace + test_data = build_data.joinpath("config-pickup-test") + shutil.copytree(test_data, tmp_pixi_workspace, dirs_exist_ok=True) + + manifest_path = tmp_pixi_workspace.joinpath("pixi.toml") + + # Create .pixi/config.toml with mirror that redirects from the broken URL to our backends channel + pixi_dir = tmp_pixi_workspace.joinpath(".pixi") + config_path = pixi_dir.joinpath("config.toml") + config = tomllib.loads(config_path.read_text()) + config["mirrors"] = { + "https://broken.url/conda-forge": ["https://prefix.dev/conda-forge"], + } + config_path.write_text(tomli_w.dumps(config)) + + verify_cli_command( + [pixi, "run", "-v", "--manifest-path", manifest_path, "start"], + stdout_contains="Build backend works", + )