2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-10-21 15:18:19 +00:00
Files
2026-10-13 11:38:10 -03:00

27 lines
591 B
Perl

package XCAT::Test::Package;
use strict;
use warnings;
use Cwd qw(getcwd);
use Exporter qw(import);
use XCAT::Test::Lifecycle ();
our @EXPORT_OK = qw(run_in);
sub run_in {
my ($directory, @command) = @_;
my $previous = getcwd();
chdir($directory) or die "chdir $directory: $!";
my ($stdout, $stderr, $status);
my $ok = eval {
($status, $stdout, $stderr) = XCAT::Test::Lifecycle::command(@command);
1;
};
my $error = $@;
chdir($previous) or die "chdir $previous: $!";
die $error unless $ok;
return ($status, $stdout, $stderr);
}
1;