about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2017-11-30 09:16:49 +0100
committeraszlig <aszlig@nix.build>2017-11-30 13:22:09 +0100
commit2df7436fb32cf7ac871b1143a8270f8cfa16b7e1 (patch)
tree406a7a9cc5a8f5e5192d1f732bac95d05fa7b858 /tests
parent947cd56bd8872d8e19bc196d925a1e0886555ec3 (diff)
pkgs/sandbox: Add handling for XDG_CACHE_HOME
We only handle XDG_DATA_HOME and XDG_CONFIG_HOME, but we've missed
XDG_CACHE_HOME. While the latter is used very rarely as it doesn't
matter a lot if it ends up within a tmpfs anyway. However if the cache
directory gets pretty large we might run out of space.

Not only do we now have proper fallbacks but this also adds tests for
all of the XDG environment variables we're using.

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'tests')
-rw-r--r--tests/sandbox.nix18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/sandbox.nix b/tests/sandbox.nix
index 9c247da2..9a1b4a3a 100644
--- a/tests/sandbox.nix
+++ b/tests/sandbox.nix
@@ -15,15 +15,27 @@
     environment.systemPackages = let
       testProgram = pkgs.writeScriptBin "test-sandbox" ''
         #!${pkgs.stdenv.shell} -ex
+
+        # Should fail because we can't access the host's PATH
         ! echo foo | grep -qF foo
+
         export PATH=/run/baz-test-sandbox/bin
         echo foo > /home/foo/existing/bar
         test ! -d /home/foo/nonexisting
         /run/foo-test-sandbox/bin/hello
         echo aaa | /run/bar-test-sandbox/bin/sed -e 's/a/b/g'
+
+        echo XDG1 > /home/foo/.local/share/xdg/1
+        echo XDG2 > /home/foo/.config/xdg/2
+        echo XDG3 > /home/foo/.cache/xdg/3
       '';
     in lib.singleton (pkgs.vuizvui.buildSandbox testProgram {
-      paths.required = [ "/home/foo/existing" ];
+      paths.required = [
+        "/home/foo/existing"
+        "$XDG_DATA_HOME/xdg"
+        "$XDG_CONFIG_HOME/xdg"
+        "$XDG_CACHE_HOME/xdg"
+      ];
       paths.wanted = [ "/home/foo/nonexisting" ];
       paths.runtimeVars = [ "COLLECT_ME" ];
     });
@@ -37,5 +49,9 @@
     $machine->succeed('test -d /home/foo/existing');
     $machine->succeed('grep -qF foo /home/foo/existing/bar');
     $machine->fail('test -d /home/foo/nonexisting');
+
+    $machine->succeed('grep -qF XDG1 /home/foo/.local/share/xdg/1');
+    $machine->succeed('grep -qF XDG2 /home/foo/.config/xdg/2');
+    $machine->succeed('grep -qF XDG3 /home/foo/.cache/xdg/3');
   '';
 }