2022-12-23 17:41:52 +00:00
|
|
|
args@{
|
2019-09-06 07:25:22 +00:00
|
|
|
system,
|
|
|
|
pkgs ? import ../.. { inherit system config; },
|
|
|
|
# Use a minimal kernel?
|
|
|
|
minimal ? false,
|
|
|
|
# Ignored
|
2020-10-23 21:13:38 +00:00
|
|
|
config ? { },
|
2020-06-02 14:27:07 +00:00
|
|
|
# !!! See comment about args in lib/modules.nix
|
2022-12-23 17:41:52 +00:00
|
|
|
specialArgs ? throw "legacy - do not use, see error below",
|
2019-09-06 07:25:22 +00:00
|
|
|
# Modules to add to each VM
|
2020-10-23 21:13:38 +00:00
|
|
|
extraConfigurations ? [ ],
|
|
|
|
}:
|
2022-06-15 14:59:21 +00:00
|
|
|
let
|
|
|
|
nixos-lib = import ./default.nix { inherit (pkgs) lib; };
|
|
|
|
in
|
|
|
|
|
2022-12-23 17:41:52 +00:00
|
|
|
pkgs.lib.throwIf (args ? specialArgs)
|
|
|
|
''
|
|
|
|
testing-python.nix: `specialArgs` is not supported anymore. If you're looking
|
|
|
|
for the public interface to the NixOS test framework, use `runTest`, and
|
|
|
|
`node.specialArgs`.
|
|
|
|
See https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
|
|
|
|
and https://nixos.org/manual/nixos/unstable/index.html#test-opt-node.specialArgs
|
|
|
|
''
|
2020-05-14 12:34:50 +00:00
|
|
|
rec {
|
2019-09-06 07:25:22 +00:00
|
|
|
|
|
|
|
inherit pkgs;
|
|
|
|
|
2022-06-15 14:59:21 +00:00
|
|
|
evalTest =
|
|
|
|
module:
|
|
|
|
nixos-lib.evalTest {
|
|
|
|
imports = [
|
|
|
|
extraTestModule
|
|
|
|
module
|
|
|
|
];
|
|
|
|
};
|
|
|
|
runTest =
|
|
|
|
module:
|
|
|
|
nixos-lib.runTest {
|
|
|
|
imports = [
|
|
|
|
extraTestModule
|
|
|
|
module
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
extraTestModule = {
|
|
|
|
config = {
|
|
|
|
hostPkgs = pkgs;
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
2022-06-15 14:59:21 +00:00
|
|
|
};
|
2022-06-06 11:29:04 +00:00
|
|
|
|
2022-10-16 14:18:00 +00:00
|
|
|
# Make a full-blown test (legacy)
|
|
|
|
# For an official public interface to the tests, see
|
|
|
|
# https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
|
2019-09-06 07:25:22 +00:00
|
|
|
makeTest =
|
2022-03-18 00:20:21 +00:00
|
|
|
{
|
|
|
|
machine ? null,
|
|
|
|
nodes ? { },
|
|
|
|
testScript,
|
2019-09-06 07:25:22 +00:00
|
|
|
enableOCR ? false,
|
2023-10-23 00:11:11 +00:00
|
|
|
globalTimeout ? (60 * 60),
|
2019-09-06 07:25:22 +00:00
|
|
|
name ? "unnamed",
|
2022-06-03 11:37:04 +00:00
|
|
|
skipTypeCheck ? false,
|
2020-10-23 21:13:38 +00:00
|
|
|
# Skip linting (mainly intended for faster dev cycles)
|
2019-12-22 13:50:08 +00:00
|
|
|
skipLint ? false,
|
2020-12-09 11:59:39 +00:00
|
|
|
passthru ? { },
|
2022-03-18 00:20:21 +00:00
|
|
|
meta ? { },
|
2021-02-09 11:02:35 +00:00
|
|
|
# For meta.position
|
|
|
|
pos ? # position used in error messages and for meta.position
|
2022-03-18 00:20:21 +00:00
|
|
|
(
|
|
|
|
if meta.description or null != null then
|
|
|
|
builtins.unsafeGetAttrPos "description" meta
|
2021-02-09 11:02:35 +00:00
|
|
|
else
|
|
|
|
builtins.unsafeGetAttrPos "testScript" t
|
2024-12-10 19:26:33 +00:00
|
|
|
),
|
2022-05-23 09:08:13 +00:00
|
|
|
extraPythonPackages ? (_: [ ]),
|
2022-06-27 11:05:59 +00:00
|
|
|
interactive ? { },
|
2022-10-16 14:18:00 +00:00
|
|
|
}@t:
|
|
|
|
let
|
|
|
|
testConfig =
|
2022-09-29 08:32:31 +00:00
|
|
|
(evalTest {
|
2022-06-21 22:41:12 +00:00
|
|
|
imports = [
|
|
|
|
{
|
|
|
|
_file = "makeTest parameters";
|
|
|
|
config = t;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
defaults = {
|
|
|
|
_file = "makeTest: extraConfigurations";
|
|
|
|
imports = extraConfigurations;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
2022-09-29 08:32:31 +00:00
|
|
|
}).config;
|
2022-10-16 14:18:00 +00:00
|
|
|
in
|
|
|
|
testConfig.test # For nix-build
|
|
|
|
// testConfig; # For all-tests.nix
|
2019-09-06 07:25:22 +00:00
|
|
|
|
|
|
|
simpleTest = as: (makeTest as).test;
|
|
|
|
|
|
|
|
}
|