diff options
Diffstat (limited to 'nixos/lib/testing.nix')
-rw-r--r-- | nixos/lib/testing.nix | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/nixos/lib/testing.nix b/nixos/lib/testing.nix index 42a0c60c7e19c..a13e76a695603 100644 --- a/nixos/lib/testing.nix +++ b/nixos/lib/testing.nix @@ -1,6 +1,13 @@ -{ system, minimal ? false, config ? {} }: - -with import ./build-vms.nix { inherit system minimal config; }; +{ system +, pkgs ? import ../.. { inherit system config; } + # Use a minimal kernel? +, minimal ? false + # Ignored +, config ? {} + # Modules to add to each VM +, extraConfigurations ? [] }: + +with import ./build-vms.nix { inherit system pkgs minimal extraConfigurations; }; with pkgs; let @@ -27,14 +34,14 @@ in rec { cp ${./test-driver/test-driver.pl} $out/bin/nixos-test-driver chmod u+x $out/bin/nixos-test-driver - libDir=$out/lib/perl5/site_perl + libDir=$out/${perl.libPrefix} mkdir -p $libDir cp ${./test-driver/Machine.pm} $libDir/Machine.pm cp ${./test-driver/Logger.pm} $libDir/Logger.pm wrapProgram $out/bin/nixos-test-driver \ --prefix PATH : "${lib.makeBinPath [ qemu_test vde2 netpbm coreutils ]}" \ - --prefix PERL5LIB : "${with perlPackages; lib.makePerlPath [ TermReadLineGnu XMLWriter IOTty FileSlurp ]}:$out/lib/perl5/site_perl" + --prefix PERL5LIB : "${with perlPackages; makePerlPath [ TermReadLineGnu XMLWriter IOTty FileSlurp ]}:$out/${perl.libPrefix}" ''; }; @@ -69,7 +76,7 @@ in rec { mkdir -p $out/coverage-data mv $i $out/coverage-data/$(dirname $(dirname $i)) done - ''; # */ + ''; }; @@ -109,7 +116,7 @@ in rec { vms = map (m: m.config.system.build.vm) (lib.attrValues nodes); - ocrProg = tesseract_4.override { enableLanguages = [ "eng" ]; }; + ocrProg = tesseract4.override { enableLanguages = [ "eng" ]; }; imagemagick_tiff = imagemagick_light.override { inherit libtiff; }; @@ -149,9 +156,23 @@ in rec { test = passMeta (runTests driver); report = passMeta (releaseTools.gcovReport { coverageRuns = [ test ]; }); - in (if makeCoverageReport then report else test) // { - inherit nodes driver test; - }; + nodeNames = builtins.attrNames nodes; + invalidNodeNames = lib.filter + (node: builtins.match "^[A-z_][A-z0-9_]+$" node == null) nodeNames; + + in + if lib.length invalidNodeNames > 0 then + throw '' + Cannot create machines out of (${lib.concatStringsSep ", " invalidNodeNames})! + All machines are referenced as perl variables in the testing framework which will break the + script when special characters are used. + + Please stick to alphanumeric chars and underscores as separation. + '' + else + (if makeCoverageReport then report else test) // { + inherit nodes driver test; + }; runInMachine = { drv |