From 797297b609457a1a85e18fb00b609df9d9436916 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Wed, 17 Aug 2022 01:09:43 -0600 Subject: [PATCH] integration-tests/flakes: Check pure evaluation --- integration-tests/flakes/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/integration-tests/flakes/default.nix b/integration-tests/flakes/default.nix index 0fa5b55..1cb3191 100644 --- a/integration-tests/flakes/default.nix +++ b/integration-tests/flakes/default.nix @@ -35,5 +35,14 @@ in tools.makeTest { deployer.succeed("cd /tmp/bundle && git add probe.nix") deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply --on @target --evaluator ${evaluator}") alpha.succeed("grep SECOND /etc/deployment") + + with subtest("Check that impure expressions are forbidden"): + deployer.succeed("sed -i 's|SECOND|''${builtins.readFile /etc/hostname}|g' /tmp/bundle/probe.nix") + logs = deployer.fail("cd /tmp/bundle && run-copy-stderr ${tools.colmenaExec} apply --on @target --evaluator ${evaluator}") + assert re.search(r"access to absolute path.*forbidden in pure eval mode", logs) + + with subtest("Check that impure expressions can be allowed with --impure"): + deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply --on @target --evaluator ${evaluator} --impure") + alpha.succeed("grep deployer /etc/deployment") ''; }