aboutsummaryrefslogtreecommitdiffstats
path: root/tests/default.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-13 03:00:44 +0000
committertv <tv@krebsco.de>2026-11-13 03:00:44 +0000
commit3219e04ce4ff01b5f013e89d6245af9d28d73814 (patch)
treea9d29ecf8238e5a58fb8c85b4fab49facf2accf1 /tests/default.nix
parent8c78f328bf7a1a4b97f26e5f5bb25f2d8b462f24 (diff)
tests: move combinations no code path tells apart to exhaustive tests
The matrices cross every option of a source type with every other one, also where the code handling one never looks at the other. Scenarios for such combinations are exhaustive, and run in their own tests, which nix-build tests doesn't build, but nix-build tests -A exhaustive does: - file and git: drawing inputs combined with rsync's or Git's options, since drawing inputs happens after delivery. - flake: materialize combined with how the flake gets there, except for flakes in Git work trees and in subdirectories, since materializing copies what got delivered. - flake-input: materialize for inputs other than dep. - deploy: /etc/nixos/flake.nix combined with deploying a flake, since it only matters without one. - edge-cases: generated flakes where only delivery matters, and remote targets where drawing inputs alone matters, which happens on the target alike for every kind of target. That's 181 of 707 scenarios.
Diffstat (limited to 'tests/default.nix')
-rw-r--r--tests/default.nix25
1 files changed, 20 insertions, 5 deletions
diff --git a/tests/default.nix b/tests/default.nix
index 3dabee9..686b130 100644
--- a/tests/default.nix
+++ b/tests/default.nix
@@ -1,7 +1,10 @@
# NixOS VM tests for populate: one test per source type, one for features
# spanning sources, one for edge cases of flakes, one for staying inside the
-# target directory, and one for writeDeploy's arguments to nixos-rebuild. Build all with nix-build tests, or one with,
-# e.g., nix-build tests -A flake. jq runs populate's jq programs for flakes
+# target directory, and one for writeDeploy's arguments to nixos-rebuild.
+# Build all with nix-build tests, or one with, e.g., nix-build tests -A flake.
+# The exhaustive tests add the combinations of options that no code path
+# tells apart from the ones the others cover; build them with nix-build tests
+# -A exhaustive, or one with, e.g., nix-build tests -A exhaustive.flake. jq runs populate's jq programs for flakes
# without VMs.
{ pkgs ? import ../pkgs {} }:
@@ -32,10 +35,22 @@ let
};
scenarios = scenariosWith pkgs.rsync;
flakeJq = import ../pkgs/populate/flake-jq.nix;
+ # VM tests of those of the groups of scenarios that are, or aren't,
+ # exhaustive, named after the groups with prefix in front.
+ testsOf = exhaustive: prefix: pkgs.lib.mapAttrs
+ (name: scenarios: import ./vm.nix {
+ inherit pkgs gitHead scenarios;
+ name = prefix + name;
+ })
+ (pkgs.lib.filterAttrs (_: scenarios: scenarios != [])
+ (builtins.mapAttrs
+ (_: builtins.filter (scenario: scenario.exhaustive == exhaustive))
+ scenarios));
in
- builtins.mapAttrs
- (name: scenarios: import ./vm.nix { inherit pkgs name scenarios gitHead; })
- scenarios
+ testsOf false ""
+ # An attribute set without recurseForDerivations, so nix-build tests
+ # doesn't build them.
+ // { exhaustive = testsOf true "exhaustive-"; }
// pkgs.lib.mapAttrs'
(version: rsync: {
name = "rsync-${builtins.replaceStrings [ "." ] [ "-" ] version}";