1args@{
2 system,
3 pkgs ? import ../.. { inherit system config; },
4 # Use a minimal kernel?
5 minimal ? false,
6 # Ignored
7 config ? { },
8 # !!! See comment about args in lib/modules.nix
9 specialArgs ? throw "legacy - do not use, see error below",
10 # Modules to add to each VM
11 extraConfigurations ? [ ],
12}:
13let
14 nixos-lib = import ./default.nix { inherit (pkgs) lib; };
15in
16
17pkgs.lib.throwIf (args ? specialArgs)
18 ''
19 testing-python.nix: `specialArgs` is not supported anymore. If you're looking
20 for the public interface to the NixOS test framework, use `runTest`, and
21 `node.specialArgs`.
22 See https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
23 and https://nixos.org/manual/nixos/unstable/index.html#test-opt-node.specialArgs
24 ''
25 rec {
26
27 inherit pkgs;
28
29 evalTest =
30 module:
31 nixos-lib.evalTest {
32 imports = [
33 extraTestModule
34 module
35 ];
36 };
37 runTest =
38 module:
39 nixos-lib.runTest {
40 imports = [
41 extraTestModule
42 module
43 ];
44 };
45
46 extraTestModule = {
47 config = {
48 hostPkgs = pkgs;
49 };
50 };
51
52 # Make a full-blown test (legacy)
53 # For an official public interface to the tests, see
54 # https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
55 makeTest =
56 {
57 machine ? null,
58 nodes ? { },
59 testScript,
60 enableOCR ? false,
61 globalTimeout ? (60 * 60),
62 name ? "unnamed",
63 skipTypeCheck ? false,
64 # Skip linting (mainly intended for faster dev cycles)
65 skipLint ? false,
66 passthru ? { },
67 meta ? { },
68 # For meta.position
69 pos ? # position used in error messages and for meta.position
70 (
71 if meta.description or null != null then
72 builtins.unsafeGetAttrPos "description" meta
73 else
74 builtins.unsafeGetAttrPos "testScript" t
75 ),
76 extraPythonPackages ? (_: [ ]),
77 interactive ? { },
78 sshBackdoor ? { },
79 }@t:
80 let
81 testConfig =
82 (evalTest {
83 imports = [
84 {
85 _file = "makeTest parameters";
86 config = t;
87 }
88 {
89 defaults = {
90 _file = "makeTest: extraConfigurations";
91 imports = extraConfigurations;
92 };
93 }
94 ];
95 }).config;
96 in
97 testConfig.test # For nix-build
98 // testConfig; # For all-tests.nix
99
100 simpleTest = as: (makeTest as).test;
101
102 }