2011-03-16 13:18:12 +00:00
|
|
|
#! @perl@ -w -I@nix@/libexec/nix
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Hydra::Schema;
|
|
|
|
use Hydra::Helper::Nix;
|
|
|
|
use Hydra::Helper::AddBuilds;
|
|
|
|
use Cwd;
|
|
|
|
|
|
|
|
use Setup;
|
|
|
|
|
|
|
|
my $db = openHydraDB;
|
|
|
|
|
2011-03-17 08:48:27 +00:00
|
|
|
use Test::Simple tests => 14;
|
2011-03-16 13:18:12 +00:00
|
|
|
|
|
|
|
hydra_setup($db);
|
|
|
|
|
|
|
|
my $res;
|
|
|
|
my $stdout;
|
|
|
|
my $stderr;
|
|
|
|
|
2011-03-17 08:48:27 +00:00
|
|
|
my $jobsBaseUri = "file://".getcwd;
|
2011-03-16 13:18:12 +00:00
|
|
|
my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"});
|
2011-03-17 08:48:27 +00:00
|
|
|
|
|
|
|
sub nrBuildsForJobset {
|
|
|
|
my ($project, $jobset) = @_;
|
|
|
|
return $db->resultset('Builds')->search({ project => $project, jobset => $jobset},{})->count ;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub createJobsetWithOneSCMInput {
|
|
|
|
my ($jobsetName, $nixexprpath, $type, $uri) = @_;
|
|
|
|
my $jobset = $project->jobsets->create({name => $jobsetName, nixexprinput => "jobs", nixexprpath => $nixexprpath, emailoverride => ""});
|
|
|
|
|
|
|
|
my $jobsetinput;
|
|
|
|
my $jobsetinputals;
|
|
|
|
|
|
|
|
$jobsetinput = $jobset->jobsetinputs->create({name => "jobs", type => "path"});
|
|
|
|
$jobsetinputals = $jobsetinput->jobsetinputalts->create({altnr => 0, value => getcwd."/jobs"});
|
|
|
|
|
|
|
|
$jobsetinput = $jobset->jobsetinputs->create({name => "src", type => $type});
|
|
|
|
$jobsetinputals = $jobsetinput->jobsetinputalts->create({altnr => 0, value => $uri});
|
2011-03-17 10:29:01 +00:00
|
|
|
|
|
|
|
return $jobset;
|
2011-03-17 08:48:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub evalSucceeds {
|
|
|
|
my ($project, $jobset) = @_;
|
|
|
|
return captureStdoutStderr(60, ("../src/script/hydra_evaluator.pl", $project, $jobset));
|
|
|
|
}
|
|
|
|
|
|
|
|
my $jobset = $project->jobsets->create({name => "basic", nixexprinput => "jobs", nixexprpath => "basic.nix", emailoverride => ""});
|
|
|
|
my $jobsetinput = $jobset->jobsetinputs->create({name => "jobs", type => "path"});
|
2011-03-16 13:18:12 +00:00
|
|
|
my $jobsetinputals = $jobsetinput->jobsetinputalts->create({altnr => 0, value => getcwd."/jobs"});
|
|
|
|
|
|
|
|
($res, $stdout, $stderr) = captureStdoutStderr(60, ("../src/script/hydra_evaluator.pl", "tests", "basic"));
|
|
|
|
|
|
|
|
ok($res, "Evaluating jobs/basic.nix should exit with return code 0");
|
2011-03-17 08:48:27 +00:00
|
|
|
ok( nrBuildsForJobset("tests", "basic") == 3 , "Evaluating jobs/basic.nix should result in 3 builds");
|
2011-03-16 13:18:12 +00:00
|
|
|
|
2011-03-16 13:34:17 +00:00
|
|
|
|
2011-03-17 08:48:27 +00:00
|
|
|
my @scminputs = ("svn", "svn-checkout", "git", "bzr", "bzr-checkout", "hg");
|
|
|
|
foreach my $scm (@scminputs) {
|
2011-03-17 10:29:01 +00:00
|
|
|
$jobset = createJobsetWithOneSCMInput($scm, "$scm-input.nix", $scm, "$jobsBaseUri/$scm-repo");
|
2011-03-17 08:48:27 +00:00
|
|
|
ok(evalSucceeds("tests", $scm), "Evaluating jobs/$scm-input.nix should exit with return code 0.");
|
2011-03-17 10:29:01 +00:00
|
|
|
print STDERR "Evaluation errors for jobset tests:$scm: \n".$jobset->errormsg."\n" if $jobset->errormsg;
|
|
|
|
|
|
|
|
ok(nrBuildsForJobset("tests", $scm) == 1, "Evaluating jobs/$scm-input.nix should result in 1 build");
|
2011-03-17 08:48:27 +00:00
|
|
|
}
|
2011-03-16 13:18:12 +00:00
|
|
|
|