2022-12-23 17:41:52 +00:00
|
|
|
args@
|
2019-09-06 08:25:22 +01:00
|
|
|
{ system
|
|
|
|
, pkgs ? import ../.. { inherit system config; }
|
|
|
|
# Use a minimal kernel?
|
|
|
|
, minimal ? false
|
|
|
|
# Ignored
|
2020-10-23 22:13:38 +01:00
|
|
|
, config ? { }
|
2020-06-02 15:27:07 +01: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 08:25:22 +01:00
|
|
|
# Modules to add to each VM
|
2020-10-23 22:13:38 +01:00
|
|
|
, extraConfigurations ? [ ]
|
|
|
|
}:
|
2022-06-15 15:59:21 +01: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 13:34:50 +01:00
|
|
|
rec {
|
2019-09-06 08:25:22 +01:00
|
|
|
|
|
|
|
inherit pkgs;
|
|
|
|
|
2022-06-15 15:59:21 +01:00
|
|
|
evalTest = module: nixos-lib.evalTest { imports = [ extraTestModule module ]; };
|
|
|
|
runTest = module: nixos-lib.runTest { imports = [ extraTestModule module ]; };
|
|
|
|
|
|
|
|
extraTestModule = {
|
|
|
|
config = {
|
|
|
|
hostPkgs = pkgs;
|
|
|
|
};
|
|
|
|
};
|
2022-06-06 12:29:04 +01:00
|
|
|
|
2022-10-16 15:18:00 +01: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 08:25:22 +01:00
|
|
|
makeTest =
|
2022-03-18 00:20:21 +00:00
|
|
|
{ machine ? null
|
|
|
|
, nodes ? {}
|
|
|
|
, testScript
|
2019-09-06 08:25:22 +01:00
|
|
|
, enableOCR ? false
|
2023-10-23 01:11:11 +01:00
|
|
|
, globalTimeout ? (60 * 60)
|
2019-09-06 08:25:22 +01:00
|
|
|
, name ? "unnamed"
|
2022-06-03 12:37:04 +01:00
|
|
|
, skipTypeCheck ? false
|
2020-10-23 22:13:38 +01: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)
|
2022-05-23 10:08:13 +01:00
|
|
|
, extraPythonPackages ? (_ : [])
|
2022-06-27 12:05:59 +01:00
|
|
|
, interactive ? {}
|
2022-10-16 15:18:00 +01:00
|
|
|
} @ t: let
|
|
|
|
testConfig =
|
2022-09-29 09:32:31 +01:00
|
|
|
(evalTest {
|
2022-06-21 23:41:12 +01:00
|
|
|
imports = [
|
|
|
|
{ _file = "makeTest parameters"; config = t; }
|
|
|
|
{
|
|
|
|
defaults = {
|
|
|
|
_file = "makeTest: extraConfigurations";
|
|
|
|
imports = extraConfigurations;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
2022-09-29 09:32:31 +01:00
|
|
|
}).config;
|
2022-10-16 15:18:00 +01:00
|
|
|
in
|
|
|
|
testConfig.test # For nix-build
|
|
|
|
// testConfig; # For all-tests.nix
|
2019-09-06 08:25:22 +01:00
|
|
|
|
|
|
|
simpleTest = as: (makeTest as).test;
|
|
|
|
|
|
|
|
}
|