diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/default.nix | 13 | ||||
| -rw-r--r-- | tests/scenarios.nix | 23 |
2 files changed, 23 insertions, 13 deletions
diff --git a/tests/default.nix b/tests/default.nix index f7ffa71..189e573 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -8,8 +8,9 @@ # 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 {} }: +# VMs. implementation selects populate's implementation, e.g. nix-build +# tests --argstr implementation rust -A smoke. +{ pkgs ? import ../pkgs {}, implementation ? "shell" }: let # HEAD of /fixtures/gitsrc, which fixtures.sh creates deterministically, @@ -24,11 +25,13 @@ let (pkgs.callPackage ./rsync.nix {}); # The scenarios, with populate using rsync. - scenariosWith = rsync: import ./scenarios.nix { + scenariosWith = rsync: let + populate = pkgs.populate.override { inherit implementation rsync; }; + in import ./scenarios.nix { inherit (pkgs) lib; krops = import ../lib; - populate = pkgs.populate.override { inherit rsync; }; - inherit (pkgs.krops) writeDeploy; + inherit implementation populate; + inherit (pkgs.krops.override { inherit populate; }) writeDeploy; url = "http://deployer:8000"; gitUrl = "git://deployer/gitsrc.git"; remoteHost = "target"; diff --git a/tests/scenarios.nix b/tests/scenarios.nix index 2fc1bd7..cda72bd 100644 --- a/tests/scenarios.nix +++ b/tests/scenarios.nix @@ -28,6 +28,8 @@ gitFirst, # Version of rsync on the deploying machine. rsyncVersion, + # The implementation of populate, "shell" or "rust". + implementation, }: let @@ -228,6 +230,17 @@ let then options // { fetchOnTarget = true; } else options)); + # A phase copying flakes to a target using sudo, which isn't supported: + # the shell implementation refuses during evaluation, the Rust one when it + # runs, because only then it decides whether the target is local. + refuseCopyingWithSudo = + if implementation == "shell" then { + expect = "eval-error"; + control = withFetchOnTarget; + } else { + expect.fail = "copying flakes to targets with sudo is not supported"; + }; + in # The remote target must not count as local wherever this gets evaluated. @@ -431,10 +444,7 @@ assert !(krops.isLocalTarget (targets.remote "/")); inherit (flags) fetchOnTarget materialize; } // drawInputs flags.inputs { dep.follows = "alt"; }; } // optionalAttrs (flags.inputs != "none") alt; - } // (if copyingWithSudo flags ctx then { - expect = "eval-error"; - control = withFetchOnTarget; - } else { + } // (if copyingWithSudo flags ctx then refuseCopyingWithSudo else { check = if flags.kind == "subdir" then checkFlake { attr = "who"; expected = "sub"; subdir = true; materialized = flags.materialize; @@ -466,10 +476,7 @@ assert !(krops.isLocalTarget (targets.remote "/")); inherit (flags) fetchOnTarget materialize; } // drawInputs inputs { inner.follows = "alt"; }; } // optionalAttrs (inputs != "none") alt; - } // (if copyingWithSudo flags ctx then { - expect = "eval-error"; - control = withFetchOnTarget; - } else { + } // (if copyingWithSudo flags ctx then refuseCopyingWithSudo else { check = { dep = checkFlake { attr = "greeting"; |
