aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/build-dry.sh6
-rw-r--r--tests/build-remote.sh3
-rw-r--r--tests/check-refs.sh2
-rw-r--r--tests/check-reqs.sh2
-rw-r--r--tests/check.nix5
-rw-r--r--tests/check.sh23
-rw-r--r--tests/common.sh.in16
-rw-r--r--tests/dependencies.nix1
-rw-r--r--tests/fetchGit.sh4
-rw-r--r--tests/fetchurl.sh15
-rwxr-xr-xtests/function-trace.sh85
-rw-r--r--tests/gc-auto.sh70
-rw-r--r--tests/gc.sh2
-rw-r--r--tests/hash.sh12
-rw-r--r--tests/import-derivation.nix5
-rw-r--r--tests/init.sh1
-rwxr-xr-xtests/install-darwin.sh2
-rw-r--r--tests/lang/binary-databin0 -> 1024 bytes
-rw-r--r--tests/lang/eval-fail-hashfile-missing.nix5
-rw-r--r--tests/lang/eval-okay-context-introspection.exp1
-rw-r--r--tests/lang/eval-okay-context-introspection.nix24
-rw-r--r--tests/lang/eval-okay-float.exp1
-rw-r--r--tests/lang/eval-okay-float.nix6
-rw-r--r--tests/lang/eval-okay-fromTOML.exp2
-rw-r--r--tests/lang/eval-okay-fromTOML.nix56
-rw-r--r--tests/lang/eval-okay-hash.exp1
-rw-r--r--tests/lang/eval-okay-hashfile.exp1
-rw-r--r--tests/lang/eval-okay-hashfile.nix4
-rw-r--r--tests/lang/eval-okay-hashstring.exp1
-rw-r--r--tests/lang/eval-okay-hashstring.nix (renamed from tests/lang/eval-okay-hash.nix)0
-rw-r--r--tests/lang/eval-okay-types.exp2
-rw-r--r--tests/lang/eval-okay-types.nix2
-rw-r--r--tests/lang/parse-fail-mixed-nested-attrs1.nix4
-rw-r--r--tests/lang/parse-fail-mixed-nested-attrs2.nix4
-rw-r--r--tests/lang/parse-okay-dup-attrs-6.nix (renamed from tests/lang/parse-fail-dup-attrs-6.nix)0
-rw-r--r--tests/lang/parse-okay-mixed-nested-attrs-1.nix4
-rw-r--r--tests/lang/parse-okay-mixed-nested-attrs-2.nix4
-rw-r--r--tests/lang/parse-okay-mixed-nested-attrs-3.nix7
-rw-r--r--tests/linux-sandbox.sh3
-rw-r--r--tests/local.mk8
-rw-r--r--tests/nix-copy-ssh.sh2
-rw-r--r--tests/nix-shell.sh8
-rw-r--r--tests/placeholders.sh2
-rw-r--r--tests/post-hook.sh15
-rwxr-xr-xtests/push-to-store.sh4
-rw-r--r--tests/remote-builds.nix36
-rw-r--r--tests/signing.sh4
-rw-r--r--tests/timeout.sh12
48 files changed, 404 insertions, 73 deletions
diff --git a/tests/build-dry.sh b/tests/build-dry.sh
index 610e6070c..e72533e70 100644
--- a/tests/build-dry.sh
+++ b/tests/build-dry.sh
@@ -8,13 +8,13 @@ clearStore
clearCache
# Ensure this builds successfully first
-nix build -f dependencies.nix
+nix build --no-link -f dependencies.nix
clearStore
clearCache
# Try --dry-run using old command first
-nix-build dependencies.nix --dry-run 2>&1 | grep "will be built"
+nix-build --no-out-link dependencies.nix --dry-run 2>&1 | grep "will be built"
# Now new command:
nix build -f dependencies.nix --dry-run 2>&1 | grep "will be built"
@@ -27,7 +27,7 @@ clearCache
# Try --dry-run using new command first
nix build -f dependencies.nix --dry-run 2>&1 | grep "will be built"
# Now old command:
-nix-build dependencies.nix --dry-run 2>&1 | grep "will be built"
+nix-build --no-out-link dependencies.nix --dry-run 2>&1 | grep "will be built"
fi
###################################################
diff --git a/tests/build-remote.sh b/tests/build-remote.sh
index 9bca0f4a3..ddd68f327 100644
--- a/tests/build-remote.sh
+++ b/tests/build-remote.sh
@@ -11,7 +11,8 @@ rm -rf $TEST_ROOT/store0 $TEST_ROOT/store1
nix build -f build-hook.nix -o $TEST_ROOT/result --max-jobs 0 \
--sandbox-paths /nix/store --sandbox-build-dir /build-tmp \
- --builders "$TEST_ROOT/store0; $TEST_ROOT/store1 - - 1 1 foo"
+ --builders "$TEST_ROOT/store0; $TEST_ROOT/store1 - - 1 1 foo" \
+ --system-features foo
outPath=$TEST_ROOT/result
diff --git a/tests/check-refs.sh b/tests/check-refs.sh
index 34ee22cfc..16bbabc40 100644
--- a/tests/check-refs.sh
+++ b/tests/check-refs.sh
@@ -1,5 +1,7 @@
source common.sh
+clearStore
+
RESULT=$TEST_ROOT/result
dep=$(nix-build -o $RESULT check-refs.nix -A dep)
diff --git a/tests/check-reqs.sh b/tests/check-reqs.sh
index 77689215d..e9f65fc2a 100644
--- a/tests/check-reqs.sh
+++ b/tests/check-reqs.sh
@@ -1,5 +1,7 @@
source common.sh
+clearStore
+
RESULT=$TEST_ROOT/result
nix-build -o $RESULT check-reqs.nix -A test1
diff --git a/tests/check.nix b/tests/check.nix
index 08aac2fb0..56c82e565 100644
--- a/tests/check.nix
+++ b/tests/check.nix
@@ -10,6 +10,11 @@ with import ./config.nix;
'';
};
+ hashmismatch = import <nix/fetchurl.nix> {
+ url = "file://" + toString ./dummy;
+ sha256 = "0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73";
+ };
+
fetchurl = import <nix/fetchurl.nix> {
url = "file://" + toString ./lang/eval-okay-xml.exp.xml;
sha256 = "0kg4sla7ihm8ijr8cb3117fhl99zrc2bwy1jrngsfmkh8bav4m0v";
diff --git a/tests/check.sh b/tests/check.sh
index b05e40ffb..bc23a6634 100644
--- a/tests/check.sh
+++ b/tests/check.sh
@@ -6,14 +6,16 @@ nix-build dependencies.nix --no-out-link
nix-build dependencies.nix --no-out-link --check
nix-build check.nix -A nondeterministic --no-out-link
-(! nix-build check.nix -A nondeterministic --no-out-link --check 2> $TEST_ROOT/log)
+nix-build check.nix -A nondeterministic --no-out-link --check 2> $TEST_ROOT/log || status=$?
grep 'may not be deterministic' $TEST_ROOT/log
+[ "$status" = "104" ]
clearStore
nix-build dependencies.nix --no-out-link --repeat 3
-(! nix-build check.nix -A nondeterministic --no-out-link --repeat 1 2> $TEST_ROOT/log)
+nix-build check.nix -A nondeterministic --no-out-link --repeat 1 2> $TEST_ROOT/log || status=$?
+[ "$status" = "1" ]
grep 'differs from previous round' $TEST_ROOT/log
path=$(nix-build check.nix -A fetchurl --no-out-link --hashed-mirrors '')
@@ -23,10 +25,23 @@ echo foo > $path
chmod -w $path
nix-build check.nix -A fetchurl --no-out-link --check --hashed-mirrors ''
-
# Note: "check" doesn't repair anything, it just compares to the hash stored in the database.
[[ $(cat $path) = foo ]]
nix-build check.nix -A fetchurl --no-out-link --repair --hashed-mirrors ''
-
[[ $(cat $path) != foo ]]
+
+nix-build check.nix -A hashmismatch --no-out-link --hashed-mirrors '' || status=$?
+[ "$status" = "102" ]
+
+echo -n > ./dummy
+nix-build check.nix -A hashmismatch --no-out-link --hashed-mirrors ''
+echo 'Hello World' > ./dummy
+
+nix-build check.nix -A hashmismatch --no-out-link --check --hashed-mirrors '' || status=$?
+[ "$status" = "102" ]
+
+# Multiple failures with --keep-going
+nix-build check.nix -A nondeterministic --no-out-link
+nix-build check.nix -A nondeterministic -A hashmismatch --no-out-link --check --keep-going --hashed-mirrors '' || status=$?
+[ "$status" = "110" ]
diff --git a/tests/common.sh.in b/tests/common.sh.in
index 2ee2f589d..15d7b1ef9 100644
--- a/tests/common.sh.in
+++ b/tests/common.sh.in
@@ -16,6 +16,7 @@ if [[ -n $NIX_STORE ]]; then
export _NIX_TEST_NO_SANDBOX=1
fi
export _NIX_IN_TEST=$TEST_ROOT/shared
+export _NIX_TEST_NO_LSOF=1
export NIX_REMOTE=$NIX_REMOTE_
unset NIX_PATH
export TEST_HOME=$TEST_ROOT/test-home
@@ -85,16 +86,13 @@ killDaemon() {
trap "" EXIT
}
-canUseSandbox() {
- if [[ $(uname) != Linux ]]; then return 1; fi
-
- if [ ! -L /proc/self/ns/user ]; then
- echo "Kernel doesn't support user namespaces, skipping this test..."
- return 1
- fi
+if [[ $(uname) == Linux ]] && [[ -L /proc/self/ns/user ]] && unshare --user true; then
+ _canUseSandbox=1
+fi
- if ! unshare --user true ; then
- echo "Unprivileged user namespaces disabled by sysctl, skipping this test..."
+canUseSandbox() {
+ if [[ ! $_canUseSandbox ]]; then
+ echo "Sandboxing not supported, skipping this test..."
return 1
fi
diff --git a/tests/dependencies.nix b/tests/dependencies.nix
index 687237add..eca4b2964 100644
--- a/tests/dependencies.nix
+++ b/tests/dependencies.nix
@@ -17,6 +17,7 @@ let {
builder = ./dependencies.builder0.sh + "/FOOBAR/../.";
input1 = input1 + "/.";
input2 = "${input2}/.";
+ input1_drv = input1;
meta.description = "Random test package";
};
diff --git a/tests/fetchGit.sh b/tests/fetchGit.sh
index 530ac7bb8..4c46bdf04 100644
--- a/tests/fetchGit.sh
+++ b/tests/fetchGit.sh
@@ -9,7 +9,7 @@ clearStore
repo=$TEST_ROOT/git
-rm -rf $repo ${repo}-tmp $TEST_HOME/.cache/nix/git
+rm -rf $repo ${repo}-tmp $TEST_HOME/.cache/nix/gitv2
git init $repo
git -C $repo config user.email "foobar@example.com"
@@ -129,7 +129,7 @@ path5=$(nix eval --raw "(builtins.fetchGit { url = $repo; ref = \"dev\"; }).outP
# Nuke the cache
-rm -rf $TEST_HOME/.cache/nix/git
+rm -rf $TEST_HOME/.cache/nix/gitv2
# Try again, but without 'git' on PATH
NIX=$(command -v nix)
diff --git a/tests/fetchurl.sh b/tests/fetchurl.sh
index 9bbf044f7..7319ced2b 100644
--- a/tests/fetchurl.sh
+++ b/tests/fetchurl.sh
@@ -18,6 +18,17 @@ outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file://$(pwd)/fetchurl.sh
cmp $outPath fetchurl.sh
+# Now using an SRI hash.
+clearStore
+
+hash=$(nix hash-file ./fetchurl.sh)
+
+[[ $hash =~ ^sha256- ]]
+
+outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file://$(pwd)/fetchurl.sh --argstr hash $hash --no-out-link --hashed-mirrors '')
+
+cmp $outPath fetchurl.sh
+
# Test the hashed mirror feature.
clearStore
@@ -31,6 +42,10 @@ ln -s $(pwd)/fetchurl.sh $mirror/sha512/$hash32
outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file:///no-such-dir/fetchurl.sh --argstr sha512 $hash --no-out-link --hashed-mirrors "file://$mirror")
+# Test hashed mirrors with an SRI hash.
+nix-build '<nix/fetchurl.nix>' --argstr url file:///no-such-dir/fetchurl.sh --argstr hash $(nix to-sri --type sha512 $hash) \
+ --argstr name bla --no-out-link --hashed-mirrors "file://$mirror"
+
# Test unpacking a NAR.
rm -rf $TEST_ROOT/archive
mkdir -p $TEST_ROOT/archive
diff --git a/tests/function-trace.sh b/tests/function-trace.sh
new file mode 100755
index 000000000..182a4d5c2
--- /dev/null
+++ b/tests/function-trace.sh
@@ -0,0 +1,85 @@
+source common.sh
+
+set +x
+
+expect_trace() {
+ expr="$1"
+ expect="$2"
+ actual=$(
+ nix-instantiate \
+ --trace-function-calls \
+ --expr "$expr" 2>&1 \
+ | grep "function-trace" \
+ | sed -e 's/ [0-9]*$//'
+ );
+
+ echo -n "Tracing expression '$expr'"
+ set +e
+ msg=$(diff -swB \
+ <(echo "$expect") \
+ <(echo "$actual")
+ );
+ result=$?
+ set -e
+ if [ $result -eq 0 ]; then
+ echo " ok."
+ else
+ echo " failed. difference:"
+ echo "$msg"
+ return $result
+ fi
+}
+
+# failure inside a tryEval
+expect_trace 'builtins.tryEval (throw "example")' "
+function-trace entered undefined position at
+function-trace exited undefined position at
+function-trace entered (string):1:1 at
+function-trace entered (string):1:19 at
+function-trace exited (string):1:19 at
+function-trace exited (string):1:1 at
+"
+
+# Missing argument to a formal function
+expect_trace '({ x }: x) { }' "
+function-trace entered undefined position at
+function-trace exited undefined position at
+function-trace entered (string):1:1 at
+function-trace exited (string):1:1 at
+"
+
+# Too many arguments to a formal function
+expect_trace '({ x }: x) { x = "x"; y = "y"; }' "
+function-trace entered undefined position at
+function-trace exited undefined position at
+function-trace entered (string):1:1 at
+function-trace exited (string):1:1 at
+"
+
+# Not enough arguments to a lambda
+expect_trace '(x: y: x + y) 1' "
+function-trace entered undefined position at
+function-trace exited undefined position at
+function-trace entered (string):1:1 at
+function-trace exited (string):1:1 at
+"
+
+# Too many arguments to a lambda
+expect_trace '(x: x) 1 2' "
+function-trace entered undefined position at
+function-trace exited undefined position at
+function-trace entered (string):1:1 at
+function-trace exited (string):1:1 at
+function-trace entered (string):1:1 at
+function-trace exited (string):1:1 at
+"
+
+# Not a function
+expect_trace '1 2' "
+function-trace entered undefined position at
+function-trace exited undefined position at
+function-trace entered (string):1:1 at
+function-trace exited (string):1:1 at
+"
+
+set -e
diff --git a/tests/gc-auto.sh b/tests/gc-auto.sh
new file mode 100644
index 000000000..de1e2cfe4
--- /dev/null
+++ b/tests/gc-auto.sh
@@ -0,0 +1,70 @@
+source common.sh
+
+clearStore
+
+garbage1=$(nix add-to-store --name garbage1 ./nar-access.sh)
+garbage2=$(nix add-to-store --name garbage2 ./nar-access.sh)
+garbage3=$(nix add-to-store --name garbage3 ./nar-access.sh)
+
+ls -l $garbage3
+POSIXLY_CORRECT=1 du $garbage3
+
+fake_free=$TEST_ROOT/fake-free
+export _NIX_TEST_FREE_SPACE_FILE=$fake_free
+echo 1100 > $fake_free
+
+expr=$(cat <<EOF
+with import ./config.nix; mkDerivation {
+ name = "gc-A";
+ buildCommand = ''
+ set -x
+ [[ \$(ls \$NIX_STORE/*-garbage? | wc -l) = 3 ]]
+ mkdir \$out
+ echo foo > \$out/bar
+ echo 1...
+ sleep 2
+ echo 200 > ${fake_free}.tmp1
+ mv ${fake_free}.tmp1 $fake_free
+ echo 2...
+ sleep 2
+ echo 3...
+ sleep 2
+ echo 4...
+ [[ \$(ls \$NIX_STORE/*-garbage? | wc -l) = 1 ]]
+ '';
+}
+EOF
+)
+
+expr2=$(cat <<EOF
+with import ./config.nix; mkDerivation {
+ name = "gc-B";
+ buildCommand = ''
+ set -x
+ mkdir \$out
+ echo foo > \$out/bar
+ echo 1...
+ sleep 2
+ echo 200 > ${fake_free}.tmp2
+ mv ${fake_free}.tmp2 $fake_free
+ echo 2...
+ sleep 2
+ echo 3...
+ sleep 2
+ echo 4...
+ '';
+}
+EOF
+)
+
+nix build -v -o $TEST_ROOT/result-A -L "($expr)" \
+ --min-free 1000 --max-free 2000 --min-free-check-interval 1 &
+pid=$!
+
+nix build -v -o $TEST_ROOT/result-B -L "($expr2)" \
+ --min-free 1000 --max-free 2000 --min-free-check-interval 1
+
+wait "$pid"
+
+[[ foo = $(cat $TEST_ROOT/result-A/bar) ]]
+[[ foo = $(cat $TEST_ROOT/result-B/bar) ]]
diff --git a/tests/gc.sh b/tests/gc.sh
index 0adb05bf1..8b4f8d282 100644
--- a/tests/gc.sh
+++ b/tests/gc.sh
@@ -7,7 +7,7 @@ outPath=$(nix-store -rvv "$drvPath")
rm -f "$NIX_STATE_DIR"/gcroots/foo
ln -sf $outPath "$NIX_STATE_DIR"/gcroots/foo
-[ "$(nix-store -q --roots $outPath)" = "$NIX_STATE_DIR"/gcroots/foo ]
+[ "$(nix-store -q --roots $outPath)" = "$NIX_STATE_DIR/gcroots/foo -> $outPath" ]
nix-store --gc --print-roots | grep $outPath
nix-store --gc --print-live | grep $outPath
diff --git a/tests/hash.sh b/tests/hash.sh
index 9f234bc63..4cfc97901 100644
--- a/tests/hash.sh
+++ b/tests/hash.sh
@@ -2,7 +2,7 @@ source common.sh
try () {
printf "%s" "$2" > $TEST_ROOT/vector
- hash=$(nix-hash $EXTRA --flat --type "$1" $TEST_ROOT/vector)
+ hash=$(nix hash-file --base16 $EXTRA --type "$1" $TEST_ROOT/vector)
if test "$hash" != "$3"; then
echo "hash $1, expected $3, got $hash"
exit 1
@@ -33,6 +33,12 @@ EXTRA=--base32
try sha256 "abc" "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s"
EXTRA=
+EXTRA=--sri
+try sha512 "" "sha512-z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg/SpIdNs6c5H0NE8XYXysP+DGNKHfuwvY7kxvUdBeoGlODJ6+SfaPg=="
+try sha512 "abc" "sha512-3a81oZNherrMQXNJriBBMRLm+k6JqX6iCp7u5ktV05ohkpkqJ0/BqDa6PCOj/uu9RU1EI2Q86A4qmslPpUyknw=="
+try sha512 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" "sha512-IEqPxt2oLwoM7XvrjgikFlfBbvRosiioJ5vjMacDwzWW/RXBOxsH+aodO+pXeJygMa2Fx6cd1wNU7GMSOMo0RQ=="
+try sha256 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" "sha256-JI1qYdIGOLjlwCaTDD5gOaM85Flk/yFn9uzt1BnbBsE="
+
try2 () {
hash=$(nix-hash --type "$1" $TEST_ROOT/hash-path)
if test "$hash" != "$2"; then
@@ -65,12 +71,16 @@ try2 md5 "f78b733a68f5edbdf9413899339eaa4a"
try3() {
h64=$(nix to-base64 --type "$1" "$2")
[ "$h64" = "$4" ]
+ sri=$(nix to-sri --type "$1" "$2")
+ [ "$sri" = "$1-$4" ]
h32=$(nix-hash --type "$1" --to-base32 "$2")
[ "$h32" = "$3" ]
h16=$(nix-hash --type "$1" --to-base16 "$h32")
[ "$h16" = "$2" ]
h16=$(nix to-base16 --type "$1" "$h64")
[ "$h16" = "$2" ]
+ h16=$(nix to-base16 "$sri")
+ [ "$h16" = "$2" ]
}
try3 sha1 "800d59cfcd3c05e900cb4e214be48f6b886a08df" "vw46m23bizj4n8afrc0fj19wrp7mj3c0" "gA1Zz808BekAy04hS+SPa4hqCN8="
try3 sha256 "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s" "ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0="
diff --git a/tests/import-derivation.nix b/tests/import-derivation.nix
index 91adcd288..44fa9a45d 100644
--- a/tests/import-derivation.nix
+++ b/tests/import-derivation.nix
@@ -10,7 +10,10 @@ let
'';
};
- value = import bar;
+ value =
+ # Test that pathExists can check the existence of /nix/store paths
+ assert builtins.pathExists bar;
+ import bar;
in
diff --git a/tests/init.sh b/tests/init.sh
index e5353598b..19a12c1e2 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -16,6 +16,7 @@ mkdir "$NIX_CONF_DIR"
cat > "$NIX_CONF_DIR"/nix.conf <<EOF
build-users-group =
keep-derivations = false
+sandbox = false
include nix.conf.extra
EOF
diff --git a/tests/install-darwin.sh b/tests/install-darwin.sh
index c99ce84ac..9933eba94 100755
--- a/tests/install-darwin.sh
+++ b/tests/install-darwin.sh
@@ -34,7 +34,7 @@ cleanup() {
sudo rm -rf /etc/nix \
/nix \
/var/root/.nix-profile /var/root/.nix-defexpr /var/root/.nix-channels \
- "$USER/.nix-profile" "$USER/.nix-defexpr" "$USER/.nix-channels"
+ "$HOME/.nix-profile" "$HOME/.nix-defexpr" "$HOME/.nix-channels"
}
verify() {
diff --git a/tests/lang/binary-data b/tests/lang/binary-data
new file mode 100644
index 000000000..06d740502
--- /dev/null
+++ b/tests/lang/binary-data
Binary files differ
diff --git a/tests/lang/eval-fail-hashfile-missing.nix b/tests/lang/eval-fail-hashfile-missing.nix
new file mode 100644
index 000000000..ce098b823
--- /dev/null
+++ b/tests/lang/eval-fail-hashfile-missing.nix
@@ -0,0 +1,5 @@
+let
+ paths = [ ./this-file-is-definitely-not-there-7392097 "/and/neither/is/this/37293620" ];
+in
+ toString (builtins.concatLists (map (hash: map (builtins.hashFile hash) paths) ["md5" "sha1" "sha256" "sha512"]))
+
diff --git a/tests/lang/eval-okay-context-introspection.exp b/tests/lang/eval-okay-context-introspection.exp
new file mode 100644
index 000000000..27ba77dda
--- /dev/null
+++ b/tests/lang/eval-okay-context-introspection.exp
@@ -0,0 +1 @@
+true
diff --git a/tests/lang/eval-okay-context-introspection.nix b/tests/lang/eval-okay-context-introspection.nix
new file mode 100644
index 000000000..43178bd2e
--- /dev/null
+++ b/tests/lang/eval-okay-context-introspection.nix
@@ -0,0 +1,24 @@
+let
+ drv = derivation {
+ name = "fail";
+ builder = "/bin/false";
+ system = "x86_64-linux";
+ outputs = [ "out" "foo" ];
+ };
+
+ path = "${./eval-okay-context-introspection.nix}";
+
+ desired-context = {
+ "${builtins.unsafeDiscardStringContext path}" = {
+ path = true;
+ };
+ "${builtins.unsafeDiscardStringContext drv.drvPath}" = {
+ outputs = [ "foo" "out" ];
+ allOutputs = true;
+ };
+ };
+
+ legit-context = builtins.getContext "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}";
+
+ constructed-context = builtins.getContext (builtins.appendContext "" desired-context);
+in legit-context == constructed-context
diff --git a/tests/lang/eval-okay-float.exp b/tests/lang/eval-okay-float.exp
new file mode 100644
index 000000000..3c50a8adc
--- /dev/null
+++ b/tests/lang/eval-okay-float.exp
@@ -0,0 +1 @@
+[ 3.4 3.5 2.5 1.5 ]
diff --git a/tests/lang/eval-okay-float.nix b/tests/lang/eval-okay-float.nix
new file mode 100644
index 000000000..b2702c7b1
--- /dev/null
+++ b/tests/lang/eval-okay-float.nix
@@ -0,0 +1,6 @@
+[
+ (1.1 + 2.3)
+ (builtins.add (0.5 + 0.5) (2.0 + 0.5))
+ ((0.5 + 0.5) * (2.0 + 0.5))
+ ((1.5 + 1.5) / (0.5 * 4.0))
+]
diff --git a/tests/lang/eval-okay-fromTOML.exp b/tests/lang/eval-okay-fromTOML.exp
index 5b9d47122..d0dd3af2c 100644
--- a/tests/lang/eval-okay-fromTOML.exp
+++ b/tests/lang/eval-okay-fromTOML.exp
@@ -1 +1 @@
-[ { clients = { data = [ [ "gamma" "delta" ] [ 1 2 ] ]; hosts = [ "alpha" "omega" ]; }; database = { connection_max = 5000; enabled = true; ports = [ 8001 8001 8002 ]; server = "192.168.1.1"; }; owner = { name = "Tom Preston-Werner"; }; servers = { alpha = { dc = "eqdc10"; ip = "10.0.0.1"; }; beta = { dc = "eqdc10"; ip = "10.0.0.2"; }; }; title = "TOML Example"; } { "'key2'" = "value"; "1234" = "value"; "127.0.0.1" = "value"; a = { b = { c = { }; }; }; arr1 = [ 1 2 3 ]; arr2 = [ "red" "yellow" "green" ]; arr3 = [ [ 1 2 ] [ 3 4 5 ] ]; arr4 = [ "all" "strings" "are the same" "type" ]; arr5 = [ [ 1 2 ] [ "a" "b" "c" ] ]; arr7 = [ 1 2 3 ]; arr8 = [ 1 2 ]; bare-key = "value"; bare_key = "value"; bool1 = true; bool2 = false; "character encoding" = "value"; d = { e = { f = { }; }; }; flt1 = 1; flt2 = 3.1415; flt3 = -0.01; flt4 = 5e+22; flt5 = 1e+06; flt6 = -0.02; flt7 = 6.626e-34; flt8 = 9.22462e+06; g = { h = { i = { }; }; }; int1 = 99; int2 = 42; int3 = 0; int4 = -17; int5 = 1000; int6 = 5349221; int7 = 12345; j = { "ʞ" = { "'l'" = { }; }; }; key = "value"; name = "Orange"; products = [ { name = "Hammer"; sku = 738594937; } { } { color = "gray"; name = "Nail"; sku = 284758393; } ]; str = "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF."; table-1 = { key1 = "some string"; key2 = 123; }; table-2 = { key1 = "another string"; key2 = 456; }; x = { y = { z = { w = { name = { first = "Tom"; last = "Preston-Werner"; }; point = { x = 1; y = 2; }; }; }; }; }; "ʎǝʞ" = "value"; } { metadata = { "checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4"; "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"; "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"; "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"; }; package = [ { dependencies = [ "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" ]; name = "aho-corasick"; source = "registry+https://github.com/rust-lang/crates.io-index"; version = "0.6.4"; } { name = "ansi_term"; source = "registry+https://github.com/rust-lang/crates.io-index"; version = "0.9.0"; } { dependencies = [ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" ]; name = "atty"; source = "registry+https://github.com/rust-lang/crates.io-index"; version = "0.2.10"; } ]; } ]
+[ { clients = { data = [ [ "gamma" "delta" ] [ 1 2 ] ]; hosts = [ "alpha" "omega" ]; }; database = { connection_max = 5000; enabled = true; ports = [ 8001 8001 8002 ]; server = "192.168.1.1"; }; owner = { name = "Tom Preston-Werner"; }; servers = { alpha = { dc = "eqdc10"; ip = "10.0.0.1"; }; beta = { dc = "eqdc10"; ip = "10.0.0.2"; }; }; title = "TOML Example"; } { "1234" = "value"; "127.0.0.1" = "value"; a = { b = { c = { }; }; }; arr1 = [ 1 2 3 ]; arr2 = [ "red" "yellow" "green" ]; arr3 = [ [ 1 2 ] [ 3 4 5 ] ]; arr4 = [ "all" "strings" "are the same" "type" ]; arr5 = [ [ 1 2 ] [ "a" "b" "c" ] ]; arr7 = [ 1 2 3 ]; arr8 = [ 1 2 ]; bare-key = "value"; bare_key = "value"; bin1 = 214; bool1 = true; bool2 = false; "character encoding" = "value"; d = { e = { f = { }; }; }; dog = { "tater.man" = { type = { name = "pug"; }; }; }; flt1 = 1; flt2 = 3.1415; flt3 = -0.01; flt4 = 5e+22; flt5 = 1e+06; flt6 = -0.02; flt7 = 6.626e-34; flt8 = 9.22462e+06; fruit = [ { name = "apple"; physical = { color = "red"; shape = "round"; }; variety = [ { name = "red delicious"; } { name = "granny smith"; } ]; } { name = "banana"; variety = [ { name = "plantain"; } ]; } ]; g = { h = { i = { }; }; }; hex1 = 3735928559; hex2 = 3735928559; hex3 = 3735928559; int1 = 99; int2 = 42; int3 = 0; int4 = -17; int5 = 1000; int6 = 5349221; int7 = 12345; j = { "ʞ" = { l = { }; }; }; key = "value"; key2 = "value"; name = "Orange"; oct1 = 342391; oct2 = 493; physical = { color = "orange"; shape = "round"; }; products = [ { name = "Hammer"; sku = 738594937; } { } { color = "gray"; name = "Nail"; sku = 284758393; } ]; "quoted \"value\"" = "value"; site = { "google.com" = true; }; str = "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF."; table-1 = { key1 = "some string"; key2 = 123; }; table-2 = { key1 = "another string"; key2 = 456; }; x = { y = { z = { w = { animal = { type = { name = "pug"; }; }; name = { first = "Tom"; last = "Preston-Werner"; }; point = { x = 1; y = 2; }; }; }; }; }; "ʎǝʞ" = "value"; } { metadata = { "checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4"; "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"; "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"; "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"; }; package = [ { dependencies = [ "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" ]; name = "aho-corasick"; source = "registry+https://github.com/rust-lang/crates.io-index"; version = "0.6.4"; } { name = "ansi_term"; source = "registry+https://github.com/rust-lang/crates.io-index"; version = "0.9.0"; } { dependencies = [ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" ]; name = "atty"; source = "registry+https://github.com/rust-lang/crates.io-index"; version = "0.2.10"; } ]; } { a = [ [ { b = true; } ] ]; c = [ [ { d = true; } ] ]; e = [ [ 123 ] ]; } ]
diff --git a/tests/lang/eval-okay-fromTOML.nix b/tests/lang/eval-okay-fromTOML.nix
index 8e7cbd1c6..963932689 100644
--- a/tests/lang/eval-okay-fromTOML.nix
+++ b/tests/lang/eval-okay-fromTOML.nix
@@ -46,15 +46,15 @@
"character encoding" = "value"
"ʎǝʞ" = "value"
'key2' = "value"
- #'quoted "value"' = "value"
+ 'quoted "value"' = "value"
name = "Orange"
- # FIXME: cpptoml doesn't handle dotted keys properly yet.
- #physical.color = "orange"
- #physical.shape = "round"
- #site."google.com" = true
+ physical.color = "orange"
+ physical.shape = "round"
+ site."google.com" = true
+ # This is legal according to the spec, but cpptoml doesn't handle it.
#a.b.c = 1
#a.d = 2
@@ -68,16 +68,14 @@
int6 = 5_349_221
int7 = 1_2_3_4_5
- # FIXME: cpptoml doesn't support these yet:
+ hex1 = 0xDEADBEEF
+ hex2 = 0xdeadbeef
+ hex3 = 0xdead_beef
- #hex1 = 0xDEADBEEF
- #hex2 = 0xdeadbeef
- #hex3 = 0xdead_beef
+ oct1 = 0o01234567
+ oct2 = 0o755
- #oct1 = 0o01234567
- #oct2 = 0o755
-
- #bin1 = 0b11010110
+ bin1 = 0b11010110
flt1 = +1.0
flt2 = 3.1415
@@ -126,8 +124,8 @@
key1 = "another string"
key2 = 456
- #[dog."tater.man"]
- #type.name = "pug"
+ [dog."tater.man"]
+ type.name = "pug"
[a.b.c]
[ d.e.f ]
@@ -137,7 +135,7 @@
name = { first = "Tom", last = "Preston-Werner" }
point = { x = 1, y = 2 }
- #animal = { type.name = "pug" }
+ animal = { type.name = "pug" }
[[products]]
name = "Hammer"
@@ -149,6 +147,25 @@
name = "Nail"
sku = 284758393
color = "gray"
+
+ [[fruit]]
+ name = "apple"
+
+ [fruit.physical]
+ color = "red"
+ shape = "round"
+
+ [[fruit.variety]]
+ name = "red delicious"
+
+ [[fruit.variety]]
+ name = "granny smith"
+
+ [[fruit]]
+ name = "banana"
+
+ [[fruit.variety]]
+ name = "plantain"
'')
(builtins.fromTOML ''
@@ -181,4 +198,11 @@
"checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
'')
+
+ (builtins.fromTOML ''
+ a = [[{ b = true }]]
+ c = [ [ { d = true } ] ]
+ e = [[123]]
+ '')
+
]
diff --git a/tests/lang/eval-okay-hash.exp b/tests/lang/eval-okay-hash.exp
index d720a082d..e69de29bb 100644
--- a/tests/lang/eval-okay-hash.exp
+++ b/tests/lang/eval-okay-hash.exp
@@ -1 +0,0 @@
-[ "d41d8cd98f00b204e9800998ecf8427e" "6c69ee7f211c640419d5366cc076ae46" "bb3438fbabd460ea6dbd27d153e2233b" "da39a3ee5e6b4b0d3255bfef95601890afd80709" "cd54e8568c1b37cf1e5badb0779bcbf382212189" "6d12e10b1d331dad210e47fd25d4f260802b7e77" "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" "900a4469df00ccbfd0c145c6d1e4b7953dd0afafadd7534e3a4019e8d38fc663" "ad0387b3bd8652f730ca46d25f9c170af0fd589f42e7f23f5a9e6412d97d7e56" "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" "9d0886f8c6b389398a16257bc79780fab9831c7fc11c8ab07fa732cb7b348feade382f92617c9c5305fefba0af02ab5fd39a587d330997ff5bd0db19f7666653" "21644b72aa259e5a588cd3afbafb1d4310f4889680f6c83b9d531596a5a284f34dbebff409d23bcc86aee6bad10c891606f075c6f4755cb536da27db5693f3a7" ]
diff --git a/tests/lang/eval-okay-hashfile.exp b/tests/lang/eval-okay-hashfile.exp
new file mode 100644
index 000000000..ff1e8293e
--- /dev/null
+++ b/tests/lang/eval-okay-hashfile.exp
@@ -0,0 +1 @@
+[ "d3b07384d113edec49eaa6238ad5ff00" "0f343b0931126a20f133d67c2b018a3b" "f1d2d2f924e986ac86fdf7b36c94bcdf32beec15" "60cacbf3d72e1e7834203da608037b1bf83b40e8" "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c" "5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef" "0cf9180a764aba863a67b6d72f0918bc131c6772642cb2dce5a34f0a702f9470ddc2bf125c12198b1995c233c34b4afd346c54a2334c350a948a51b6e8b4e6b6" "8efb4f73c5655351c444eb109230c556d39e2c7624e9c11abc9e3fb4b9b9254218cc5085b454a9698d085cfa92198491f07a723be4574adc70617b73eb0b6461" ]
diff --git a/tests/lang/eval-okay-hashfile.nix b/tests/lang/eval-okay-hashfile.nix
new file mode 100644
index 000000000..aff5a1856
--- /dev/null
+++ b/tests/lang/eval-okay-hashfile.nix
@@ -0,0 +1,4 @@
+let
+ paths = [ ./data ./binary-data ];
+in
+ builtins.concatLists (map (hash: map (builtins.hashFile hash) paths) ["md5" "sha1" "sha256" "sha512"])
diff --git a/tests/lang/eval-okay-hashstring.exp b/tests/lang/eval-okay-hashstring.exp
new file mode 100644
index 000000000..d720a082d
--- /dev/null
+++ b/tests/lang/eval-okay-hashstring.exp
@@ -0,0 +1 @@
+[ "d41d8cd98f00b204e9800998ecf8427e" "6c69ee7f211c640419d5366cc076ae46" "bb3438fbabd460ea6dbd27d153e2233b" "da39a3ee5e6b4b0d3255bfef95601890afd80709" "cd54e8568c1b37cf1e5badb0779bcbf382212189" "6d12e10b1d331dad210e47fd25d4f260802b7e77" "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" "900a4469df00ccbfd0c145c6d1e4b7953dd0afafadd7534e3a4019e8d38fc663" "ad0387b3bd8652f730ca46d25f9c170af0fd589f42e7f23f5a9e6412d97d7e56" "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" "9d0886f8c6b389398a16257bc79780fab9831c7fc11c8ab07fa732cb7b348feade382f92617c9c5305fefba0af02ab5fd39a587d330997ff5bd0db19f7666653" "21644b72aa259e5a588cd3afbafb1d4310f4889680f6c83b9d531596a5a284f34dbebff409d23bcc86aee6bad10c891606f075c6f4755cb536da27db5693f3a7" ]
diff --git a/tests/lang/eval-okay-hash.nix b/tests/lang/eval-okay-hashstring.nix
index b0f62b245..b0f62b245 100644
--- a/tests/lang/eval-okay-hash.nix
+++ b/tests/lang/eval-okay-hashstring.nix
diff --git a/tests/lang/eval-okay-types.exp b/tests/lang/eval-okay-types.exp
index 9a8ea0bcb..92a153299 100644
--- a/tests/lang/eval-okay-types.exp
+++ b/tests/lang/eval-okay-types.exp
@@ -1 +1 @@
-[ true false true false true false true false true true true true true true true true true true true false true false "int" "bool" "string" "null" "set" "list" "lambda" "lambda" "lambda" "lambda" ]
+[ true false true false true false true false true true true true true true true true true true true false true true true false "int" "bool" "string" "null" "set" "list" "lambda" "lambda" "lambda" "lambda" ]
diff --git a/tests/lang/eval-okay-types.nix b/tests/lang/eval-okay-types.nix
index a34775f5e..9b58be5d1 100644
--- a/tests/lang/eval-okay-types.nix
+++ b/tests/lang/eval-okay-types.nix
@@ -20,6 +20,8 @@ with builtins;
(isFloat (1 - 2.0))
(isBool (true && false))
(isBool null)
+ (isPath /nix/store)
+ (isPath ./.)
(isAttrs { x = 123; })
(isAttrs null)
(typeOf (3 * 4))
diff --git a/tests/lang/parse-fail-mixed-nested-attrs1.nix b/tests/lang/parse-fail-mixed-nested-attrs1.nix
new file mode 100644
index 000000000..11e40e66f
--- /dev/null
+++ b/tests/lang/parse-fail-mixed-nested-attrs1.nix
@@ -0,0 +1,4 @@
+{
+ x.z = 3;
+ x = { y = 3; z = 3; };
+}
diff --git a/tests/lang/parse-fail-mixed-nested-attrs2.nix b/tests/lang/parse-fail-mixed-nested-attrs2.nix
new file mode 100644
index 000000000..17da82e5f
--- /dev/null
+++ b/tests/lang/parse-fail-mixed-nested-attrs2.nix
@@ -0,0 +1,4 @@
+{
+ x.y.y = 3;
+ x = { y.y= 3; z = 3; };
+}
diff --git a/tests/lang/parse-fail-dup-attrs-6.nix b/tests/lang/parse-okay-dup-attrs-6.nix
index ae6d7a769..ae6d7a769 100644
--- a/tests/lang/parse-fail-dup-attrs-6.nix
+++ b/tests/lang/parse-okay-dup-attrs-6.nix
diff --git a/tests/lang/parse-okay-mixed-nested-attrs-1.nix b/tests/lang/parse-okay-mixed-nested-attrs-1.nix
new file mode 100644
index 000000000..fd1001c8c
--- /dev/null
+++ b/tests/lang/parse-okay-mixed-nested-attrs-1.nix
@@ -0,0 +1,4 @@
+{
+ x = { y = 3; z = 3; };
+ x.q = 3;
+}
diff --git a/tests/lang/parse-okay-mixed-nested-attrs-2.nix b/tests/lang/parse-okay-mixed-nested-attrs-2.nix
new file mode 100644
index 000000000..ad066b680
--- /dev/null
+++ b/tests/lang/parse-okay-mixed-nested-attrs-2.nix
@@ -0,0 +1,4 @@
+{
+ x.q = 3;
+ x = { y = 3; z = 3; };
+}
diff --git a/tests/lang/parse-okay-mixed-nested-attrs-3.nix b/tests/lang/parse-okay-mixed-nested-attrs-3.nix
new file mode 100644
index 000000000..45a33e480
--- /dev/null
+++ b/tests/lang/parse-okay-mixed-nested-attrs-3.nix
@@ -0,0 +1,7 @@
+{
+ services.ssh.enable = true;
+ services.ssh = { port = 123; };
+ services = {
+ httpd.enable = true;
+ };
+}
diff --git a/tests/linux-sandbox.sh b/tests/linux-sandbox.sh
index acfd46c54..52967d07d 100644
--- a/tests/linux-sandbox.sh
+++ b/tests/linux-sandbox.sh
@@ -25,3 +25,6 @@ nix path-info -r $outPath | grep input-2
nix ls-store -R -l $outPath | grep foobar
nix cat-store $outPath/foobar | grep FOOBAR
+
+# Test --check without hash rewriting.
+nix-build dependencies.nix --no-out-link --check --sandbox-paths /nix/store
diff --git a/tests/local.mk b/tests/local.mk
index 1ff68348b..187f96ea2 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -3,7 +3,9 @@ check:
nix_tests = \
init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
- gc.sh gc-concurrent.sh \
+ gc.sh \
+ gc-concurrent.sh \
+ gc-auto.sh \
referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
gc-runtime.sh check-refs.sh filter-source.sh \
remote-store.sh export.sh export-graph.sh \
@@ -26,7 +28,9 @@ nix_tests = \
check.sh \
plugins.sh \
search.sh \
- nix-copy-ssh.sh
+ nix-copy-ssh.sh \
+ post-hook.sh \
+ function-trace.sh
# parallel.sh
install-tests += $(foreach x, $(nix_tests), tests/$(x))
diff --git a/tests/nix-copy-ssh.sh b/tests/nix-copy-ssh.sh
index 6aba667a4..eb801548d 100644
--- a/tests/nix-copy-ssh.sh
+++ b/tests/nix-copy-ssh.sh
@@ -7,7 +7,7 @@ remoteRoot=$TEST_ROOT/store2
chmod -R u+w "$remoteRoot" || true
rm -rf "$remoteRoot"
-outPath=$(nix-build dependencies.nix)
+outPath=$(nix-build --no-out-link dependencies.nix)
nix copy --to "ssh://localhost?store=$NIX_STORE_DIR&remote-store=$remoteRoot%3fstore=$NIX_STORE_DIR%26real=$remoteRoot$NIX_STORE_DIR" $outPath
diff --git a/tests/nix-shell.sh b/tests/nix-shell.sh
index 6024ea399..ee502dddb 100644
--- a/tests/nix-shell.sh
+++ b/tests/nix-shell.sh
@@ -27,13 +27,13 @@ output=$(nix-shell --pure --keep SELECTED_IMPURE_VAR shell.nix -A shellDrv --run
# Test nix-shell on a .drv symlink
# Legacy: absolute path and .drv extension required
-nix-instantiate shell.nix -A shellDrv --indirect --add-root shell.drv
-[[ $(nix-shell --pure $PWD/shell.drv --run \
+nix-instantiate shell.nix -A shellDrv --indirect --add-root $TEST_ROOT/shell.drv
+[[ $(nix-shell --pure $TEST_ROOT/shell.drv --run \
'echo "$IMPURE_VAR - $VAR_FROM_STDENV_SETUP - $VAR_FROM_NIX"') = " - foo - bar" ]]
# New behaviour: just needs to resolve to a derivation in the store
-nix-instantiate shell.nix -A shellDrv --indirect --add-root shell
-[[ $(nix-shell --pure shell --run \
+nix-instantiate shell.nix -A shellDrv --indirect --add-root $TEST_ROOT/shell
+[[ $(nix-shell --pure $TEST_ROOT/shell --run \
'echo "$IMPURE_VAR - $VAR_FROM_STDENV_SETUP - $VAR_FROM_NIX"') = " - foo - bar" ]]
# Test nix-shell -p
diff --git a/tests/placeholders.sh b/tests/placeholders.sh
index 071cfe2dc..cd1bb7bc2 100644
--- a/tests/placeholders.sh
+++ b/tests/placeholders.sh
@@ -18,5 +18,3 @@ nix-build --no-out-link -E '
";
}
'
-
-echo XYZZY
diff --git a/tests/post-hook.sh b/tests/post-hook.sh
new file mode 100644
index 000000000..a02657215
--- /dev/null
+++ b/tests/post-hook.sh
@@ -0,0 +1,15 @@
+source common.sh
+
+clearStore
+
+export REMOTE_STORE=$TEST_ROOT/remote_store
+
+# Build the dependencies and push them to the remote store
+nix-build -o $TEST_ROOT/result dependencies.nix --post-build-hook $PWD/push-to-store.sh
+
+clearStore
+
+# Ensure that we the remote store contains both the runtime and buildtime
+# closure of what we've just built
+nix copy --from "$REMOTE_STORE" --no-require-sigs -f dependencies.nix
+nix copy --from "$REMOTE_STORE" --no-require-sigs -f dependencies.nix input1_drv
diff --git a/tests/push-to-store.sh b/tests/push-to-store.sh
new file mode 100755
index 000000000..6aadb916b
--- /dev/null
+++ b/tests/push-to-store.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo Pushing "$@" to "$REMOTE_STORE"
+printf "%s" "$OUT_PATHS" | xargs -d: nix copy --to "$REMOTE_STORE" --no-require-sigs
diff --git a/tests/remote-builds.nix b/tests/remote-builds.nix
index d7a4b2198..b867f13b4 100644
--- a/tests/remote-builds.nix
+++ b/tests/remote-builds.nix
@@ -8,8 +8,8 @@ makeTest (
let
- # The configuration of the build slaves.
- slave =
+ # The configuration of the remote builders.
+ builder =
{ config, pkgs, ... }:
{ services.openssh.enable = true;
virtualisation.writableStore = true;
@@ -36,21 +36,21 @@ in
{
nodes =
- { slave1 = slave;
- slave2 = slave;
+ { builder1 = builder;
+ builder2 = builder;
client =
{ config, pkgs, ... }:
{ nix.maxJobs = 0; # force remote building
nix.distributedBuilds = true;
nix.buildMachines =
- [ { hostName = "slave1";
+ [ { hostName = "builder1";
sshUser = "root";
sshKey = "/root/.ssh/id_ed25519";
system = "i686-linux";
maxJobs = 1;
}
- { hostName = "slave2";
+ { hostName = "builder2";
sshUser = "root";
sshKey = "/root/.ssh/id_ed25519";
system = "i686-linux";
@@ -75,33 +75,33 @@ in
$client->copyFileFromHost("key", "/root/.ssh/id_ed25519");
$client->succeed("chmod 600 /root/.ssh/id_ed25519");
- # Install the SSH key on the slaves.
+ # Install the SSH key on the builders.
$client->waitForUnit("network.target");
- foreach my $slave ($slave1, $slave2) {
- $slave->succeed("mkdir -p -m 700 /root/.ssh");
- $slave->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
- $slave->waitForUnit("sshd");
- $client->succeed("ssh -o StrictHostKeyChecking=no " . $slave->name() . " 'echo hello world'");
+ foreach my $builder ($builder1, $builder2) {
+ $builder->succeed("mkdir -p -m 700 /root/.ssh");
+ $builder->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
+ $builder->waitForUnit("sshd");
+ $client->succeed("ssh -o StrictHostKeyChecking=no " . $builder->name() . " 'echo hello world'");
}
- # Perform a build and check that it was performed on the slave.
+ # Perform a build and check that it was performed on the builder.
my $out = $client->succeed(
"nix-build ${expr nodes.client.config 1} 2> build-output",
"grep -q Hello build-output"
);
- $slave1->succeed("test -e $out");
+ $builder1->succeed("test -e $out");
# And a parallel build.
my ($out1, $out2) = split /\s/,
$client->succeed('nix-store -r $(nix-instantiate ${expr nodes.client.config 2})\!out $(nix-instantiate ${expr nodes.client.config 3})\!out');
- $slave1->succeed("test -e $out1 -o -e $out2");
- $slave2->succeed("test -e $out1 -o -e $out2");
+ $builder1->succeed("test -e $out1 -o -e $out2");
+ $builder2->succeed("test -e $out1 -o -e $out2");
# And a failing build.
$client->fail("nix-build ${expr nodes.client.config 5}");
- # Test whether the build hook automatically skips unavailable slaves.
- $slave1->block;
+ # Test whether the build hook automatically skips unavailable builders.
+ $builder1->block;
$client->succeed("nix-build ${expr nodes.client.config 4}");
'';
diff --git a/tests/signing.sh b/tests/signing.sh
index 469296391..9e29e3fbf 100644
--- a/tests/signing.sh
+++ b/tests/signing.sh
@@ -62,6 +62,10 @@ outPathCA=$(IMPURE_VAR1=foo IMPURE_VAR2=bar nix-build ./fixed.nix -A good.0 --no
nix verify $outPathCA
nix verify $outPathCA --sigs-needed 1000
+# Check that signing a content-addressed path doesn't overflow validSigs
+nix sign-paths --key-file $TEST_ROOT/sk1 $outPathCA
+nix verify -r $outPathCA --sigs-needed 1000 --trusted-public-keys $pk1
+
# Copy to a binary cache.
nix copy --to file://$cacheDir $outPath2
diff --git a/tests/timeout.sh b/tests/timeout.sh
index 39ecf0a1a..eea9b5731 100644
--- a/tests/timeout.sh
+++ b/tests/timeout.sh
@@ -2,10 +2,14 @@
source common.sh
-failed=0
-messages="`nix-build -Q timeout.nix -A infiniteLoop --timeout 2 2>&1 || failed=1`"
-if [ $failed -ne 0 ]; then
- echo "error: 'nix-store' succeeded; should have timed out"
+
+set +e
+messages=$(nix-build -Q timeout.nix -A infiniteLoop --timeout 2 2>&1)
+status=$?
+set -e
+
+if [ $status -ne 101 ]; then
+ echo "error: 'nix-store' exited with '$status'; should have exited 101"
exit 1
fi