fd18b547e5
Adds the `user.rust` UPM to workshop-engine for managing Rust toolchains, components, cross-compilation targets, and cargo operations: - `rustup default <toolchain>` / `rustup component add` / `rustup target add` - `cargo fetch` for dependency pre-fetch with optional `--locked` - `cargo install` for global crate tools with registry support Includes 275-line test suite (`tests/upm/test_rust.py`) covering the full lifecycle with optional network tests.
106 lines
3.8 KiB
Python
106 lines
3.8 KiB
Python
import os
|
|
import pytest
|
|
|
|
FIXTURES = os.path.join(os.path.dirname(os.path.dirname(__file__)), "fixtures", "bake")
|
|
|
|
@pytest.mark.bake
|
|
class TestBakeSimpleScript:
|
|
|
|
def test_simple_script_runs(self, run_baker, bake_workspace, work_dir):
|
|
prebake_cfg = os.path.join(
|
|
os.path.dirname(os.path.dirname(__file__)), "fixtures", "prebake", "minimal.yml"
|
|
)
|
|
script = os.path.join(FIXTURES, "simple.sh")
|
|
bake_base = os.path.join(FIXTURES, "bake_base.sh")
|
|
|
|
result = run_baker(
|
|
"bake", script,
|
|
"--bake-base", bake_base,
|
|
"--prebake", prebake_cfg,
|
|
cwd=work_dir,
|
|
timeout=60,
|
|
)
|
|
assert result["success"], f"Bake failed: {result['stderr']}"
|
|
assert "Hello from simple bake script" in result["stdout"]
|
|
|
|
def test_simple_script_sets_env_vars(self, run_baker, bake_workspace, work_dir):
|
|
prebake_cfg = os.path.join(
|
|
os.path.dirname(os.path.dirname(__file__)), "fixtures", "prebake", "minimal.yml"
|
|
)
|
|
script = os.path.join(FIXTURES, "simple.sh")
|
|
bake_base = os.path.join(FIXTURES, "bake_base.sh")
|
|
|
|
result = run_baker(
|
|
"bake", script,
|
|
"--bake-base", bake_base,
|
|
"--prebake", prebake_cfg,
|
|
cwd=work_dir,
|
|
timeout=60,
|
|
)
|
|
assert result["success"]
|
|
assert "test-pipeline" in result["stdout"]
|
|
|
|
@pytest.mark.bake
|
|
class TestBakePipeline:
|
|
|
|
def test_pipeline_functions_execute(self, run_baker, bake_workspace, work_dir):
|
|
prebake_cfg = os.path.join(
|
|
os.path.dirname(os.path.dirname(__file__)), "fixtures", "prebake", "minimal.yml"
|
|
)
|
|
script = os.path.join(FIXTURES, "pipeline.sh")
|
|
bake_base = os.path.join(FIXTURES, "bake_base.sh")
|
|
|
|
result = run_baker(
|
|
"bake", script,
|
|
"--bake-base", bake_base,
|
|
"--prebake", prebake_cfg,
|
|
cwd=work_dir,
|
|
timeout=60,
|
|
)
|
|
assert result["success"], f"Pipeline bake failed: {result['stderr']}"
|
|
assert os.path.exists("/tmp/bake-test-output/step1.txt")
|
|
assert os.path.exists("/tmp/bake-test-output/step2.txt")
|
|
|
|
def test_pipeline_step_outputs_correct(self, run_baker, bake_workspace, work_dir):
|
|
prebake_cfg = os.path.join(
|
|
os.path.dirname(os.path.dirname(__file__)), "fixtures", "prebake", "minimal.yml"
|
|
)
|
|
script = os.path.join(FIXTURES, "pipeline.sh")
|
|
bake_base = os.path.join(FIXTURES, "bake_base.sh")
|
|
|
|
result = run_baker(
|
|
"bake", script,
|
|
"--bake-base", bake_base,
|
|
"--prebake", prebake_cfg,
|
|
cwd=work_dir,
|
|
timeout=60,
|
|
)
|
|
assert result["success"]
|
|
with open("/tmp/bake-test-output/step1.txt") as f:
|
|
assert f.read().strip() == "step1-done"
|
|
with open("/tmp/bake-test-output/step2.txt") as f:
|
|
assert f.read().strip() == "step2-done"
|
|
|
|
@pytest.mark.bake
|
|
class TestBakeAfterDependencies:
|
|
|
|
def test_after_ordering(self, run_baker, bake_workspace, work_dir):
|
|
prebake_cfg = os.path.join(
|
|
os.path.dirname(os.path.dirname(__file__)), "fixtures", "prebake", "minimal.yml"
|
|
)
|
|
script = os.path.join(FIXTURES, "with_after.sh")
|
|
bake_base = os.path.join(FIXTURES, "bake_base.sh")
|
|
|
|
result = run_baker(
|
|
"bake", script,
|
|
"--bake-base", bake_base,
|
|
"--prebake", prebake_cfg,
|
|
cwd=work_dir,
|
|
timeout=60,
|
|
)
|
|
assert result["success"], f"@after bake failed: {result['stderr']}"
|
|
assert os.path.exists("/tmp/bake-after-test/status.txt")
|
|
assert os.path.exists("/tmp/bake-after-test/source.txt")
|
|
assert os.path.exists("/tmp/bake-after-test/build.txt")
|
|
|