From 2240035e20a5f4e6c621720fd8cd9536b584b338 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 19 Feb 2021 17:04:19 -0500 Subject: [PATCH 1/3] Run tests with yath This will let us run tests in parallel, and creates a more Perl-standard test development experience. --- flake.nix | 2 ++ tests/Makefile.am | 2 +- tests/{evaluation-tests.pl => evaluation.t} | 0 tests/{ => lib}/Setup.pm | 0 tests/test.pl | 24 +++++++++++++++++++++ 5 files changed, 27 insertions(+), 1 deletion(-) rename tests/{evaluation-tests.pl => evaluation.t} (100%) rename tests/{ => lib}/Setup.pm (100%) create mode 100644 tests/test.pl diff --git a/flake.nix b/flake.nix index de4f29c5..08783bbc 100644 --- a/flake.nix +++ b/flake.nix @@ -126,6 +126,7 @@ EmailMIME EmailSender FileSlurp + FileWhich IOCompress IPCRun JSON @@ -145,6 +146,7 @@ TermSizeAny TestMore TextDiff + Test2Harness TextTable XMLSimple YAML diff --git a/tests/Makefile.am b/tests/Makefile.am index b0881bce..f5a92239 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -26,7 +26,7 @@ EXTRA_DIST = \ TESTS = \ set-up.pl \ - evaluation-tests.pl \ + test.pl \ tear-down.pl check_SCRIPTS = repos diff --git a/tests/evaluation-tests.pl b/tests/evaluation.t similarity index 100% rename from tests/evaluation-tests.pl rename to tests/evaluation.t diff --git a/tests/Setup.pm b/tests/lib/Setup.pm similarity index 100% rename from tests/Setup.pm rename to tests/lib/Setup.pm diff --git a/tests/test.pl b/tests/test.pl new file mode 100644 index 00000000..fc5b215a --- /dev/null +++ b/tests/test.pl @@ -0,0 +1,24 @@ +#!/usr/bin/env perl +# HARNESS-NO-PRELOAD +# HARNESS-CAT-LONG +# THIS IS A GENERATED YATH RUNNER TEST +use strict; +use warnings; + +use lib 'lib'; +BEGIN { + use File::Which qw(which); + $App::Yath::Script::SCRIPT = which 'yath'; +} +use App::Yath::Util qw/find_yath/; + +system($^X, find_yath(), '-D', 'test', '--default-search' => './', @ARGV); +my $exit = $?; + +# This makes sure it works with prove. +print "1..1\n"; +print "not " if $exit; +print "ok 1 - Passed tests when run by yath\n"; +print STDERR "yath exited with $exit" if $exit; + +exit($exit ? 255 : 0); From 45d9a22d7393c3f1f6ef60ea7c3abcbd3757e99c Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 19 Feb 2021 17:06:49 -0500 Subject: [PATCH 2/3] flake.nix: add perlPackages until they're available from nixpkgs These packages were added to Nixpkgs in https://github.com/NixOS/nixpkgs/pull/113702. --- flake.nix | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/flake.nix b/flake.nix index 08783bbc..198f9b8b 100644 --- a/flake.nix +++ b/flake.nix @@ -37,6 +37,83 @@ # Add LDAP dependencies that aren't currently found within nixpkgs. perlPackages = prev.perlPackages // { + Test2Harness = final.buildPerlPackage { + pname = "Test2-Harness"; + version = "1.000042"; + src = final.fetchurl { + url = "mirror://cpan/authors/id/E/EX/EXODIST/Test2-Harness-1.000042.tar.gz"; + sha256 = "aaf231a68af1a6ffd6a11188875fcf572e373e43c8285945227b9d687b43db2d"; + }; + + checkPhase = '' + patchShebangs ./t ./scripts/yath + ./scripts/yath test -j $NIX_BUILD_CORES + ''; + + propagatedBuildInputs = with final.perlPackages; [ DataUUID Importer LongJump ScopeGuard TermTable Test2PluginMemUsage Test2PluginUUID Test2Suite gotofile ]; + meta = { + description = "A new and improved test harness with better Test2 integration"; + license = with final.lib.licenses; [ artistic1 gpl1Plus ]; + }; + }; + + Test2PluginMemUsage = prev.perlPackages.buildPerlPackage { + pname = "Test2-Plugin-MemUsage"; + version = "0.002003"; + src = final.fetchurl { + url = "mirror://cpan/authors/id/E/EX/EXODIST/Test2-Plugin-MemUsage-0.002003.tar.gz"; + sha256 = "5e0662d5a823ae081641f5ce82843111eec1831cd31f883a6c6de54afdf87c25"; + }; + buildInputs = with final.perlPackages; [ Test2Suite ]; + meta = { + description = "Collect and display memory usage information"; + license = with final.lib.licenses; [ artistic1 gpl1Plus ]; + }; + }; + + Test2PluginUUID = prev.perlPackages.buildPerlPackage { + pname = "Test2-Plugin-UUID"; + version = "0.002001"; + src = final.fetchurl { + url = "mirror://cpan/authors/id/E/EX/EXODIST/Test2-Plugin-UUID-0.002001.tar.gz"; + sha256 = "4c6c8d484d7153d8779dc155a992b203095b5c5aa1cfb1ee8bcedcd0601878c9"; + }; + buildInputs = with final.perlPackages;[ Test2Suite ]; + propagatedBuildInputs = with final.perlPackages; [ DataUUID ]; + meta = { + description = "Use REAL UUIDs in Test2"; + license = with final.lib.licenses; [ artistic1 gpl1Plus ]; + }; + }; + + LongJump = final.buildPerlPackage { + pname = "Long-Jump"; + version = "0.000001"; + src = final.fetchurl { + url = "mirror://cpan/authors/id/E/EX/EXODIST/Long-Jump-0.000001.tar.gz"; + sha256 = "d5d6456d86992b559d8f66fc90960f919292cd3803c13403faac575762c77af4"; + }; + buildInputs = with final.perlPackages; [ Test2Suite ]; + meta = { + description = "Mechanism for returning to a specific point from a deeply nested stack"; + license = with final.lib.licenses; [ artistic1 gpl1Plus ]; + }; + }; + + gotofile = final.buildPerlPackage { + pname = "goto-file"; + version = "0.005"; + src = final.fetchurl { + url = "mirror://cpan/authors/id/E/EX/EXODIST/goto-file-0.005.tar.gz"; + sha256 = "c6cdd5ee4a6cdcbdbf314d92a4f9985dbcdf9e4258048cae76125c052aa31f77"; + }; + buildInputs = with final.perlPackages; [ Test2Suite ]; + meta = { + description = "Stop parsing the current file and move on to a different one"; + license = with final.lib.licenses; [ artistic1 gpl1Plus ]; + }; + }; + NetLDAPServer = prev.perlPackages.buildPerlPackage { pname = "Net-LDAP-Server"; version = "0.43"; From 3ebcaef1273eeece1ddf6a73417923540b1e653f Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 23 Feb 2021 17:25:29 -0500 Subject: [PATCH 3/3] README: update with instructions on running tests --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index cbc50650..6139edad 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,15 @@ conflicts with services that might be running on your host, hydra and postgress Note that this is only ever meant as an ad-hoc way of executing Hydra during development. Please make use of the NixOS module for actually running Hydra in production. +### Running Tests + +After making your changes, verify the test suite still passes. After following the steps in [Development Environment](#development-environment), run: + +``` +$ nix-shell +$ make check +``` + ### JSON API You can also interface with Hydra through a JSON API. The API is defined in [hydra-api.yaml](./hydra-api.yaml) and you can test and explore via the [swagger editor](https://editor.swagger.io/?url=https://raw.githubusercontent.com/NixOS/hydra/master/hydra-api.yaml)