diff options
| author | tv <tv@krebsco.de> | 2026-11-13 20:38:10 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-13 22:02:18 +0100 |
| commit | 21c791e7c0b91ad984d1205d70398e426f7517d7 (patch) | |
| tree | 0ca0e160b05330948594b70a3c0145385488b87f | |
| parent | c4d5c98d460c4e53077ff00bc21c40631eee290d (diff) | |
tests: check what populate mustn't print
A phase's unexpected lists what populate is expected not to print,
whether it succeeds or not. notdir expects populate not to go on
locking after it fails to find the URL of a source drawn from, which
would lock the current directory, the login directory on a remote
target, copying it into the store.
| -rw-r--r-- | tests/scenarios.nix | 9 | ||||
| -rw-r--r-- | tests/vm.nix | 5 |
2 files changed, 12 insertions, 2 deletions
diff --git a/tests/scenarios.nix b/tests/scenarios.nix index ca2fd20..990a99b 100644 --- a/tests/scenarios.nix +++ b/tests/scenarios.nix @@ -109,12 +109,14 @@ let # evaluation fail. env sets environment variables for populate, as # arguments of env. interrupt ends populate after that many seconds, # which it's expected not to finish before. output lists what a - # succeeding populate is expected to print. expect.fail is what a + # succeeding populate is expected to print, and unexpected what populate + # is expected not to print, succeeding or not. expect.fail is what a # failing populate is expected to print, and expect.status, if given, # its exit status. phase = { sources, backup ? false, prune ? false, deploy ? null, targetPath ? path, env ? "", interrupt ? null, output ? [], + unexpected ? [], expect ? "success", control ? null, controlTargetPath ? null, check ? "", mutate ? null, checkDeployer ? null, mutateDeployer ? null, }: let @@ -149,7 +151,7 @@ let null else { populate = toString (command sources targetPath); - inherit env interrupt output; + inherit env interrupt output unexpected; expect = if expect == "success" then null else expect.fail; status = if expect == "success" then null else expect.status or null; # No phase gets around checking the canaries. @@ -1326,6 +1328,9 @@ assert !(krops.isLocalTarget (targets.remote "/")); p.pipe = "/fixtures/pipe"; }; expect.fail = "error: source p is not a directory"; + # Locking the flake with an empty URL would lock the current + # directory, the login directory on a remote target. + unexpected = [ "while fetching the input" ]; }]; }) (s "noinput-nested" { diff --git a/tests/vm.nix b/tests/vm.nix index 25a12a4..8a08819 100644 --- a/tests/vm.nix +++ b/tests/vm.nix @@ -158,6 +158,11 @@ in pkgs.testers.runNixOSTest { f"env HOME=/root {phase['env']} timeout {limit} {phase['populate']} </dev/null 2>&1", timeout=900, ) + for unexpected in phase["unexpected"]: + if unexpected in out: + raise Exception( + f"populate {i} prints {unexpected!r}:\n{out}" + ) if phase["interrupt"] is not None: if status != 124: raise Exception(f"populate {i} ends on its own:\n{out}") |
