diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-09-03 22:44:56 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-09-03 22:45:00 +0000 |
commit | b836662f501397be746030a8a0f694fafb7b68df (patch) | |
tree | 7365fdee959a9583207caa804b71328e72ef47bf | |
parent | 975a47f7fe9365eacd214c196ce5747ea2a19c3b (diff) | |
parent | 145915eb3901ad78e61f27df22e755fdf9a2c28a (diff) |
Merge remote-tracking branch 'obsidian/single-ca-drv-build' into ca-floating-upstream
Tests also now fail as they should
-rw-r--r-- | tests/content-addressed.nix | 29 | ||||
-rw-r--r-- | tests/content-addressed.sh | 19 |
2 files changed, 31 insertions, 17 deletions
diff --git a/tests/content-addressed.nix b/tests/content-addressed.nix index a46c21164..5ebc779c1 100644 --- a/tests/content-addressed.nix +++ b/tests/content-addressed.nix @@ -5,12 +5,11 @@ with import ./config.nix; # The derivation can be arbitrarily modified by passing a different `seed`, # but the output will always be the same rec { - root = mkDerivation { - name = "simple-content-addressed"; + rootLegacy = mkDerivation { + name = "simple-input-addressed"; buildCommand = '' set -x - echo "Building a CA derivation" - echo "The seed is ${toString seed}" + echo "Building a legacy derivation" mkdir -p $out echo "Hello World" > $out/hello ''; @@ -18,23 +17,35 @@ rec { outputHashMode = "recursive"; outputHashAlgo = "sha256"; }; - dependent = mkDerivation { + rootCA = mkDerivation { + name = "dependent"; + buildCommand = '' + echo "building a CA derivation" + echo "The seed is ${toString seed}" + mkdir -p $out + echo ${rootLegacy}/hello > $out/dep + ''; + __contentAddressed = true; + outputHashMode = "recursive"; + outputHashAlgo = "sha256"; + }; + dependentCA = mkDerivation { name = "dependent"; buildCommand = '' echo "building a dependent derivation" mkdir -p $out - echo ${root}/hello > $out/dep + echo ${rootCA}/hello > $out/dep ''; __contentAddressed = true; outputHashMode = "recursive"; outputHashAlgo = "sha256"; }; - transitivelyDependent = mkDerivation { + transitivelyDependentCA = mkDerivation { name = "transitively-dependent"; buildCommand = '' echo "building transitively-dependent" - cat ${dependent}/dep - echo ${dependent} > $out + cat ${dependentCA}/dep + echo ${dependentCA} > $out ''; __contentAddressed = true; outputHashMode = "recursive"; diff --git a/tests/content-addressed.sh b/tests/content-addressed.sh index 5997a432f..b2e94fe1e 100644 --- a/tests/content-addressed.sh +++ b/tests/content-addressed.sh @@ -2,20 +2,23 @@ source common.sh -drv=$(nix-instantiate --experimental-features ca-derivations ./content-addressed.nix -A root --arg seed 1) +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 testDerivation () { local derivationPath=$1 local commonArgs=("--experimental-features" "ca-derivations" "./content-addressed.nix" "-A" "$derivationPath" "--no-out-link") - local out1=$(nix-build "${commonArgs[@]}" --arg seed 1) - local out2=$(nix-build "${commonArgs[@]}" --arg seed 2 "${extraArgs[@]}") - test $out1 == $out2 + local out1 out2 + out1=$(set -e; nix-build "${commonArgs[@]}" --arg seed 1) + out2=$(nix-build "${commonArgs[@]}" --arg seed 2 "${secondSeedArgs[@]}") + test "$out1" == "$out2" } -testDerivation root +testDerivation rootCA # The seed only changes the root derivation, and not it's output, so the # dependent derivations should only need to be built once. -extaArgs=(-j0) -testDerivation dependent -testDerivation transitivelyDependent +secondSeedArgs=(-j0) +# Don't directly build depenentCA, that way we'll make sure we dodn't rely on +# dependent derivations always being already built. +#testDerivation dependentCA +testDerivation transitivelyDependentCA |