Merge pull request #883 from cole-h/bare-yath-test

Trivially run tests with `yath test`
This commit is contained in:
Graham Christensen 2021-03-05 14:04:16 -05:00 committed by GitHub
commit de2f30f035
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 38 additions and 14 deletions

12
.gitignore vendored
View file

@ -25,16 +25,16 @@ Makefile.in
/doc/manual/images /doc/manual/images
/doc/manual/manual.html /doc/manual/manual.html
/doc/manual/manual.pdf /doc/manual/manual.pdf
/tests/.bzr* /t/.bzr*
/tests/.git* /t/.git*
/tests/.hg* /t/.hg*
/tests/nix /t/nix
/tests/data /t/data
/t/jobs/config.nix
/inst /inst
hydra-config.h hydra-config.h
hydra-config.h.in hydra-config.h.in
result result
tests/jobs/config.nix
outputs outputs
config config
stamp-h1 stamp-h1

2
.yath.rc Normal file
View file

@ -0,0 +1,2 @@
[test]
-I=rel(t/lib)

View file

@ -1,4 +1,4 @@
SUBDIRS = src tests doc SUBDIRS = src t doc
BOOTCLEAN_SUBDIRS = $(SUBDIRS) BOOTCLEAN_SUBDIRS = $(SUBDIRS)
DIST_SUBDIRS = $(SUBDIRS) DIST_SUBDIRS = $(SUBDIRS)
EXTRA_DIST = hydra-module.nix EXTRA_DIST = hydra-module.nix

View file

@ -70,8 +70,8 @@ AC_CONFIG_FILES([
src/lib/Makefile src/lib/Makefile
src/root/Makefile src/root/Makefile
src/script/Makefile src/script/Makefile
tests/Makefile t/Makefile
tests/jobs/config.nix t/jobs/config.nix
]) ])
AC_CONFIG_COMMANDS([executable-scripts], []) AC_CONFIG_COMMANDS([executable-scripts], [])

View file

@ -26,3 +26,21 @@ To build Hydra, you should then do:
You can run the Hydra web server in your source tree as follows: You can run the Hydra web server in your source tree as follows:
$ ./src/script/hydra-server $ ./src/script/hydra-server
You can run Hydra's test suite with the following:
[nix-shell]$ make check
[nix-shell]$ # to run as many tests as you have cores:
[nix-shell]$ make check YATH_JOB_COUNT=$NIX_BUILD_CORES
[nix-shell]$ # or run yath directly:
[nix-shell]$ yath test
[nix-shell]$ # to run as many tests as you have cores:
[nix-shell]$ yath test -j $NIX_BUILD_CORES
When using `yath` instead of `make check`, ensure you have run `make`
in the root of the repository at least once.
**Warning**: Currently, the tests can fail
if run with high parallelism [due to an issue in
`Test::PostgreSQL`](https://github.com/TJC/Test-postgresql/issues/40)
causing database ports to collide.

View file

@ -320,12 +320,16 @@
] ++ lib.optionals stdenv.isLinux [ rpm dpkg cdrkit ] ); ] ++ lib.optionals stdenv.isLinux [ rpm dpkg cdrkit ] );
shellHook = '' shellHook = ''
pushd $(git rev-parse --show-toplevel) >/dev/null
PATH=$(pwd)/src/hydra-evaluator:$(pwd)/src/script:$(pwd)/src/hydra-eval-jobs:$(pwd)/src/hydra-queue-runner:$PATH PATH=$(pwd)/src/hydra-evaluator:$(pwd)/src/script:$(pwd)/src/hydra-eval-jobs:$(pwd)/src/hydra-queue-runner:$PATH
PERL5LIB=$(pwd)/src/lib:$PERL5LIB PERL5LIB=$(pwd)/src/lib:$PERL5LIB
export HYDRA_HOME="src/" export HYDRA_HOME="$(pwd)/src/"
mkdir -p .hydra-data mkdir -p .hydra-data
export HYDRA_DATA="$(pwd)/.hydra-data" export HYDRA_DATA="$(pwd)/.hydra-data"
export HYDRA_DBI='dbi:Pg:dbname=hydra;host=localhost;port=64444' export HYDRA_DBI='dbi:Pg:dbname=hydra;host=localhost;port=64444'
popd >/dev/null
''; '';
preConfigure = "autoreconf -vfi"; preConfigure = "autoreconf -vfi";
@ -416,7 +420,7 @@
su - hydra -c "hydra-create-user root --email-address 'alice@example.org' --password foobar --role admin" su - hydra -c "hydra-create-user root --email-address 'alice@example.org' --password foobar --role admin"
mkdir /run/jobset /tmp/nix mkdir /run/jobset /tmp/nix
chmod 755 /run/jobset /tmp/nix chmod 755 /run/jobset /tmp/nix
cp ${./tests/api-test.nix} /run/jobset/default.nix cp ${./t/api-test.nix} /run/jobset/default.nix
chmod 644 /run/jobset/default.nix chmod 644 /run/jobset/default.nix
chown -R hydra /run/jobset /tmp/nix chown -R hydra /run/jobset /tmp/nix
""" """
@ -428,7 +432,7 @@
# Run the API tests. # Run the API tests.
machine.succeed( machine.succeed(
"su - hydra -c 'perl -I ${pkgs.hydra.perlDeps}/lib/perl5/site_perl ${./tests/api-test.pl}' >&2" "su - hydra -c 'perl -I ${pkgs.hydra.perlDeps}/lib/perl5/site_perl ${./t/api-test.pl}' >&2"
) )
''; '';
}; };
@ -455,7 +459,7 @@
su - hydra -c "hydra-create-user root --email-address 'alice@example.org' --password foobar --role admin" su - hydra -c "hydra-create-user root --email-address 'alice@example.org' --password foobar --role admin"
mkdir /run/jobset mkdir /run/jobset
chmod 755 /run/jobset chmod 755 /run/jobset
cp ${./tests/api-test.nix} /run/jobset/default.nix cp ${./t/api-test.nix} /run/jobset/default.nix
chmod 644 /run/jobset/default.nix chmod 644 /run/jobset/default.nix
chown -R hydra /run/jobset chown -R hydra /run/jobset
""" """
@ -477,7 +481,7 @@
# Setup the project and jobset # Setup the project and jobset
machine.succeed( machine.succeed(
"su - hydra -c 'perl -I ${pkgs.hydra.perlDeps}/lib/perl5/site_perl ${./tests/setup-notifications-jobset.pl}' >&2" "su - hydra -c 'perl -I ${pkgs.hydra.perlDeps}/lib/perl5/site_perl ${./t/setup-notifications-jobset.pl}' >&2"
) )
# Wait until hydra has build the job and # Wait until hydra has build the job and