0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

Simplify running tests even further

Now you can just say:

  $ nix-build '<nixos/tests/login.nix>'

You can still get the driver script for interactive testing:

  $ nix-build '<nixos/tests/login.nix>' -A driver
  $ ./result/bin/nixos-test-driver
This commit is contained in:
Eelco Dolstra 2014-04-14 14:23:38 +02:00
parent abe218950c
commit 36c05d5e5b
2 changed files with 43 additions and 47 deletions

View file

@ -67,22 +67,19 @@ rec {
};
makeTest = testFun: complete (call testFun);
makeTests = testsFun: lib.mapAttrs (name: complete) (call testsFun);
makeTest =
{ testScript, makeCoverageReport ? false, ... } @ t:
apply = makeTest; # compatibility
call = f: f { inherit pkgs system; };
complete = { testScript, makeCoverageReport ? false, ... } @ t: t // rec {
let
nodes = buildVirtualNetwork (
t.nodes or (if t ? machine then { machine = t.machine; } else { }));
testScript =
testScript' =
# Call the test script with the computed nodes.
if builtins.isFunction t.testScript
then t.testScript { inherit nodes; }
else t.testScript;
if builtins.isFunction testScript
then testScript { inherit nodes; }
else testScript;
vlans = map (m: m.config.virtualisation.vlans) (lib.attrValues nodes);
@ -93,7 +90,7 @@ rec {
# VMs from the command line.
driver = runCommand "nixos-test-driver"
{ buildInputs = [ makeWrapper];
inherit testScript;
testScript = testScript';
preferLocalBuild = true;
}
''
@ -118,8 +115,7 @@ rec {
report = releaseTools.gcovReport { coverageRuns = [ test ]; };
result = if makeCoverageReport then report else test;
};
in (if makeCoverageReport then report else test) // { inherit driver test; };
runInMachine =
@ -149,7 +145,7 @@ rec {
exit $?
'';
testscript = ''
testScript = ''
startAll;
$client->waitForUnit("multi-user.target");
${preBuild}
@ -162,7 +158,7 @@ rec {
${coreutils}/bin/mkdir $out
${coreutils}/bin/mkdir -p vm-state-client/xchg
export > vm-state-client/xchg/saved-env
export tests='${testscript}'
export tests='${testScript}'
${testDriver}/bin/nixos-test-driver ${vm.config.system.build.vm}/bin/run-*-vm
''; # */

View file

@ -14,7 +14,7 @@ let
forAllSystems = pkgs.lib.genAttrs systems;
callTest = fn: args: forAllSystems (system: (import fn ({ inherit system; } // args)).result);
callTest = fn: args: forAllSystems (system: import fn ({ inherit system; } // args));
pkgs = import nixpkgs { system = "x86_64-linux"; };