diff options
| author | tv <tv@krebsco.de> | 2026-11-13 21:35:09 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-13 22:37:12 +0100 |
| commit | 54f84159efc90ce02196915c0005e54b846251ed (patch) | |
| tree | 750d3a738f5113bd4e794e52fb458f6fdb510efc | |
| parent | 80d5426c3a5ed621c650cd1928f1eb1cafdb1b7a (diff) | |
tests: run scenarios selected by name
nix-build tests -A only --argstr only REGEX runs the scenarios whose
names match the regular expression REGEX in a single VM test, like the
smoke test, e.g. --argstr only 'lock-hooks-.*' for lock-hooks on all
three kinds of targets.
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | tests/default.nix | 29 |
2 files changed, 25 insertions, 5 deletions
@@ -747,6 +747,7 @@ nix-build tests -A flake # the test for one source type nix-build tests -A exhaustive # all exhaustive tests nix-build tests -A exhaustive.git # the remaining combinations of one test nix-build tests -A rsync-3-5-0 # the scenarios depending on rsync's version +nix-build tests -A only --argstr only 'lock-hooks-.*' # scenarios by name nix-build tests -A jq # populate's programs for flakes, without VMs ``` 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. |
