aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bad.tar.xzbin0 -> 228 bytes
-rw-r--r--tests/local.mk3
-rw-r--r--tests/nix-build.sh3
-rw-r--r--tests/tarball.sh34
4 files changed, 27 insertions, 13 deletions
diff --git a/tests/bad.tar.xz b/tests/bad.tar.xz
new file mode 100644
index 000000000..250a5ad1a
--- /dev/null
+++ b/tests/bad.tar.xz
Binary files differ
diff --git a/tests/local.mk b/tests/local.mk
index 8c7c673d7..dab3a23b6 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -1,6 +1,3 @@
-check:
- @echo "Warning: Nix has no 'make check'. Please install Nix and run 'make installcheck' instead."
-
nix_tests = \
init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
gc.sh \
diff --git a/tests/nix-build.sh b/tests/nix-build.sh
index 395264863..0eb599608 100644
--- a/tests/nix-build.sh
+++ b/tests/nix-build.sh
@@ -23,3 +23,6 @@ outPath2=$(nix-build $(nix-instantiate dependencies.nix) --no-out-link)
outPath2=$(nix-build $(nix-instantiate dependencies.nix)!out --no-out-link)
[[ $outPath = $outPath2 ]]
+
+outPath2=$(nix-store -r $(nix-instantiate --indirect --add-root $TEST_ROOT/indirect dependencies.nix)!out)
+[[ $outPath = $outPath2 ]]
diff --git a/tests/tarball.sh b/tests/tarball.sh
index ba534c626..8adb8d72f 100644
--- a/tests/tarball.sh
+++ b/tests/tarball.sh
@@ -10,19 +10,33 @@ mkdir -p $tarroot
cp dependencies.nix $tarroot/default.nix
cp config.nix dependencies.builder*.sh $tarroot/
-tarball=$TEST_ROOT/tarball.tar.xz
-(cd $TEST_ROOT && tar c tarball) | xz > $tarball
+test_tarball() {
+ local ext="$1"
+ local compressor="$2"
-nix-env -f file://$tarball -qa --out-path | grep -q dependencies
+ tarball=$TEST_ROOT/tarball.tar$ext
+ (cd $TEST_ROOT && tar c tarball) | $compressor > $tarball
-nix-build -o $TEST_ROOT/result file://$tarball
+ nix-env -f file://$tarball -qa --out-path | grep -q dependencies
-nix-build -o $TEST_ROOT/result '<foo>' -I foo=file://$tarball
+ nix-build -o $TEST_ROOT/result file://$tarball
-nix-build -o $TEST_ROOT/result -E "import (fetchTarball file://$tarball)"
+ nix-build -o $TEST_ROOT/result '<foo>' -I foo=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-build -o $TEST_ROOT/result -E "import (fetchTarball file://$tarball)"
-nix-instantiate --eval -E '<fnord/config.nix>' -I fnord=file://no-such-tarball.tar.xz -I fnord=.
+ nix-instantiate --eval -E '1 + 2' -I fnord=file://no-such-tarball.tar$ext
+ nix-instantiate --eval -E 'with <fnord/xyzzy>; 1 + 2' -I fnord=file://no-such-tarball$ext
+ (! nix-instantiate --eval -E '<fnord/xyzzy> 1' -I fnord=file://no-such-tarball$ext)
+
+ nix-instantiate --eval -E '<fnord/config.nix>' -I fnord=file://no-such-tarball$ext -I fnord=.
+}
+
+test_tarball '' cat
+test_tarball .xz xz
+test_tarball .gz gzip
+
+rm -rf $TEST_ROOT/tmp
+mkdir -p $TEST_ROOT/tmp
+(! TMPDIR=$TEST_ROOT/tmp XDG_RUNTIME_DIR=$TEST_ROOT/tmp nix-env -f file://$(pwd)/bad.tar.xz -qa --out-path)
+(! [ -e $TEST_ROOT/tmp/bad ])