aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-09-16 22:35:24 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-09-16 22:35:24 +0000
commitf60b380a7f32406659efee282cde4c1330fc1c65 (patch)
tree8bd0680b8fafa02c93b29d0934133b0ff5b29e7a /tests
parentc08c9f08c75bf379439348cccb5b8871a27bf498 (diff)
parent5080d4e7b2525d1656282c65a217a22ff8381df3 (diff)
Merge remote-tracking branch 'upstream/master' into remove-storetype-delegate-regStore
Diffstat (limited to 'tests')
-rw-r--r--tests/content-addressed.nix32
-rw-r--r--tests/content-addressed.sh17
-rw-r--r--tests/describe-stores.sh8
-rw-r--r--tests/local.mk4
-rw-r--r--tests/multiple-outputs.nix15
-rw-r--r--tests/multiple-outputs.sh6
6 files changed, 81 insertions, 1 deletions
diff --git a/tests/content-addressed.nix b/tests/content-addressed.nix
new file mode 100644
index 000000000..5e9bad0ac
--- /dev/null
+++ b/tests/content-addressed.nix
@@ -0,0 +1,32 @@
+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
+rec {
+ rootLegacy = mkDerivation {
+ name = "simple-input-addressed";
+ buildCommand = ''
+ set -x
+ echo "Building a legacy derivation"
+ mkdir -p $out
+ echo "Hello World" > $out/hello
+ '';
+ };
+ rootCA = mkDerivation {
+ name = "dependent";
+ outputs = [ "out" "dev" ];
+ buildCommand = ''
+ echo "building a CA derivation"
+ echo "The seed is ${toString seed}"
+ mkdir -p $out
+ echo ${rootLegacy}/hello > $out/dep
+ # test symlink at root
+ ln -s $out $dev
+ '';
+ __contentAddressed = true;
+ outputHashMode = "recursive";
+ outputHashAlgo = "sha256";
+ };
+}
diff --git a/tests/content-addressed.sh b/tests/content-addressed.sh
new file mode 100644
index 000000000..ae9e3c59e
--- /dev/null
+++ b/tests/content-addressed.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+source common.sh
+
+clearStore
+clearCache
+
+export REMOTE_STORE=file://$cacheDir
+
+drv=$(nix-instantiate --experimental-features ca-derivations ./content-addressed.nix -A rootCA --arg seed 1)
+nix --experimental-features 'nix-command ca-derivations' show-derivation --derivation "$drv" --arg seed 1
+
+commonArgs=("--experimental-features" "ca-derivations" "./content-addressed.nix" "-A" "rootCA" "--no-out-link")
+out1=$(nix-build "${commonArgs[@]}" ./content-addressed.nix --arg seed 1)
+out2=$(nix-build "${commonArgs[@]}" ./content-addressed.nix --arg seed 2)
+
+test $out1 == $out2
diff --git a/tests/describe-stores.sh b/tests/describe-stores.sh
new file mode 100644
index 000000000..3fea61483
--- /dev/null
+++ b/tests/describe-stores.sh
@@ -0,0 +1,8 @@
+source common.sh
+
+# Query an arbitrary value in `nix describe-stores --json`'s output just to
+# check that it has the right structure
+[[ $(nix --experimental-features 'nix-command flakes' describe-stores --json | jq '.["SSH Store"]["compress"]["defaultValue"]') == false ]]
+
+# Ensure that the output of `nix describe-stores` isn't empty
+[[ -n $(nix --experimental-features 'nix-command flakes' describe-stores) ]]
diff --git a/tests/local.mk b/tests/local.mk
index fd9438386..a1929f96d 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -33,7 +33,9 @@ nix_tests = \
post-hook.sh \
function-trace.sh \
recursive.sh \
- flakes.sh
+ describe-stores.sh \
+ flakes.sh \
+ content-addressed.sh
# parallel.sh
# build-remote-content-addressed-fixed.sh \
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..."