Merge pull request #1025 from lukegb/hydra-better-errors
Produce better errors for failing jobsets
This commit is contained in:
16
t/jobs/broken-constituent.nix
Normal file
16
t/jobs/broken-constituent.nix
Normal file
@ -0,0 +1,16 @@
|
||||
with import ./config.nix;
|
||||
{
|
||||
broken = mkDerivation {
|
||||
name = "broken";
|
||||
_hydraAggregate = true;
|
||||
constituents = [
|
||||
"does-not-exist"
|
||||
"does-not-evaluate"
|
||||
];
|
||||
builder = ./fail.sh;
|
||||
};
|
||||
|
||||
# does-not-exist doesn't exist.
|
||||
|
||||
does-not-evaluate = assert false; {};
|
||||
}
|
@ -148,6 +148,7 @@ sub createJobsetWithOneInput {
|
||||
sub evalSucceeds {
|
||||
my ($jobset) = @_;
|
||||
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-eval-jobset", $jobset->project->name, $jobset->name));
|
||||
$jobset->discard_changes; # refresh from DB
|
||||
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 "";
|
||||
|
32
t/queue-runner/constituents.t
Normal file
32
t/queue-runner/constituents.t
Normal file
@ -0,0 +1,32 @@
|
||||
use feature 'unicode_strings';
|
||||
use strict;
|
||||
use warnings;
|
||||
use Setup;
|
||||
|
||||
my %ctx = test_init();
|
||||
|
||||
require Hydra::Schema;
|
||||
require Hydra::Model::DB;
|
||||
|
||||
use Test2::V0;
|
||||
|
||||
my $db = Hydra::Model::DB->new;
|
||||
hydra_setup($db);
|
||||
|
||||
my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"});
|
||||
|
||||
my $jobset = createBaseJobset("broken-constituent", "broken-constituent.nix", $ctx{jobsdir});
|
||||
|
||||
ok(evalSucceeds($jobset), "Evaluating jobs/broken-constituent.nix should exit with return code 0");
|
||||
is(nrQueuedBuildsForJobset($jobset), 0, "Evaluating jobs/broken-constituent.nix should not queue any builds");
|
||||
|
||||
like(
|
||||
$jobset->errormsg,
|
||||
qr/^does-not-exist: does not exist$/m,
|
||||
"Evaluating jobs/broken-constituent.nix should log an error for does-not-exist");
|
||||
like(
|
||||
$jobset->errormsg,
|
||||
qr/^does-not-evaluate: error: assertion 'false' failed$/m,
|
||||
"Evaluating jobs/broken-constituent.nix should log an error for does-not-evaluate");
|
||||
|
||||
done_testing;
|
Reference in New Issue
Block a user