diff options
| author | Hermes Agent <hermes@localhost> | 2026-08-12 07:14:29 +0000 |
|---|---|---|
| committer | Hermes Agent <hermes@localhost> | 2026-08-12 07:14:29 +0000 |
| commit | e5338d823d5e9b2042bbba482c0f629762bbe163 (patch) | |
| tree | 73f516a6007e46f43a74c2936685b3c59151e334 /tests | |
| parent | e09ee680abd286d25604c2242fa3e128fbdeed69 (diff) | |
Clean workspace after initramfs failure
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/build.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/build.rs b/tests/build.rs index dc9443c..987811a 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -31,6 +31,14 @@ impl PackageInstaller for FailingInstaller { } } +struct FailingInitramfsBuilder; + +impl InitramfsBuilder for FailingInitramfsBuilder { + fn build(&mut self, _request: &InitramfsRequest) -> anyhow::Result<InitramfsResult> { + anyhow::bail!("simulated initramfs build failure") + } +} + #[derive(Default)] struct FixtureInitramfsBuilder; @@ -181,3 +189,22 @@ fn removes_the_new_workspace_when_package_installation_fails() { assert!(!workspace.exists(), "failed build must not leave a workspace"); assert!(!artifact.exists()); } + +#[test] +fn removes_the_new_workspace_when_initramfs_build_fails() { + let fixture = tempdir().expect("fixture directory"); + let spec = ImageSpec::load(std::path::Path::new("profiles/alt-controller.toml")) + .expect("load controller spec"); + let plan = BuildPlan::compile(spec).expect("compile build plan"); + let mut executor = BuildExecutor::new(FixtureInstaller::default(), FailingInitramfsBuilder); + let workspace = fixture.path().join("work"); + let artifact = fixture.path().join("image.tar"); + + let error = executor + .execute(&plan, &workspace, "profiles/apt.conf", &artifact) + .expect_err("failed initramfs build must fail the build"); + + assert!(error.to_string().contains("simulated initramfs build failure")); + assert!(!workspace.exists(), "failed build must not leave a workspace"); + assert!(!artifact.exists()); +} |