From 1c88ac5cba34058fc172001325dd2703d6fb3b92 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Wed, 12 Aug 2026 07:29:47 +0000 Subject: Clean workspace when installer produces no rootfs --- tests/build.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/build.rs') diff --git a/tests/build.rs b/tests/build.rs index 987811a..cae79b0 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -31,6 +31,14 @@ impl PackageInstaller for FailingInstaller { } } +struct RootfslessInstaller; + +impl PackageInstaller for RootfslessInstaller { + fn install(&self, _request: &PackageRequest) -> anyhow::Result<()> { + Ok(()) + } +} + struct FailingInitramfsBuilder; impl InitramfsBuilder for FailingInitramfsBuilder { @@ -190,6 +198,25 @@ fn removes_the_new_workspace_when_package_installation_fails() { assert!(!artifact.exists()); } +#[test] +fn removes_the_new_workspace_when_the_installer_does_not_create_a_rootfs() { + 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(RootfslessInstaller, FixtureInitramfsBuilder); + 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("missing rootfs must fail the build"); + + assert!(error.to_string().contains("package installer did not create rootfs")); + 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"); -- cgit v1.2.3