From 796f7c174bd91ac6d3c9833385d68e7c60bbd771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Sun, 6 Sep 2026 02:44:58 -0300 Subject: [PATCH] test(xcat-dep): capture a rejected deb left in staging Both assertions fail against the previous build_deb_in_chroot, which left the deb in the result directory after the smoke rejected it. --- t/sbuild-all.t | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/t/sbuild-all.t b/t/sbuild-all.t index 926f3e3..9a29df5 100644 --- a/t/sbuild-all.t +++ b/t/sbuild-all.t @@ -607,8 +607,13 @@ STUB local $ENV{PATH} = "$fakebin:$ENV{PATH}"; local $ENV{FAKE_SCHROOT_CONFIG} = "[noble-amd64-sbuild]\ntype=directory\ndirectory=/srv/chroot/noble-amd64\nunion-type=overlay\n"; - open my $dfh, '>', "$work/out/fixture-xcat_1.8.18-4_amd64.deb" or die $!; - print $dfh "not really a deb\n"; close $dfh; + # A failed smoke removes the deb it rejected, so each case plants a fresh one. + my $plant = sub { + open my $dfh, '>', "$work/out/fixture-xcat_1.8.18-4_amd64.deb" or die $!; + print {$dfh} "not really a deb\n"; + close $dfh; + }; + $plant->(); my %smoke = (deb => qr/^fixture-xcat_/, run => '/opt/xcat/bin/fixture-xcat -V', expect => qr/fixture-xcat version 1\.8\.18/); @@ -627,17 +632,27 @@ STUB ok(!$ok, 'a binary reporting another version fails the smoke'); like($@, qr/does not match/, '... naming the expectation it missed'); + # The debs are already in staging when the smoke runs, and the publish gate checks names + # and versions only. One left behind is the broken binary the smoke exists to catch. + is_deeply([ glob("$work/out/*.deb") ], [], + '... and the deb it rejected is gone from the result directory'); + like($@, qr/were removed from/, '... which the failure says'); + + $plant->(); + local $ENV{FAKE_SMOKE_OUT} = 'fixture-xcat version 1.8.18'; local $ENV{FAKE_SMOKE_RC} = 3; $ok = eval { quiet { build_deb_in_chroot(@args, smoke => \%smoke) }; 1 }; ok(!$ok, 'a binary that cannot run fails the smoke even with matching output'); like($@, qr/smoke failed \(rc=3\)/, '... reporting the exit status'); + $plant->(); delete local $ENV{FAKE_SMOKE_RC}; $ok = eval { quiet { build_deb_in_chroot(@args, smoke => { %smoke, deb => qr/^nosuchpkg_/ }) }; 1 }; ok(!$ok, 'a smoke that names a deb the build never produced fails'); like($@, qr/no produced deb matches/, '... instead of silently skipping the check'); + $plant->(); # --skip-install is what sbuild-all.pl passes to drop the smoke, so the same build with no # smoke must still succeed -- otherwise the tests above would pass for the wrong reason.