2022-12-28 21:21:41 +00:00
|
|
|
args@
|
2020-04-24 23:36:52 +00:00
|
|
|
{ system
|
|
|
|
, pkgs ? import ../.. { inherit system config; }
|
|
|
|
# Use a minimal kernel?
|
|
|
|
, minimal ? false
|
|
|
|
# Ignored
|
2020-10-27 00:29:36 +00:00
|
|
|
, config ? { }
|
2020-09-25 04:45:31 +00:00
|
|
|
# !!! See comment about args in lib/modules.nix
|
2022-12-28 21:21:41 +00:00
|
|
|
, specialArgs ? throw "legacy - do not use, see error below"
|
2020-04-24 23:36:52 +00:00
|
|
|
# Modules to add to each VM
|
2020-10-27 00:29:36 +00:00
|
|
|
, extraConfigurations ? [ ]
|
|
|
|
}:
|
2022-09-30 11:47:45 +00:00
|
|
|
let
|
|
|
|
nixos-lib = import ./default.nix { inherit (pkgs) lib; };
|
|
|
|
in
|
|
|
|
|
2022-12-28 21:21:41 +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-15 21:57:56 +00:00
|
|
|
rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
inherit pkgs;
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
evalTest = module: nixos-lib.evalTest { imports = [ extraTestModule module ]; };
|
|
|
|
runTest = module: nixos-lib.runTest { imports = [ extraTestModule module ]; };
|
2020-12-25 13:55:36 +00:00
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
extraTestModule = {
|
|
|
|
config = {
|
|
|
|
hostPkgs = pkgs;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2022-09-30 11:47:45 +00:00
|
|
|
};
|
2021-06-28 23:13:55 +00:00
|
|
|
|
2022-10-21 18:38:19 +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
|
2020-04-24 23:36:52 +00:00
|
|
|
makeTest =
|
2022-03-30 09:31:56 +00:00
|
|
|
{ machine ? null
|
|
|
|
, nodes ? {}
|
|
|
|
, testScript
|
2020-04-24 23:36:52 +00:00
|
|
|
, enableOCR ? false
|
2023-11-16 04:20:00 +00:00
|
|
|
, globalTimeout ? (60 * 60)
|
2020-04-24 23:36:52 +00:00
|
|
|
, name ? "unnamed"
|
2022-06-16 17:23:12 +00:00
|
|
|
, skipTypeCheck ? false
|
2020-10-27 00:29:36 +00:00
|
|
|
# Skip linting (mainly intended for faster dev cycles)
|
2020-04-24 23:36:52 +00:00
|
|
|
, skipLint ? false
|
2020-12-25 13:55:36 +00:00
|
|
|
, passthru ? {}
|
2022-03-30 09:31:56 +00:00
|
|
|
, meta ? {}
|
2021-05-03 20:48:10 +00:00
|
|
|
, # For meta.position
|
|
|
|
pos ? # position used in error messages and for meta.position
|
2022-03-30 09:31:56 +00:00
|
|
|
(if meta.description or null != null
|
|
|
|
then builtins.unsafeGetAttrPos "description" meta
|
2021-05-03 20:48:10 +00:00
|
|
|
else builtins.unsafeGetAttrPos "testScript" t)
|
2022-06-16 17:23:12 +00:00
|
|
|
, extraPythonPackages ? (_ : [])
|
2022-09-30 11:47:45 +00:00
|
|
|
, interactive ? {}
|
2022-10-21 18:38:19 +00:00
|
|
|
} @ t: let
|
|
|
|
testConfig =
|
2022-09-30 11:47:45 +00:00
|
|
|
(evalTest {
|
|
|
|
imports = [
|
|
|
|
{ _file = "makeTest parameters"; config = t; }
|
|
|
|
{
|
|
|
|
defaults = {
|
|
|
|
_file = "makeTest: extraConfigurations";
|
|
|
|
imports = extraConfigurations;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}).config;
|
2022-10-21 18:38:19 +00:00
|
|
|
in
|
|
|
|
testConfig.test # For nix-build
|
|
|
|
// testConfig; # For all-tests.nix
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
simpleTest = as: (makeTest as).test;
|
|
|
|
|
|
|
|
}
|