mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/testing: restrict arguments to makeTest
Disallow passing arbitrary arguments to makeTest since they are not used; this can help catch mistakes.
This commit is contained in:
parent
9077b1a631
commit
79a234567c
2 changed files with 16 additions and 13 deletions
|
@ -146,26 +146,28 @@ rec {
|
||||||
|
|
||||||
# Make a full-blown test
|
# Make a full-blown test
|
||||||
makeTest =
|
makeTest =
|
||||||
{ testScript
|
{ machine ? null
|
||||||
|
, nodes ? {}
|
||||||
|
, testScript
|
||||||
, enableOCR ? false
|
, enableOCR ? false
|
||||||
, name ? "unnamed"
|
, name ? "unnamed"
|
||||||
# Skip linting (mainly intended for faster dev cycles)
|
# Skip linting (mainly intended for faster dev cycles)
|
||||||
, skipLint ? false
|
, skipLint ? false
|
||||||
, passthru ? {}
|
, passthru ? {}
|
||||||
|
, meta ? {}
|
||||||
, # For meta.position
|
, # For meta.position
|
||||||
pos ? # position used in error messages and for meta.position
|
pos ? # position used in error messages and for meta.position
|
||||||
(if t.meta.description or null != null
|
(if meta.description or null != null
|
||||||
then builtins.unsafeGetAttrPos "description" t.meta
|
then builtins.unsafeGetAttrPos "description" meta
|
||||||
else builtins.unsafeGetAttrPos "testScript" t)
|
else builtins.unsafeGetAttrPos "testScript" t)
|
||||||
, ...
|
|
||||||
} @ t:
|
} @ t:
|
||||||
let
|
let
|
||||||
nodes = qemu_pkg:
|
mkNodes = qemu_pkg:
|
||||||
let
|
let
|
||||||
testScript' =
|
testScript' =
|
||||||
# Call the test script with the computed nodes.
|
# Call the test script with the computed nodes.
|
||||||
if lib.isFunction testScript
|
if lib.isFunction testScript
|
||||||
then testScript { nodes = nodes qemu_pkg; }
|
then testScript { nodes = mkNodes qemu_pkg; }
|
||||||
else testScript;
|
else testScript;
|
||||||
|
|
||||||
build-vms = import ./build-vms.nix {
|
build-vms = import ./build-vms.nix {
|
||||||
|
@ -205,33 +207,34 @@ rec {
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
build-vms.buildVirtualNetwork (
|
build-vms.buildVirtualNetwork (
|
||||||
t.nodes or (if t ? machine then { machine = t.machine; } else { })
|
nodes // lib.optionalAttrs (machine != null) { inherit machine; }
|
||||||
);
|
);
|
||||||
|
|
||||||
driver = setupDriverForTest {
|
driver = setupDriverForTest {
|
||||||
inherit testScript enableOCR skipLint passthru;
|
inherit testScript enableOCR skipLint passthru;
|
||||||
testName = name;
|
testName = name;
|
||||||
qemu_pkg = pkgs.qemu_test;
|
qemu_pkg = pkgs.qemu_test;
|
||||||
nodes = nodes pkgs.qemu_test;
|
nodes = mkNodes pkgs.qemu_test;
|
||||||
};
|
};
|
||||||
driverInteractive = setupDriverForTest {
|
driverInteractive = setupDriverForTest {
|
||||||
inherit testScript enableOCR skipLint passthru;
|
inherit testScript enableOCR skipLint passthru;
|
||||||
testName = name;
|
testName = name;
|
||||||
qemu_pkg = pkgs.qemu;
|
qemu_pkg = pkgs.qemu;
|
||||||
nodes = nodes pkgs.qemu;
|
nodes = mkNodes pkgs.qemu;
|
||||||
interactive = true;
|
interactive = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
test =
|
test =
|
||||||
let
|
let
|
||||||
passMeta = drv: drv // lib.optionalAttrs (t ? meta) {
|
passMeta = drv: drv // lib.optionalAttrs (meta != {}) {
|
||||||
meta = (drv.meta or { }) // t.meta;
|
meta = (drv.meta or { }) // meta;
|
||||||
};
|
};
|
||||||
in passMeta (runTests { inherit driver pos driverInteractive; });
|
in passMeta (runTests { inherit driver pos driverInteractive; });
|
||||||
|
|
||||||
in
|
in
|
||||||
test // {
|
test // {
|
||||||
inherit test driver driverInteractive nodes;
|
inherit test driver driverInteractive;
|
||||||
|
inherit (driver) nodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
abortForFunction = functionName: abort ''The ${functionName} function was
|
abortForFunction = functionName: abort ''The ${functionName} function was
|
||||||
|
|
|
@ -33613,7 +33613,7 @@ with pkgs;
|
||||||
then import test
|
then import test
|
||||||
else test;
|
else test;
|
||||||
calledTest = if lib.isFunction loadedTest
|
calledTest = if lib.isFunction loadedTest
|
||||||
then callPackage loadedTest {}
|
then loadedTest { inherit pkgs lib; }
|
||||||
else loadedTest;
|
else loadedTest;
|
||||||
in
|
in
|
||||||
nixosTesting.makeTest calledTest;
|
nixosTesting.makeTest calledTest;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue