diff options
Diffstat (limited to 'tests/default.nix')
| -rw-r--r-- | tests/default.nix | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/tests/default.nix b/tests/default.nix index f7ffa71..e940bd2 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -7,9 +7,11 @@ # -A exhaustive, or one with, e.g., nix-build tests -A exhaustive.flake. # The smoke test runs a few scenarios covering each source type and each kind # of target in a single VM test, for checking changes quickly; build it with -# nix-build tests -A smoke. jq runs populate's jq programs for flakes without -# VMs. -{ pkgs ? import ../pkgs {} }: +# nix-build tests -A smoke. nix-build tests -A only --argstr only REGEX runs +# the scenarios whose names match the regular expression REGEX in a single +# VM test, e.g. --argstr only 'lock-hooks-.*'. jq runs populate's jq +# programs for flakes without VMs. +{ pkgs ? import ../pkgs {}, only ? null }: let # HEAD of /fixtures/gitsrc, which fixtures.sh creates deterministically, @@ -72,15 +74,27 @@ let "deploy-local-buildTarget0-etcFlake0-flakefile" "deploy-sudo-allocateTTY" ]; + allScenarios = pkgs.lib.concatLists (builtins.attrValues scenarios); smokeScenarios = let - all = pkgs.lib.concatLists (builtins.attrValues scenarios); - selected = builtins.filter (scenario: builtins.elem scenario.name smokeNames) all; + selected = builtins.filter (scenario: builtins.elem scenario.name smokeNames) allScenarios; missing = pkgs.lib.subtractLists (map (scenario: scenario.name) selected) smokeNames; in if missing != [] then throw "tests: smoke test names missing scenarios: ${toString missing}" else selected; + # The scenarios whose names match the regular expression only. + onlyScenarios = let + selected = builtins.filter + (scenario: builtins.match only scenario.name != null) + allScenarios; + in + if only == null then + throw "tests: -A only needs --argstr only REGEX" + else if selected == [] then + throw "tests: no scenario's name matches ${builtins.toJSON only}" + else + selected; in testsOf false "" # Not built by nix-build tests either, which runs these scenarios anyway. @@ -90,6 +104,11 @@ in name = "smoke"; scenarios = smokeScenarios; }; + only.only = import ./vm.nix { + inherit pkgs gitHead; + name = "only"; + scenarios = onlyScenarios; + }; } # An attribute set without recurseForDerivations, so nix-build tests # doesn't build them. |
