nixos/tests: format the testing-python.nix file more consistenly

This commit is contained in:
Andreas Rammhold 2020-10-23 23:13:38 +02:00
parent 04100cd281
commit 61b09f552c
No known key found for this signature in database
GPG Key ID: E432E410B5E48C86
1 changed files with 105 additions and 97 deletions

View File

@ -3,11 +3,12 @@
# Use a minimal kernel?
, minimal ? false
# Ignored
, config ? {}
, config ? { }
# !!! See comment about args in lib/modules.nix
, specialArgs ? {}
, specialArgs ? { }
# Modules to add to each VM
, extraConfigurations ? [] }:
, extraConfigurations ? [ ]
}:
with pkgs;
@ -16,9 +17,11 @@ rec {
inherit pkgs;
mkTestDriver = let
mkTestDriver =
let
testDriverScript = ./test-driver/test-driver.py;
in qemu_pkg: stdenv.mkDerivation {
in
qemu_pkg: stdenv.mkDerivation {
name = "nixos-test-driver";
nativeBuildInputs = [ makeWrapper ];
@ -75,7 +78,6 @@ rec {
, skipLint ? false
, ...
} @ t:
let
# A standard store path to the vm monitor is built like this:
# /tmp/nix-build-vm-test-run-$name.drv-0/vm-state-machine/monitor
@ -108,7 +110,8 @@ rec {
testDriver = mkTestDriver (if qemu_pkg == null then pkgs.qemu_test else qemu_pkg);
nodes = build-vms.buildVirtualNetwork (
t.nodes or (if t ? machine then { machine = t.machine; } else { }));
t.nodes or (if t ? machine then { machine = t.machine; } else { })
);
vlans = map (m: m.config.virtualisation.vlans) (lib.attrValues nodes);
vms = map (m: m.config.system.build.vm) (lib.attrValues nodes);
@ -120,7 +123,8 @@ rec {
testDriverName = with builtins;
if testNameLen > maxTestNameLen then
abort ("The name of the test '${name}' must not be longer than ${toString maxTestNameLen} " +
abort
("The name of the test '${name}' must not be longer than ${toString maxTestNameLen} " +
"it's currently ${toString testNameLen} characters long.")
else
"nixos-test-driver-${name}";
@ -128,7 +132,8 @@ rec {
warn = if skipLint then lib.warn "Linting is disabled!" else lib.id;
in
warn (runCommand testDriverName
{ buildInputs = [ makeWrapper];
{
buildInputs = [ makeWrapper ];
testScript = testScript';
preferLocalBuild = true;
testName = name;
@ -162,7 +167,7 @@ rec {
''); # "
passMeta = drv: drv // lib.optionalAttrs (t ? meta) {
meta = (drv.meta or {}) // t.meta;
meta = (drv.meta or { }) // t.meta;
};
driver = mkDriver null;
@ -172,7 +177,8 @@ rec {
nodeNames = builtins.attrNames driver.nodes;
invalidNodeNames = lib.filter
(node: builtins.match "^[A-z_]([A-z0-9_]+)?$" node == null) nodeNames;
(node: builtins.match "^[A-z_]([A-z0-9_]+)?$" node == null)
nodeNames;
in
if lib.length invalidNodeNames > 0 then
@ -202,8 +208,10 @@ rec {
};
vm = build-vms.buildVM { }
[ machine
{ key = "run-in-machine";
[
machine
{
key = "run-in-machine";
networking.hostName = "client";
nix.readOnlyStore = false;
virtualisation.writableStore = false;
@ -253,13 +261,13 @@ rec {
lib.overrideDerivation drv (attrs: {
requiredSystemFeatures = [ "kvm" ];
builder = "${bash}/bin/sh";
args = ["-e" vmRunCommand];
args = [ "-e" vmRunCommand ];
origArgs = attrs.args;
origBuilder = attrs.builder;
});
runInMachineWithX = { require ? [], ... } @ args:
runInMachineWithX = { require ? [ ], ... } @ args:
let
client =
{ ... }: