diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index f554bb5c..aca8fb77 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -782,10 +782,10 @@ sub addBuildProducts { open LIST, "$outPath/nix-support/hydra-build-products" or die; while () { - /^([\w\-]+)\s+([\w\-]+)\s+(\S+)(\s+(\S+))?$/ or next; + /^([\w\-]+)\s+([\w\-]+)\s+("[^"]*"|\S+)(\s+(\S+))?$/ or next; my $type = $1; my $subtype = $2 eq "none" ? "" : $2; - my $path = File::Spec->canonpath($3); + my $path = File::Spec->canonpath((substr $3, 0, 1) eq "\"" ? substr $3, 1, -1 : $3); my $defaultPath = $5; # Ensure that the path exists and points into the Nix store. diff --git a/tests/evaluation-tests.pl b/tests/evaluation-tests.pl index 08e47b5c..2044c1be 100755 --- a/tests/evaluation-tests.pl +++ b/tests/evaluation-tests.pl @@ -7,7 +7,7 @@ use Setup; my $db = Hydra::Model::DB->new; -use Test::Simple tests => 60; +use Test::Simple tests => 68; hydra_setup($db); @@ -136,3 +136,25 @@ foreach my $scm ( @scminputs ) { ($loop, $updated) = updateRepository($scmName, $update, getcwd . "/$scmName-repo/"); } } + +# Test build products + +$jobset = createBaseJobset("build-products", "build-products.nix"); + +ok(evalSucceeds($jobset), "Evaluating jobs/build-products.nix should exit with return code 0"); +ok(nrQueuedBuildsForJobset($jobset) == 2 , "Evaluating jobs/build-products.nix should result in 2 builds"); + +for my $build (queuedBuildsForJobset($jobset)) { + ok(runBuild($build), "Build '".$build->job->name."' from jobs/build-products.nix should exit with code 0"); + my $newbuild = $db->resultset('Builds')->find($build->id); + ok($newbuild->finished == 1 && $newbuild->buildstatus == 0, "Build '".$build->job->name."' from jobs/build-products.nix should have buildstatus 0"); + + my $buildproducts = $db->resultset('BuildProducts')->search({ build => $build->id }); + my $buildproduct = $buildproducts->next; + + if($build->job->name eq "simple") { + ok($buildproduct->name eq "text.txt", "We should have text.txt, but found: ".$buildproduct->name."\n"); + } elsif ($build->job->name eq "with_spaces") { + ok($buildproduct->name eq "some text.txt", "We should have: \"some text.txt\", but found: ".$buildproduct->name."\n"); + } +}