add first evaluations tests

This commit is contained in:
Rob Vermaas 2011-03-16 13:18:12 +00:00
parent 8f35d03bca
commit 890a7867b4
8 changed files with 87 additions and 9 deletions

View file

@ -36,8 +36,8 @@ LIBS="-L$nix/lib/nix"
AC_CHECK_HEADER([store-api.hh], [:], AC_CHECK_HEADER([store-api.hh], [:],
[AC_MSG_ERROR([Nix headers not found; please install Nix or check the `--with-nix' option.])]) [AC_MSG_ERROR([Nix headers not found; please install Nix or check the `--with-nix' option.])])
AC_CHECK_LIB([expr], [_ZN3nix17parseExprFromFileERNS_9EvalStateESs], [:], #AC_CHECK_LIB([expr], [_ZN3nix17parseExprFromFileERNS_9EvalStateESs], [:],
[AC_MSG_ERROR([Nix library not found; please install Nix or check the `--with-nix' option.])]) # [AC_MSG_ERROR([Nix library not found; please install Nix or check the `--with-nix' option.])])
CPPFLAGS="$old_CPPFLAGS" CPPFLAGS="$old_CPPFLAGS"
LIBS="$old_LIBS" LIBS="$old_LIBS"
@ -67,6 +67,7 @@ AC_CONFIG_FILES([
tests/Makefile tests/Makefile
tests/query-all-tables.pl tests/query-all-tables.pl
tests/evaluation-tests.pl
]) ])
AC_OUTPUT AC_OUTPUT

View file

@ -1,19 +1,24 @@
TESTDIR=`pwd`
TESTS_ENVIRONMENT = \ TESTS_ENVIRONMENT = \
HYDRA_DBI="dbi:SQLite:db.sqlite" \ HYDRA_DBI="dbi:SQLite:db.sqlite" \
HYDRA_DATA="$(top_srcdir)/tests/data" \ HYDRA_DATA="$(TESTDIR)/data" \
HYDRA_HOME="$(topsrc_dir)/src" \ HYDRA_HOME="$(topsrc_dir)/src" \
NIX_REMOTE= \ NIX_REMOTE= \
NIX_STATE_DIR=$(top_srcdir)/tests/nix/var \ NIX_STATE_DIR="$(TESTDIR)/nix/var/nix" \
NIX_DATA_DIR=$(top_srcdir)/tests/nix/var \ NIX_STORE_DIR="$(TESTDIR)/nix/store" \
NIX_STORE_DIR=$(top_srcdir)/tests/nix/store \ NIX_LOG_DIR="$(TESTDIR)/nix/var/log/nix" \
PERL5LIB=$$PERL5LIB:$(top_srcdir)/src/lib \ PERL5LIB=$$PERL5LIB:$(top_srcdir)/src/lib \
perl -w perl -w
TESTS = \ TESTS = \
query-all-tables.pl query-all-tables.pl \
evaluation-tests.pl
$(TESTS) : db.sqlite dirs clean :
chmod -R a+w nix
rm -rf db.sqlite data nix
$(TESTS) : clean 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

14
tests/Setup.pm Normal file
View file

@ -0,0 +1,14 @@
package Setup;
use strict;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(hydra_setup);
sub hydra_setup {
my ($db) = @_;
$db->resultset('Users')->create({ username => "root", emailaddress => 'root@email.com', password => '' });
}
1;

31
tests/evaluation-tests.pl.in Executable file
View file

@ -0,0 +1,31 @@
#! @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;
use Test::Simple tests => 1;
hydra_setup($db);
my $res;
my $stdout;
my $stderr;
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"});
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");
print STDERR "\n$res\n";

23
tests/jobs/basic.nix Normal file
View file

@ -0,0 +1,23 @@
{ input }:
{
empty_dir =
derivation {
name = "empty-dir";
system = builtins.currentSystem;
builder = ./empty-dir-builder.sh;
};
fails =
derivation {
name = "fails";
system = builtins.currentSystem;
builder = ./fail.sh;
};
succeed_with_failed =
derivation {
name = "succeed-with-failed";
system = builtins.currentSystem;
builder = ./succeed-with-failed.sh;
};
}

View file

@ -0,0 +1 @@
mkdir $out

1
tests/jobs/fail.sh Normal file
View file

@ -0,0 +1 @@
exit 1

View file

@ -0,0 +1,2 @@
mkdir -p $out/nix-support/failed