forked from lix-project/hydra
Hydra::Helper::Nix: expose a captureStdoutStderrWithStdin, make it available in tests
This commit is contained in:
parent
d4fe7e55dd
commit
3a6c25489c
|
@ -18,6 +18,7 @@ our @ISA = qw(Exporter);
|
||||||
our @EXPORT = qw(
|
our @EXPORT = qw(
|
||||||
cancelBuilds
|
cancelBuilds
|
||||||
captureStdoutStderr
|
captureStdoutStderr
|
||||||
|
captureStdoutStderrWithStdin
|
||||||
findLog
|
findLog
|
||||||
gcRootFor
|
gcRootFor
|
||||||
getBaseUrl
|
getBaseUrl
|
||||||
|
@ -428,14 +429,19 @@ sub pathIsInsidePrefix {
|
||||||
|
|
||||||
sub captureStdoutStderr {
|
sub captureStdoutStderr {
|
||||||
my ($timeout, @cmd) = @_;
|
my ($timeout, @cmd) = @_;
|
||||||
my $stdin = "";
|
|
||||||
|
return captureStdoutStderrWithStdin($timeout, \@cmd, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
sub captureStdoutStderrWithStdin {
|
||||||
|
my ($timeout, $cmd, $stdin) = @_;
|
||||||
my $stdout;
|
my $stdout;
|
||||||
my $stderr;
|
my $stderr;
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
local $SIG{ALRM} = sub { die "timeout\n" }; # NB: \n required
|
local $SIG{ALRM} = sub { die "timeout\n" }; # NB: \n required
|
||||||
alarm $timeout;
|
alarm $timeout;
|
||||||
IPC::Run::run(\@cmd, \$stdin, \$stdout, \$stderr);
|
IPC::Run::run($cmd, \$stdin, \$stdout, \$stderr);
|
||||||
alarm 0;
|
alarm 0;
|
||||||
1;
|
1;
|
||||||
} or do {
|
} or do {
|
||||||
|
|
|
@ -5,6 +5,7 @@ package CliRunners;
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
our @EXPORT = qw(
|
our @EXPORT = qw(
|
||||||
captureStdoutStderr
|
captureStdoutStderr
|
||||||
|
captureStdoutStderrWithStdin
|
||||||
evalFails
|
evalFails
|
||||||
evalSucceeds
|
evalSucceeds
|
||||||
runBuild
|
runBuild
|
||||||
|
@ -21,6 +22,15 @@ sub captureStdoutStderr {
|
||||||
return Hydra::Helper::Nix::captureStdoutStderr(@_)
|
return Hydra::Helper::Nix::captureStdoutStderr(@_)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub captureStdoutStderrWithStdin {
|
||||||
|
# "Lazy"-load Hydra::Helper::Nix to avoid the compile-time
|
||||||
|
# import of Hydra::Model::DB. Early loading of the DB class
|
||||||
|
# causes fixation of the DSN, and we need to fixate it after
|
||||||
|
# the temporary DB is setup.
|
||||||
|
require Hydra::Helper::Nix;
|
||||||
|
return Hydra::Helper::Nix::captureStdoutStderrWithStdin(@_)
|
||||||
|
}
|
||||||
|
|
||||||
sub evalSucceeds {
|
sub evalSucceeds {
|
||||||
my ($jobset) = @_;
|
my ($jobset) = @_;
|
||||||
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-eval-jobset", $jobset->project->name, $jobset->name));
|
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-eval-jobset", $jobset->project->name, $jobset->name));
|
||||||
|
|
|
@ -13,6 +13,7 @@ use CliRunners;
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
our @EXPORT = qw(
|
our @EXPORT = qw(
|
||||||
captureStdoutStderr
|
captureStdoutStderr
|
||||||
|
captureStdoutStderrWithStdin
|
||||||
createBaseJobset
|
createBaseJobset
|
||||||
createJobsetWithOneInput
|
createJobsetWithOneInput
|
||||||
evalFails
|
evalFails
|
||||||
|
|
Loading…
Reference in a new issue