t: create a evalFails helper

This commit is contained in:
Graham Christensen 2022-01-10 16:47:04 -05:00
parent 40e556aee5
commit 8d4c448e92
2 changed files with 36 additions and 6 deletions

View file

@ -4,8 +4,12 @@ use strict;
package CliRunners; package CliRunners;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = qw( our @EXPORT = qw(
evalSucceeds runBuild sendNotifications captureStdoutStderr
captureStdoutStderr); evalFails
evalSucceeds
runBuild
sendNotifications
);
sub captureStdoutStderr { sub captureStdoutStderr {
@ -30,6 +34,19 @@ sub evalSucceeds {
return !$res; return !$res;
} }
sub evalFails {
my ($jobset) = @_;
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-eval-jobset", $jobset->project->name, $jobset->name));
$jobset->discard_changes; # refresh from DB
if (!$res) {
chomp $stdout; chomp $stderr;
print STDERR "Evaluation errors for jobset ".$jobset->project->name.":".$jobset->name.": \n".$jobset->errormsg."\n" if $jobset->errormsg;
print STDERR "STDOUT: $stdout\n" if $stdout ne "";
print STDERR "STDERR: $stderr\n" if $stderr ne "";
}
return !!$res;
}
sub runBuild { sub runBuild {
my ($build) = @_; my ($build) = @_;
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-queue-runner", "-vvvv", "--build-one", $build->id)); my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-queue-runner", "-vvvv", "--build-one", $build->id));

View file

@ -11,10 +11,23 @@ use Cwd qw(abs_path getcwd);
use CliRunners; use CliRunners;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = qw(test_context test_init hydra_setup write_file nrBuildsForJobset queuedBuildsForJobset our @EXPORT = qw(
nrQueuedBuildsForJobset createBaseJobset createJobsetWithOneInput captureStdoutStderr
evalSucceeds runBuild sendNotifications updateRepository createBaseJobset
captureStdoutStderr); createJobsetWithOneInput
evalFails
evalSucceeds
hydra_setup
nrBuildsForJobset
nrQueuedBuildsForJobset
queuedBuildsForJobset
runBuild
sendNotifications
test_context
test_init
updateRepository
write_file
);
# Set up the environment for running tests. # Set up the environment for running tests.
# #