diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 7 | ||||
-rw-r--r-- | tests/build-hook.hook.sh | 17 | ||||
-rw-r--r-- | tests/build-hook.nix.in | 25 | ||||
-rw-r--r-- | tests/build-hook.sh | 12 |
4 files changed, 59 insertions, 2 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 14662c20d..608ffec19 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -16,8 +16,10 @@ simple.sh: simple.nix dependencies.sh: dependencies.nix locking.sh: locking.nix parallel.sh: parallel.nix +build-hook.sh: build-hook.nix -TESTS = init.sh simple.sh dependencies.sh locking.sh parallel.sh +TESTS = init.sh simple.sh dependencies.sh locking.sh parallel.sh \ + build-hook.sh XFAIL_TESTS = @@ -27,4 +29,5 @@ EXTRA_DIST = $(TESTS) \ simple.nix.in simple.builder.sh \ dependencies.nix.in dependencies.builder*.sh \ locking.nix.in locking.builder.sh \ - parallel.nix.in parallel.builder.sh + parallel.nix.in parallel.builder.sh \ + build-hook.nix.in diff --git a/tests/build-hook.hook.sh b/tests/build-hook.hook.sh new file mode 100644 index 000000000..7176315d9 --- /dev/null +++ b/tests/build-hook.hook.sh @@ -0,0 +1,17 @@ +set -x + +drv=$1 + +echo "HOOK for $drv" + +outPath=$(sed 's/Derive(\[\"\([^\"]*\)\".*/\1/' $drv) + +echo "output path is $outPath" + +if $(echo $outPath | grep -q input-1); then + mkdir $outPath + echo "BAR" > $outPath/foo + exit 100 +fi + +exit 101
\ No newline at end of file diff --git a/tests/build-hook.nix.in b/tests/build-hook.nix.in new file mode 100644 index 000000000..920564955 --- /dev/null +++ b/tests/build-hook.nix.in @@ -0,0 +1,25 @@ +let { + + input1 = derivation { + name = "dependencies-input-1"; + system = "@system@"; + builder = "@shell@"; + args = ["-e" "-x" ./dependencies.builder1.sh]; + }; + + input2 = derivation { + name = "dependencies-input-2"; + system = "@system@"; + builder = "@shell@"; + args = ["-e" "-x" ./dependencies.builder2.sh]; + }; + + body = derivation { + name = "dependencies"; + system = "@system@"; + builder = "@shell@"; + args = ["-e" "-x" ./dependencies.builder0.sh]; + inherit input1 input2; + }; + +}
\ No newline at end of file diff --git a/tests/build-hook.sh b/tests/build-hook.sh new file mode 100644 index 000000000..bd74e42fe --- /dev/null +++ b/tests/build-hook.sh @@ -0,0 +1,12 @@ +export NIX_BUILD_HOOK="sh build-hook.hook.sh" + +storeExpr=$($TOP/src/nix-instantiate/nix-instantiate build-hook.nix) + +echo "store expr is $storeExpr" + +outPath=$($TOP/src/nix-store/nix-store -qnfvvvvv "$storeExpr") + +echo "output path is $outPath" + +text=$(cat "$outPath"/foobar) +if test "$text" != "BARBAR"; then exit 1; fi |