about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/binary-cache.sh1
-rw-r--r--tests/binary-patching.nix18
-rw-r--r--tests/binary-patching.sh61
-rw-r--r--tests/common.sh.in6
-rw-r--r--tests/filter-source.nix2
-rw-r--r--tests/install-package.sh7
-rw-r--r--tests/local.mk8
-rw-r--r--tests/negative-caching.nix21
-rw-r--r--tests/negative-caching.sh22
-rw-r--r--tests/nix-channel.sh2
-rw-r--r--tests/nix-copy-closure.nix2
-rw-r--r--tests/nix-profile.sh5
-rw-r--r--tests/nix-pull.sh33
-rw-r--r--tests/remote-store.sh1
-rw-r--r--tests/restricted.sh18
-rw-r--r--tests/secure-drv-outputs.sh1
-rw-r--r--tests/tarball.sh12
17 files changed, 40 insertions, 180 deletions
diff --git a/tests/binary-cache.sh b/tests/binary-cache.sh
index c72d2defa5d0..5f88c595fdfb 100644
--- a/tests/binary-cache.sh
+++ b/tests/binary-cache.sh
@@ -1,7 +1,6 @@
 source common.sh
 
 clearStore
-clearManifests
 clearCache
 
 # Create the binary cache.
diff --git a/tests/binary-patching.nix b/tests/binary-patching.nix
deleted file mode 100644
index 8ed474d1f27f..000000000000
--- a/tests/binary-patching.nix
+++ /dev/null
@@ -1,18 +0,0 @@
-{ version }:
-
-with import ./config.nix;
-
-mkDerivation {
-  name = "foo-${toString version}";
-  builder = builtins.toFile "builder.sh"
-    ''
-      mkdir $out
-      (for ((n = 1; n < 100000; n++)); do echo $n; done) > $out/foo
-      ${if version != 1 then ''
-        (for ((n = 100000; n < 110000; n++)); do echo $n; done) >> $out/foo
-      '' else ""}
-      ${if version == 3 then ''
-        echo foobar >> $out/foo
-      '' else ""}
-    '';
-}
diff --git a/tests/binary-patching.sh b/tests/binary-patching.sh
deleted file mode 100644
index 188be109a0b5..000000000000
--- a/tests/binary-patching.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-source common.sh
-
-clearManifests
-
-mkdir -p $TEST_ROOT/cache2 $TEST_ROOT/patches
-
-RESULT=$TEST_ROOT/result
-
-# Build version 1 and 2 of the "foo" package.
-nix-push --dest $TEST_ROOT/cache2 --manifest --bzip2 \
-    $(nix-build -o $RESULT binary-patching.nix --arg version 1)
-mv $TEST_ROOT/cache2/MANIFEST $TEST_ROOT/manifest1 
-
-out2=$(nix-build -o $RESULT binary-patching.nix --arg version 2)
-nix-push --dest $TEST_ROOT/cache2 --manifest --bzip2 $out2
-mv $TEST_ROOT/cache2/MANIFEST $TEST_ROOT/manifest2
-    
-out3=$(nix-build -o $RESULT binary-patching.nix --arg version 3)
-nix-push --dest $TEST_ROOT/cache2 --manifest --bzip2 $out3
-mv $TEST_ROOT/cache2/MANIFEST $TEST_ROOT/manifest3
-
-rm $RESULT
-
-# Generate binary patches.
-nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \
-    file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest2
-
-nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \
-    file://$TEST_ROOT/patches $TEST_ROOT/manifest2 $TEST_ROOT/manifest3
-
-grep -q "patch {" $TEST_ROOT/manifest3
-
-# Get rid of versions 2 and 3.
-nix-store --delete $out2 $out3
-
-# Pull the manifest containing the patches.
-clearManifests
-nix-pull file://$TEST_ROOT/manifest3
-
-# Make sure that the download size prediction uses the patches rather
-# than the full download.
-nix-build -o $RESULT binary-patching.nix --arg version 3 --dry-run 2>&1 | grep -q "0.01 MiB"
-
-# Now rebuild it.  This should use the two patches generated above.
-rm -f $TEST_ROOT/var/log/nix/downloads
-nix-build -o $RESULT binary-patching.nix --arg version 3
-rm $RESULT
-[ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 2 ]
-
-# Add a patch from version 1 directly to version 3.
-nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \
-    file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest3
-
-# Rebuild version 3.  This should use the direct patch rather than the
-# sequence of two patches.
-nix-store --delete $out2 $out3
-clearManifests
-rm $TEST_ROOT/var/log/nix/downloads
-nix-pull file://$TEST_ROOT/manifest3
-nix-build -o $RESULT binary-patching.nix --arg version 3
-[ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 1 ]
diff --git a/tests/common.sh.in b/tests/common.sh.in
index eb9798a27b45..9e8962f1a60f 100644
--- a/tests/common.sh.in
+++ b/tests/common.sh.in
@@ -2,7 +2,7 @@ set -e
 
 datadir="@datadir@"
 
-export TEST_ROOT=$(pwd)/test-tmp
+export TEST_ROOT=${TMPDIR:-/tmp}/nix-test
 export NIX_STORE_DIR
 if ! NIX_STORE_DIR=$(readlink -f $TEST_ROOT/store 2> /dev/null); then
     # Maybe the build directory is symlinked.
@@ -54,10 +54,6 @@ clearStore() {
     rm -f "$NIX_STATE_DIR"/gcroots/ref
 }
 
-clearManifests() {
-    rm -f $NIX_STATE_DIR/manifests/*
-}
-
 clearCache() {
     rm -rf "$cacheDir"
 }
diff --git a/tests/filter-source.nix b/tests/filter-source.nix
index a620f0fda5c4..9071636394af 100644
--- a/tests/filter-source.nix
+++ b/tests/filter-source.nix
@@ -8,5 +8,5 @@ mkDerivation {
       type != "symlink"
       && baseNameOf path != "foo"
       && !((import ./lang/lib.nix).hasSuffix ".bak" (baseNameOf path));
-    in builtins.filterSource filter ./test-tmp/filterin;
+    in builtins.filterSource filter ((builtins.getEnv "TEST_ROOT") + "/filterin");
 }
diff --git a/tests/install-package.sh b/tests/install-package.sh
index 653dfee4c8d1..1916f72713e2 100644
--- a/tests/install-package.sh
+++ b/tests/install-package.sh
@@ -1,15 +1,14 @@
 source common.sh
 
-# Note: this test expects to be run *after* nix-push.sh.
-
 drvPath=$(nix-instantiate ./dependencies.nix)
-outPath=$(nix-store -q $drvPath)
+outPath=$(nix-store -r $drvPath)
+nix-push --dest $cacheDir $outPath
 
 clearStore
 clearProfiles
 
 cat > $TEST_ROOT/foo.nixpkg <<EOF
-NIXPKG1 file://$TEST_ROOT/cache/MANIFEST simple $system $drvPath $outPath
+NIXPKG1 - simple $system $drvPath $outPath file://$cacheDir
 EOF
 
 nix-install-package --non-interactive -p $profiles/test $TEST_ROOT/foo.nixpkg
diff --git a/tests/local.mk b/tests/local.mk
index 03f53b44c275..471821b270e8 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -4,14 +4,14 @@ check:
 nix_tests = \
   init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
   build-hook.sh substitutes.sh substitutes2.sh \
-  fallback.sh nix-push.sh gc.sh gc-concurrent.sh nix-pull.sh \
+  fallback.sh nix-push.sh gc.sh gc-concurrent.sh \
   referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
   gc-runtime.sh install-package.sh check-refs.sh filter-source.sh \
-  remote-store.sh export.sh export-graph.sh negative-caching.sh \
-  binary-patching.sh timeout.sh secure-drv-outputs.sh nix-channel.sh \
+  remote-store.sh export.sh export-graph.sh \
+  timeout.sh secure-drv-outputs.sh nix-channel.sh \
   multiple-outputs.sh import-derivation.sh fetchurl.sh optimise-store.sh \
   binary-cache.sh nix-profile.sh repair.sh dump-db.sh case-hack.sh \
-  check-reqs.sh pass-as-file.sh tarball.sh
+  check-reqs.sh pass-as-file.sh tarball.sh restricted.sh
   # parallel.sh
 
 install-tests += $(foreach x, $(nix_tests), tests/$(x))
diff --git a/tests/negative-caching.nix b/tests/negative-caching.nix
deleted file mode 100644
index 10df67a748fc..000000000000
--- a/tests/negative-caching.nix
+++ /dev/null
@@ -1,21 +0,0 @@
-with import ./config.nix;
-
-rec {
-
-  fail = mkDerivation {
-    name = "fail";
-    builder = builtins.toFile "builder.sh" "echo FAIL; exit 1";
-  };
-
-  succeed = mkDerivation {
-    name = "succeed";
-    builder = builtins.toFile "builder.sh" "echo SUCCEED; mkdir $out";
-  };
-
-  depOnFail = mkDerivation {
-    name = "dep-on-fail";
-    builder = builtins.toFile "builder.sh" "echo URGH; mkdir $out";
-    inputs = [fail succeed];
-  };
-
-}
diff --git a/tests/negative-caching.sh b/tests/negative-caching.sh
deleted file mode 100644
index 4217bc38e121..000000000000
--- a/tests/negative-caching.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-source common.sh
-
-clearStore
-
-set +e
-
-opts="--option build-cache-failure true --print-build-trace"
-
-# This build should fail, and the failure should be cached.
-log=$(nix-build $opts negative-caching.nix -A fail --no-out-link 2>&1) && fail "should fail"
-echo "$log" | grep -q "@ build-failed" || fail "no build-failed trace"
-
-# Do it again.  The build shouldn't be tried again.
-log=$(nix-build $opts negative-caching.nix -A fail --no-out-link 2>&1) && fail "should fail"
-echo "$log" | grep -q "FAIL" && fail "failed build not cached"
-echo "$log" | grep -q "@ build-failed .* cached" || fail "trace doesn't say cached"
-
-# Check that --keep-going works properly with cached failures.
-log=$(nix-build $opts --keep-going negative-caching.nix -A depOnFail --no-out-link 2>&1) && fail "should fail"
-echo "$log" | grep -q "FAIL" && fail "failed build not cached (2)"
-echo "$log" | grep -q "@ build-failed .* cached" || fail "trace doesn't say cached (2)"
-echo "$log" | grep -q "@ build-succeeded .*-succeed" || fail "didn't keep going"
diff --git a/tests/nix-channel.sh b/tests/nix-channel.sh
index b3442f6a8471..c538afd606be 100644
--- a/tests/nix-channel.sh
+++ b/tests/nix-channel.sh
@@ -1,7 +1,6 @@
 source common.sh
 
 clearProfiles
-clearManifests
 
 rm -f $TEST_ROOT/.nix-channels
 
@@ -45,7 +44,6 @@ nix-env -i dependencies
 
 
 clearProfiles
-clearManifests
 rm -f $TEST_ROOT/.nix-channels
 
 # Test updating from a tarball
diff --git a/tests/nix-copy-closure.nix b/tests/nix-copy-closure.nix
index 1418c65897d3..0e42cc0a3d72 100644
--- a/tests/nix-copy-closure.nix
+++ b/tests/nix-copy-closure.nix
@@ -4,7 +4,7 @@
 
 with import <nixpkgs/nixos/lib/testing.nix> { inherit system; };
 
-makeTest (let pkgA = pkgs.aterm; pkgB = pkgs.wget; pkgC = pkgs.hello; in {
+makeTest (let pkgA = pkgs.cowsay; pkgB = pkgs.wget; pkgC = pkgs.hello; in {
 
   nodes =
     { client =
diff --git a/tests/nix-profile.sh b/tests/nix-profile.sh
index 3586a7efc3c8..db1edd73eef0 100644
--- a/tests/nix-profile.sh
+++ b/tests/nix-profile.sh
@@ -1,10 +1,11 @@
 source common.sh
 
 home=$TEST_ROOT/home
+user=$(whoami)
 rm -rf $home
 mkdir -p $home
-HOME=$home $SHELL -e -c ". ../scripts/nix-profile.sh"
-HOME=$home $SHELL -e -c ". ../scripts/nix-profile.sh" # test idempotency
+HOME=$home USER=$user $SHELL -e -c ". ../scripts/nix-profile.sh"
+HOME=$home USER=$user $SHELL -e -c ". ../scripts/nix-profile.sh" # test idempotency
 
 [ -L $home/.nix-profile ]
 [ -e $home/.nix-channels ]
diff --git a/tests/nix-pull.sh b/tests/nix-pull.sh
deleted file mode 100644
index 87239948c481..000000000000
--- a/tests/nix-pull.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-source common.sh
-
-pullCache () {
-    echo "pulling cache..."
-    nix-pull file://$TEST_ROOT/cache/MANIFEST
-}
-
-clearStore
-clearManifests
-pullCache
-
-drvPath=$(nix-instantiate dependencies.nix)
-outPath=$(nix-store -q $drvPath)
-
-echo "building $outPath using substitutes..."
-nix-store -r $outPath
-
-cat $outPath/input-2/bar
-
-clearStore
-clearManifests
-pullCache
-
-echo "building $drvPath using substitutes..."
-nix-store -r $drvPath
-
-cat $outPath/input-2/bar
-
-# Check that the derivers are set properly.
-test $(nix-store -q --deriver "$outPath") = "$drvPath"
-nix-store -q --deriver $(readLink $outPath/input-2) | grep -q -- "-input-2.drv"
-
-clearManifests
diff --git a/tests/remote-store.sh b/tests/remote-store.sh
index 8312424f0ac6..b3908717a40e 100644
--- a/tests/remote-store.sh
+++ b/tests/remote-store.sh
@@ -1,7 +1,6 @@
 source common.sh
 
 clearStore
-clearManifests
 
 startDaemon
 
diff --git a/tests/restricted.sh b/tests/restricted.sh
new file mode 100644
index 000000000000..19096a9f8dd2
--- /dev/null
+++ b/tests/restricted.sh
@@ -0,0 +1,18 @@
+source common.sh
+
+clearStore
+
+nix-instantiate --option restrict-eval true --eval -E '1 + 2'
+(! nix-instantiate --option restrict-eval true ./simple.nix)
+nix-instantiate --option restrict-eval true ./simple.nix -I src=.
+nix-instantiate --option restrict-eval true ./simple.nix -I src1=simple.nix -I src2=config.nix -I src3=./simple.builder.sh
+
+(! nix-instantiate --option restrict-eval true --eval -E 'builtins.readFile ./simple.nix')
+nix-instantiate --option restrict-eval true --eval -E 'builtins.readFile ./simple.nix' -I src=..
+
+(! nix-instantiate --option restrict-eval true --eval -E 'builtins.readDir ../src/boost')
+nix-instantiate --option restrict-eval true --eval -E 'builtins.readDir ../src/boost' -I src=../src
+
+(! nix-instantiate --option restrict-eval true --eval -E 'let __nixPath = [ { prefix = "foo"; path = ./.; } ]; in <foo>')
+nix-instantiate --option restrict-eval true --eval -E 'let __nixPath = [ { prefix = "foo"; path = ./.; } ]; in <foo>' -I src=.
+
diff --git a/tests/secure-drv-outputs.sh b/tests/secure-drv-outputs.sh
index 4888123da910..50a9c4428d30 100644
--- a/tests/secure-drv-outputs.sh
+++ b/tests/secure-drv-outputs.sh
@@ -5,7 +5,6 @@
 source common.sh
 
 clearStore
-clearManifests
 
 startDaemon
 
diff --git a/tests/tarball.sh b/tests/tarball.sh
index cb5258a9e548..254c4b626b87 100644
--- a/tests/tarball.sh
+++ b/tests/tarball.sh
@@ -16,8 +16,14 @@ tarball=$TEST_ROOT/tarball.tar.xz
 
 nix-env -f file://$tarball -qa --out-path | grep -q dependencies
 
-nix-build file://$tarball
+nix-build -o $TMPDIR/result file://$tarball
 
-nix-build '<foo>' -I foo=file://$tarball
+nix-build -o $TMPDIR/result '<foo>' -I foo=file://$tarball
 
-nix-build -E "import (fetchTarball file://$tarball)"
+nix-build -o $TMPDIR/result -E "import (fetchTarball file://$tarball)"
+
+nix-instantiate --eval -E '1 + 2' -I fnord=file://no-such-tarball.tar.xz
+nix-instantiate --eval -E 'with <fnord/xyzzy>; 1 + 2' -I fnord=file://no-such-tarball.tar.xz
+(! nix-instantiate --eval -E '<fnord/xyzzy> 1' -I fnord=file://no-such-tarball.tar.xz)
+
+nix-instantiate --eval -E '<fnord/config.nix>' -I fnord=file://no-such-tarball.tar.xz -I fnord=.