Skip to content
Draft
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/data/pixi_build/config-pickup-test/pixi.toml
Original file line number Diff line number Diff line change
@@ -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"]
21 changes: 21 additions & 0 deletions tests/data/pixi_build/config-pickup-test/recipe.yaml
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions tests/integration_python/test_config_pickup.py
Original file line number Diff line number Diff line change
@@ -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",
)
Loading