forked from lix-project/hydra
add tests for scm inputs
This commit is contained in:
parent
98c8a86886
commit
369b2ef0aa
|
@ -7,6 +7,7 @@ TESTS_ENVIRONMENT = \
|
||||||
NIX_STORE_DIR="$(abs_builddir)/nix/store" \
|
NIX_STORE_DIR="$(abs_builddir)/nix/store" \
|
||||||
NIX_LOG_DIR="$(abs_builddir)/nix/var/log/nix" \
|
NIX_LOG_DIR="$(abs_builddir)/nix/var/log/nix" \
|
||||||
PERL5LIB="$(srcdir):$(top_srcdir)/src/lib:$$PERL5LIB" \
|
PERL5LIB="$(srcdir):$(top_srcdir)/src/lib:$$PERL5LIB" \
|
||||||
|
PATH=$(abs_top_srcdir)/src/script:$$PATH \
|
||||||
perl -w
|
perl -w
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
|
@ -20,14 +21,14 @@ TESTS = \
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
chmod -R a+w nix
|
chmod -R a+w nix
|
||||||
rm -rf db.sqlite data nix git-repo hg-repo svn-repo svn-checkout bzr-repo
|
rm -rf db.sqlite data nix git-repo hg-repo svn-repo svn-checkout svn-checkout-repo bzr-repo bzr-checkout-repo
|
||||||
|
|
||||||
$(TESTS) : db.sqlite dirs
|
$(TESTS) : db.sqlite dirs
|
||||||
|
|
||||||
db.sqlite : $(top_srcdir)/src/sql/hydra-sqlite.sql
|
db.sqlite : $(top_srcdir)/src/sql/hydra-sqlite.sql
|
||||||
sqlite3 db.sqlite < $(top_srcdir)/src/sql/hydra-sqlite.sql
|
sqlite3 db.sqlite < $(top_srcdir)/src/sql/hydra-sqlite.sql
|
||||||
|
|
||||||
dirs : git-repo hg-repo svn-repo bzr-repo
|
dirs : git-repo hg-repo svn-repo svn-checkout-repo bzr-repo bzr-checkout-repo
|
||||||
mkdir -p data
|
mkdir -p data
|
||||||
touch data/hydra.conf
|
touch data/hydra.conf
|
||||||
mkdir -p nix
|
mkdir -p nix
|
||||||
|
@ -58,3 +59,8 @@ bzr-repo :
|
||||||
bzr add bzr-repo/bzr-file
|
bzr add bzr-repo/bzr-file
|
||||||
bzr commit -m "add bzr-file" bzr-repo/bzr-file
|
bzr commit -m "add bzr-file" bzr-repo/bzr-file
|
||||||
|
|
||||||
|
svn-checkout-repo :
|
||||||
|
ln -s svn-repo svn-checkout-repo
|
||||||
|
|
||||||
|
bzr-checkout-repo :
|
||||||
|
ln -s bzr-repo bzr-checkout-repo
|
||||||
|
|
|
@ -10,7 +10,7 @@ use Setup;
|
||||||
|
|
||||||
my $db = openHydraDB;
|
my $db = openHydraDB;
|
||||||
|
|
||||||
use Test::Simple tests => 1;
|
use Test::Simple tests => 14;
|
||||||
|
|
||||||
hydra_setup($db);
|
hydra_setup($db);
|
||||||
|
|
||||||
|
@ -18,14 +18,47 @@ my $res;
|
||||||
my $stdout;
|
my $stdout;
|
||||||
my $stderr;
|
my $stderr;
|
||||||
|
|
||||||
|
my $jobsBaseUri = "file://".getcwd;
|
||||||
my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"});
|
my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"});
|
||||||
my $jobset = $project->jobsets->create({name => "basic", nixexprinput => "input", nixexprpath => "basic.nix", emailoverride => ""});
|
|
||||||
my $jobsetinput = $jobset->jobsetinputs->create({name => "input", type => "path"});
|
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});
|
||||||
|
}
|
||||||
|
|
||||||
|
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"});
|
||||||
my $jobsetinputals = $jobsetinput->jobsetinputalts->create({altnr => 0, value => getcwd."/jobs"});
|
my $jobsetinputals = $jobsetinput->jobsetinputalts->create({altnr => 0, value => getcwd."/jobs"});
|
||||||
|
|
||||||
($res, $stdout, $stderr) = captureStdoutStderr(60, ("../src/script/hydra_evaluator.pl", "tests", "basic"));
|
($res, $stdout, $stderr) = captureStdoutStderr(60, ("../src/script/hydra_evaluator.pl", "tests", "basic"));
|
||||||
|
|
||||||
ok($res, "Evaluating jobs/basic.nix should exit with return code 0");
|
ok($res, "Evaluating jobs/basic.nix should exit with return code 0");
|
||||||
|
ok( nrBuildsForJobset("tests", "basic") == 3 , "Evaluating jobs/basic.nix should result in 3 builds");
|
||||||
|
|
||||||
|
|
||||||
|
my @scminputs = ("svn", "svn-checkout", "git", "bzr", "bzr-checkout", "hg");
|
||||||
|
foreach my $scm (@scminputs) {
|
||||||
|
createJobsetWithOneSCMInput($scm, "$scm-input.nix", $scm, "$jobsBaseUri/$scm-repo");
|
||||||
|
ok(evalSucceeds("tests", $scm), "Evaluating jobs/$scm-input.nix should exit with return code 0.");
|
||||||
|
ok(nrBuildsForJobset("tests", $scm) == 1, "Evaluating jobs/$scm-input.nix should result in 1 build")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
{ input }:
|
|
||||||
{
|
{
|
||||||
empty_dir =
|
empty_dir =
|
||||||
derivation {
|
derivation {
|
||||||
|
|
9
tests/jobs/bzr-checkout-input.nix
Normal file
9
tests/jobs/bzr-checkout-input.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{ src }:
|
||||||
|
{
|
||||||
|
copy =
|
||||||
|
derivation {
|
||||||
|
name = "bzr-checkout-input";
|
||||||
|
system = builtins.currentSystem;
|
||||||
|
builder = ./scm-builder.sh;
|
||||||
|
};
|
||||||
|
}
|
9
tests/jobs/bzr-input.nix
Normal file
9
tests/jobs/bzr-input.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{ src }:
|
||||||
|
{
|
||||||
|
copy =
|
||||||
|
derivation {
|
||||||
|
name = "bzr-input";
|
||||||
|
system = builtins.currentSystem;
|
||||||
|
builder = ./scm-builder.sh;
|
||||||
|
};
|
||||||
|
}
|
9
tests/jobs/git-input.nix
Normal file
9
tests/jobs/git-input.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{ src }:
|
||||||
|
{
|
||||||
|
copy =
|
||||||
|
derivation {
|
||||||
|
name = "git-input";
|
||||||
|
system = builtins.currentSystem;
|
||||||
|
builder = ./scm-builder.sh;
|
||||||
|
};
|
||||||
|
}
|
9
tests/jobs/hg-input.nix
Normal file
9
tests/jobs/hg-input.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{ src }:
|
||||||
|
{
|
||||||
|
copy =
|
||||||
|
derivation {
|
||||||
|
name = "hg-input";
|
||||||
|
system = builtins.currentSystem;
|
||||||
|
builder = ./scm-builder.sh;
|
||||||
|
};
|
||||||
|
}
|
2
tests/jobs/scm-builder.sh
Normal file
2
tests/jobs/scm-builder.sh
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
mkdir $out
|
||||||
|
cp -v $src/* $out/
|
9
tests/jobs/svn-checkout-input.nix
Normal file
9
tests/jobs/svn-checkout-input.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{ src }:
|
||||||
|
{
|
||||||
|
copy =
|
||||||
|
derivation {
|
||||||
|
name = "bzr-checkout-input";
|
||||||
|
system = builtins.currentSystem;
|
||||||
|
builder = ./scm-builder.sh;
|
||||||
|
};
|
||||||
|
}
|
9
tests/jobs/svn-input.nix
Normal file
9
tests/jobs/svn-input.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{ src }:
|
||||||
|
{
|
||||||
|
copy =
|
||||||
|
derivation {
|
||||||
|
name = "svn-input";
|
||||||
|
system = builtins.currentSystem;
|
||||||
|
builder = ./scm-builder.sh;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue