mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 23:23:07 +00:00
d4d7550108
Since the debut of the test-driver, we didn't obtain a race timer with the test execution to ensure that tests doesn't run beyond a certain amount of time. This is particularly important when you are running into hanging tests which cannot be detected by current facilities (requires more pvpanic wiring up, QMP API stuff, etc.). Two easy examples: - Some QEMU tests may get stuck in some situation and run for more than 24 hours → we default to 1 hour max. - Some QEMU tests may panic in the wrong place, e.g. UEFI firmware or worse → end users can set a "reasonable" amount of time And then, we should let the retry logic retest them until they succeed and adjust their global timeouts. Of course, this does not help with the fact that the timeout may need to be a function of the actual busyness of the machine running the tests. This is only one step towards increased reliability.
79 lines
2.2 KiB
Nix
79 lines
2.2 KiB
Nix
args@
|
|
{ system
|
|
, pkgs ? import ../.. { inherit system config; }
|
|
# Use a minimal kernel?
|
|
, minimal ? false
|
|
# Ignored
|
|
, config ? { }
|
|
# !!! See comment about args in lib/modules.nix
|
|
, specialArgs ? throw "legacy - do not use, see error below"
|
|
# Modules to add to each VM
|
|
, extraConfigurations ? [ ]
|
|
}:
|
|
let
|
|
nixos-lib = import ./default.nix { inherit (pkgs) lib; };
|
|
in
|
|
|
|
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
|
|
''
|
|
rec {
|
|
|
|
inherit pkgs;
|
|
|
|
evalTest = module: nixos-lib.evalTest { imports = [ extraTestModule module ]; };
|
|
runTest = module: nixos-lib.runTest { imports = [ extraTestModule module ]; };
|
|
|
|
extraTestModule = {
|
|
config = {
|
|
hostPkgs = pkgs;
|
|
};
|
|
};
|
|
|
|
# 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
|
|
makeTest =
|
|
{ machine ? null
|
|
, nodes ? {}
|
|
, testScript
|
|
, enableOCR ? false
|
|
, globalTimeout ? (60 * 60)
|
|
, name ? "unnamed"
|
|
, skipTypeCheck ? false
|
|
# Skip linting (mainly intended for faster dev cycles)
|
|
, skipLint ? false
|
|
, passthru ? {}
|
|
, meta ? {}
|
|
, # For meta.position
|
|
pos ? # position used in error messages and for meta.position
|
|
(if meta.description or null != null
|
|
then builtins.unsafeGetAttrPos "description" meta
|
|
else builtins.unsafeGetAttrPos "testScript" t)
|
|
, extraPythonPackages ? (_ : [])
|
|
, interactive ? {}
|
|
} @ t: let
|
|
testConfig =
|
|
(evalTest {
|
|
imports = [
|
|
{ _file = "makeTest parameters"; config = t; }
|
|
{
|
|
defaults = {
|
|
_file = "makeTest: extraConfigurations";
|
|
imports = extraConfigurations;
|
|
};
|
|
}
|
|
];
|
|
}).config;
|
|
in
|
|
testConfig.test # For nix-build
|
|
// testConfig; # For all-tests.nix
|
|
|
|
simpleTest = as: (makeTest as).test;
|
|
|
|
}
|