From 472ded6647b01a55aa24b2d35de3926b177115bb Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Wed, 2 Sep 2026 12:46:11 -0300 Subject: [PATCH] test(build): stage both BuildUtils modules into the sandbox buildrpms_source_only.t runs buildrpms.pl from a copied sandbox, and staged only BuildUtils.pm. Master added a second module with the same basename, build-utils/lib/XCAT/BuildUtils.pm, which buildrpms.pl also loads. The sandboxed run then died with "Can't locate .../build-utils/lib/XCAT/ BuildUtils.pm" before it reached the argument parsing the test asserts on. Stage each needed file at its own relative path and create the parent directory, so both modules reach the sandbox. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/unit/buildrpms_source_only.t | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/xCAT-test/unit/buildrpms_source_only.t b/xCAT-test/unit/buildrpms_source_only.t index ebc58a98f..5779d34b0 100644 --- a/xCAT-test/unit/buildrpms_source_only.t +++ b/xCAT-test/unit/buildrpms_source_only.t @@ -10,7 +10,9 @@ use strict; use warnings; use Cwd qw(getcwd); +use File::Basename qw(dirname); use File::Copy (); +use File::Path qw(make_path); use File::Slurper qw(read_text); use File::Spec; use File::Temp qw(tempdir); @@ -140,13 +142,18 @@ ok( !grep( { $_ eq 'buildpkgs' } @{ stages_for(1) } ), # buildrpms.pl rewrites the tracked Gitinfo in its working directory and creates # $HOME/rpmbuild. Running it in place left the developer's tree dirty and reached # into their home for a test that only exercises argument parsing. Version is -# staged because the same file-scope code reads it and dies without it, and -# BuildUtils.pm because buildrpms.pl loads it from its own directory. +# staged because the same file-scope code reads it and dies without it. Both +# modules named BuildUtils.pm are staged at their own relative paths, because +# buildrpms.pl loads each from a different directory: BuildUtils.pm from its own, +# and XCAT::BuildUtils from build-utils/lib/XCAT. my $sandbox = tempdir(CLEANUP => 1); -for my $needed (qw(buildrpms.pl Version BuildUtils.pm)) { +for my $needed (qw(buildrpms.pl Version BuildUtils.pm + build-utils/lib/XCAT/BuildUtils.pm)) { my $from = repo_path($needed); BAIL_OUT("$needed is missing from the repository") unless -r $from; - File::Copy::copy($from, File::Spec->catfile($sandbox, $needed)) + my $to = File::Spec->catfile($sandbox, split(m{/}, $needed)); + make_path(dirname($to)); + File::Copy::copy($from, $to) or BAIL_OUT("could not stage $needed: $!"); }