pkgs/test: fix silent failures when using runTests

This commit is contained in:
Julien Moutinho 2024-06-04 02:45:36 +02:00
parent fc6e6b8ffb
commit 2951758f51
2 changed files with 71 additions and 66 deletions

View File

@ -1,6 +1,3 @@
# to run these tests:
# nix-instantiate --eval --strict . -A tests.kernel-config
#
# make sure to use NON EXISTING kernel settings else they may conflict with
# common-config.nix
{ lib, pkgs }:
@ -37,8 +34,7 @@ let
{ NIXOS_FAKE_USB_DEBUG = option yes;}
];
in
runTests {
failures = runTests {
testEasy = {
expr = (getConfig { NIXOS_FAKE_USB_DEBUG = yes;}).NIXOS_FAKE_USB_DEBUG;
expected = { tristate = "y"; optional = false; freeform = null; };
@ -70,4 +66,8 @@ runTests {
expected = false;
};
}
};
in
lib.optional (failures != [])
(throw "The following kernel unit tests failed: ${lib.generators.toPretty {} failures}")

View File

@ -1,6 +1,7 @@
{ pkgs, lib, stdenv, ... }:
lib.runTests {
let
failures = lib.runTests {
# Merging two non-list definitions must still result in an error
# about a conflicting definition.
test-unitOption-merging-non-lists-conflict =
@ -34,4 +35,8 @@ lib.runTests {
expr = nixos.config.systemd.services.systemd-test-nixos.serviceConfig.StateDirectory;
expected = [ "foo" "bar" ];
};
}
};
in
lib.optional (failures != [])
(throw "The following systemd unit tests failed: ${lib.generators.toPretty {} failures}")