aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/content-addressed.nix19
-rw-r--r--tests/content-addressed.sh16
-rw-r--r--tests/local.mk3
-rw-r--r--tests/multiple-outputs.nix15
-rw-r--r--tests/multiple-outputs.sh6
5 files changed, 58 insertions, 1 deletions
diff --git a/tests/content-addressed.nix b/tests/content-addressed.nix
new file mode 100644
index 000000000..586e4cba6
--- /dev/null
+++ b/tests/content-addressed.nix
@@ -0,0 +1,19 @@
+with import ./config.nix;
+
+{ seed ? 0 }:
+# A simple content-addressed derivation.
+# The derivation can be arbitrarily modified by passing a different `seed`,
+# but the output will always be the same
+mkDerivation {
+ name = "simple-content-addressed";
+ buildCommand = ''
+ set -x
+ echo "Building a CA derivation"
+ echo "The seed is ${toString seed}"
+ mkdir -p $out
+ echo "Hello World" > $out/hello
+ '';
+ __contentAddressed = true;
+ outputHashMode = "recursive";
+ outputHashAlgo = "sha256";
+}
diff --git a/tests/content-addressed.sh b/tests/content-addressed.sh
new file mode 100644
index 000000000..2968f3a8c
--- /dev/null
+++ b/tests/content-addressed.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+source common.sh
+
+clearStore
+clearCache
+
+export REMOTE_STORE=file://$cacheDir
+
+drv=$(nix-instantiate --experimental-features ca-derivations ./content-addressed.nix --arg seed 1)
+nix --experimental-features 'nix-command ca-derivations' show-derivation --derivation "$drv" --arg seed 1
+
+out1=$(nix-build --experimental-features ca-derivations ./content-addressed.nix --arg seed 1 --no-out-link)
+out2=$(nix-build --experimental-features ca-derivations ./content-addressed.nix --arg seed 2 --no-out-link)
+
+test $out1 == $out2
diff --git a/tests/local.mk b/tests/local.mk
index 0f3bfe606..4f4e63a5a 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -32,7 +32,8 @@ nix_tests = \
post-hook.sh \
function-trace.sh \
recursive.sh \
- flakes.sh
+ flakes.sh \
+ content-addressed.sh
# parallel.sh
install-tests += $(foreach x, $(nix_tests), tests/$(x))
diff --git a/tests/multiple-outputs.nix b/tests/multiple-outputs.nix
index 4a9010d18..b915493f7 100644
--- a/tests/multiple-outputs.nix
+++ b/tests/multiple-outputs.nix
@@ -2,6 +2,21 @@ with import ./config.nix;
rec {
+ # Want to ensure that "out" doesn't get a suffix on it's path.
+ nameCheck = mkDerivation {
+ name = "multiple-outputs-a";
+ outputs = [ "out" "dev" ];
+ builder = builtins.toFile "builder.sh"
+ ''
+ mkdir $first $second
+ test -z $all
+ echo "first" > $first/file
+ echo "second" > $second/file
+ ln -s $first $second/link
+ '';
+ helloString = "Hello, world!";
+ };
+
a = mkDerivation {
name = "multiple-outputs-a";
outputs = [ "first" "second" ];
diff --git a/tests/multiple-outputs.sh b/tests/multiple-outputs.sh
index bedbc39a4..7a6ec181d 100644
--- a/tests/multiple-outputs.sh
+++ b/tests/multiple-outputs.sh
@@ -4,6 +4,12 @@ clearStore
rm -f $TEST_ROOT/result*
+# Test whether the output names match our expectations
+outPath=$(nix-instantiate multiple-outputs.nix --eval -A nameCheck.out.outPath)
+[ "$(echo "$outPath" | sed -E 's_^".*/[^-/]*-([^/]*)"$_\1_')" = "multiple-outputs-a" ]
+outPath=$(nix-instantiate multiple-outputs.nix --eval -A nameCheck.dev.outPath)
+[ "$(echo "$outPath" | sed -E 's_^".*/[^-/]*-([^/]*)"$_\1_')" = "multiple-outputs-a-dev" ]
+
# Test whether read-only evaluation works when referring to the
# ‘drvPath’ attribute.
echo "evaluating c..."