about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/common.sh.in15
-rw-r--r--tests/init.sh6
-rw-r--r--tests/install-package.sh21
-rw-r--r--tests/nix-pull.sh10
-rw-r--r--tests/referrers.sh2
-rw-r--r--tests/user-envs.sh3
7 files changed, 45 insertions, 16 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d55d0690d6e1..b19802d87bfc 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,7 +3,7 @@ TESTS_ENVIRONMENT = $(SHELL) -e
 extra1 = $(shell pwd)/test-tmp/shared
 
 simple.sh: simple.nix
-dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh nix-build.sh: dependencies.nix
+dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh nix-build.sh install-package.sh: dependencies.nix
 locking.sh: locking.nix
 parallel.sh: parallel.nix
 build-hook.sh: build-hook.nix
@@ -19,7 +19,7 @@ TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
   locking.sh parallel.sh build-hook.sh substitutes.sh substitutes2.sh \
   fallback.sh nix-push.sh gc.sh gc-concurrent.sh verify.sh nix-pull.sh \
   referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
-  gc-runtime.sh
+  gc-runtime.sh install-package.sh
 
 XFAIL_TESTS =
 
diff --git a/tests/common.sh.in b/tests/common.sh.in
index 12162649e4b2..ca4c62d91493 100644
--- a/tests/common.sh.in
+++ b/tests/common.sh.in
@@ -47,3 +47,18 @@ export nixhash=$TOP/src/nix-hash/nix-hash
 readLink() {
     ls -l "$1" | sed 's/.*->\ //'
 }
+
+clearStore() {
+    echo "clearing store..."
+    chmod -R +w "$NIX_STORE_DIR"
+    rm -rf "$NIX_STORE_DIR"
+    mkdir "$NIX_STORE_DIR"
+    rm -rf "$NIX_DB_DIR"
+    mkdir "$NIX_DB_DIR"
+    $nixstore --init
+}
+
+clearProfiles() {
+    profiles="$NIX_STATE_DIR"/profiles
+    rm -f $profiles/*
+}
diff --git a/tests/init.sh b/tests/init.sh
index 73d15fd3ad20..160cb6b0a915 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -21,9 +21,12 @@ mkdir $NIX_BIN_DIR
 ln -s $nixstore $NIX_BIN_DIR/
 ln -s $nixinstantiate $NIX_BIN_DIR/
 ln -s $nixhash $NIX_BIN_DIR/
+ln -s $nixenv $NIX_BIN_DIR/
 ln -s $TOP/scripts/nix-prefetch-url $NIX_BIN_DIR/
 ln -s $TOP/scripts/nix-collect-garbage $NIX_BIN_DIR/
 ln -s $TOP/scripts/nix-build $NIX_BIN_DIR/
+ln -s $TOP/scripts/nix-install-package $NIX_BIN_DIR/
+ln -s $TOP/scripts/nix-pull $NIX_BIN_DIR/
 ln -s $bzip2_bin_test/bzip2 $NIX_BIN_DIR/
 ln -s $bzip2_bin_test/bunzip2 $NIX_BIN_DIR/
 mkdir $NIX_BIN_DIR/nix
@@ -52,8 +55,9 @@ for i in \
     $NIX_BIN_DIR/nix-prefetch-url \
     $NIX_BIN_DIR/nix-collect-garbage \
     $NIX_BIN_DIR/nix-build \
+    $NIX_BIN_DIR/nix-install-package \
+    $NIX_BIN_DIR/nix-pull \
     ; do
-    echo "$REAL_BIN_DIR"
     sed < $i > $i.tmp \
         -e "s^$REAL_BIN_DIR^$NIX_BIN_DIR^" \
         -e "s^$REAL_LIBEXEC_DIR^$NIX_LIBEXEC_DIR^" \
diff --git a/tests/install-package.sh b/tests/install-package.sh
new file mode 100644
index 000000000000..89d1d71f3286
--- /dev/null
+++ b/tests/install-package.sh
@@ -0,0 +1,21 @@
+source common.sh
+
+# Note: this test expects to be run *after* nix-push.sh.
+
+drvPath=$($nixinstantiate ./dependencies.nix)
+outPath=$($nixstore -q $drvPath)
+
+clearStore
+clearProfiles
+
+cat > $TEST_ROOT/foo.nixpkg <<EOF
+NIXPKG1 file://$TEST_ROOT/manifest simple $system $drvPath $outPath
+EOF
+
+$NIX_BIN_DIR/nix-install-package --non-interactive -p $profiles/test $TEST_ROOT/foo.nixpkg
+test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1
+
+clearProfiles
+
+$NIX_BIN_DIR/nix-install-package --non-interactive -p $profiles/test --url file://$TEST_ROOT/foo.nixpkg
+test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1
diff --git a/tests/nix-pull.sh b/tests/nix-pull.sh
index ddbe0f97f32b..a847510cebfe 100644
--- a/tests/nix-pull.sh
+++ b/tests/nix-pull.sh
@@ -1,15 +1,5 @@
 source common.sh
 
-clearStore () {
-    echo "clearing store..."
-    chmod -R +w "$NIX_STORE_DIR"
-    rm -rf "$NIX_STORE_DIR"
-    mkdir "$NIX_STORE_DIR"
-    rm -rf "$NIX_DB_DIR"
-    mkdir "$NIX_DB_DIR"
-    $nixstore --init
-}
-
 pullCache () {
     echo "pulling cache..."
     $PERL -w -I$TOP/scripts $TOP/scripts/nix-pull file://$TEST_ROOT/manifest
diff --git a/tests/referrers.sh b/tests/referrers.sh
index 2f8a1a465e1e..4d2aaab5a2b8 100644
--- a/tests/referrers.sh
+++ b/tests/referrers.sh
@@ -3,7 +3,7 @@ source common.sh
 # This takes way to long on Cygwin (because process creation is so slow...).
 if test "$system" = i686-cygwin; then exit 0; fi
 
-max=5000
+max=2500
 
 reference=$NIX_STORE_DIR/abcdef
 touch $reference
diff --git a/tests/user-envs.sh b/tests/user-envs.sh
index b1ba0ccc164d..614c30ceb34d 100644
--- a/tests/user-envs.sh
+++ b/tests/user-envs.sh
@@ -1,7 +1,6 @@
 source common.sh
 
-profiles="$NIX_STATE_DIR"/profiles
-rm -f $profiles/*
+clearProfiles
 
 # Query installed: should be empty.
 test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 0