forked from lix-project/hydra
add first evaluations tests
This commit is contained in:
parent
8f35d03bca
commit
890a7867b4
|
@ -36,8 +36,8 @@ LIBS="-L$nix/lib/nix"
|
|||
|
||||
AC_CHECK_HEADER([store-api.hh], [:],
|
||||
[AC_MSG_ERROR([Nix headers not found; please install Nix or check the `--with-nix' option.])])
|
||||
AC_CHECK_LIB([expr], [_ZN3nix17parseExprFromFileERNS_9EvalStateESs], [:],
|
||||
[AC_MSG_ERROR([Nix library not found; please install Nix or check the `--with-nix' option.])])
|
||||
#AC_CHECK_LIB([expr], [_ZN3nix17parseExprFromFileERNS_9EvalStateESs], [:],
|
||||
# [AC_MSG_ERROR([Nix library not found; please install Nix or check the `--with-nix' option.])])
|
||||
|
||||
CPPFLAGS="$old_CPPFLAGS"
|
||||
LIBS="$old_LIBS"
|
||||
|
@ -67,6 +67,7 @@ AC_CONFIG_FILES([
|
|||
|
||||
tests/Makefile
|
||||
tests/query-all-tables.pl
|
||||
tests/evaluation-tests.pl
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
||||
|
|
|
@ -1,19 +1,24 @@
|
|||
|
||||
TESTDIR=`pwd`
|
||||
TESTS_ENVIRONMENT = \
|
||||
HYDRA_DBI="dbi:SQLite:db.sqlite" \
|
||||
HYDRA_DATA="$(top_srcdir)/tests/data" \
|
||||
HYDRA_DATA="$(TESTDIR)/data" \
|
||||
HYDRA_HOME="$(topsrc_dir)/src" \
|
||||
NIX_REMOTE= \
|
||||
NIX_STATE_DIR=$(top_srcdir)/tests/nix/var \
|
||||
NIX_DATA_DIR=$(top_srcdir)/tests/nix/var \
|
||||
NIX_STORE_DIR=$(top_srcdir)/tests/nix/store \
|
||||
NIX_STATE_DIR="$(TESTDIR)/nix/var/nix" \
|
||||
NIX_STORE_DIR="$(TESTDIR)/nix/store" \
|
||||
NIX_LOG_DIR="$(TESTDIR)/nix/var/log/nix" \
|
||||
PERL5LIB=$$PERL5LIB:$(top_srcdir)/src/lib \
|
||||
perl -w
|
||||
|
||||
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
|
||||
sqlite3 db.sqlite < $(top_srcdir)/src/sql/hydra-sqlite.sql
|
||||
|
|
14
tests/Setup.pm
Normal file
14
tests/Setup.pm
Normal 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
31
tests/evaluation-tests.pl.in
Executable 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
23
tests/jobs/basic.nix
Normal 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;
|
||||
};
|
||||
}
|
1
tests/jobs/empty-dir-builder.sh
Normal file
1
tests/jobs/empty-dir-builder.sh
Normal file
|
@ -0,0 +1 @@
|
|||
mkdir $out
|
1
tests/jobs/fail.sh
Normal file
1
tests/jobs/fail.sh
Normal file
|
@ -0,0 +1 @@
|
|||
exit 1
|
2
tests/jobs/succeed-with-failed.sh
Normal file
2
tests/jobs/succeed-with-failed.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
mkdir -p $out/nix-support/failed
|
||||
|
Loading…
Reference in a new issue