mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-10-21 15:18:19 +00:00
27 lines
591 B
Perl
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;
|