From a7bbe739717c7419a374b29e6e4887325b1af7fd Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 4 May 2004 13:22:33 +0000 Subject: [PATCH] * Another test. --- tests/Makefile.am | 6 ++++-- tests/dependencies.builder0.sh | 6 ++++++ tests/dependencies.builder1.sh | 4 ++++ tests/dependencies.builder2.sh | 4 ++++ tests/dependencies.nix.in | 25 +++++++++++++++++++++++++ tests/dependencies.sh | 23 +++++++++++++++++++++++ 6 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 tests/dependencies.builder0.sh create mode 100644 tests/dependencies.builder1.sh create mode 100644 tests/dependencies.builder2.sh create mode 100644 tests/dependencies.nix.in create mode 100644 tests/dependencies.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index 7c62f9025..2119221bb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,10 +10,12 @@ TESTS_ENVIRONMENT = TEST_ROOT=$(TEST_ROOT) \ $(SHELL) -e -x simple.sh: simple.nix +dependencies.sh: dependencies.nix -TESTS = init.sh simple.sh +TESTS = init.sh simple.sh dependencies.sh include ../substitute.mk EXTRA_DIST = $(TESTS) \ - simple.nix.in simple.builder.sh + simple.nix.in simple.builder.sh \ + dependencies.nix.in dependencies.builder*.sh diff --git a/tests/dependencies.builder0.sh b/tests/dependencies.builder0.sh new file mode 100644 index 000000000..326e8dfbb --- /dev/null +++ b/tests/dependencies.builder0.sh @@ -0,0 +1,6 @@ +export PATH=/bin:/usr/bin:$PATH + +mkdir $out +echo $(cat $input1/foo)$(cat $input2/bar) > $out/foobar + +ln -s $input2 $out/input-2 \ No newline at end of file diff --git a/tests/dependencies.builder1.sh b/tests/dependencies.builder1.sh new file mode 100644 index 000000000..53cd73916 --- /dev/null +++ b/tests/dependencies.builder1.sh @@ -0,0 +1,4 @@ +export PATH=/bin:/usr/bin:$PATH + +mkdir $out +echo FOO > $out/foo diff --git a/tests/dependencies.builder2.sh b/tests/dependencies.builder2.sh new file mode 100644 index 000000000..baceae756 --- /dev/null +++ b/tests/dependencies.builder2.sh @@ -0,0 +1,4 @@ +export PATH=/bin:/usr/bin:$PATH + +mkdir $out +echo BAR > $out/bar diff --git a/tests/dependencies.nix.in b/tests/dependencies.nix.in new file mode 100644 index 000000000..920564955 --- /dev/null +++ b/tests/dependencies.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/dependencies.sh b/tests/dependencies.sh new file mode 100644 index 000000000..8a0ba1f2a --- /dev/null +++ b/tests/dependencies.sh @@ -0,0 +1,23 @@ +storeExpr=$($TOP/src/nix-instantiate/nix-instantiate dependencies.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" != "FOOBAR"; then exit 1; fi + +deps=$($TOP/src/nix-store/nix-store -qnR "$storeExpr") + +echo "output closures are $deps" + +# The output path should be in the closure. +echo "$deps" | grep -q "$outPath" + +# Input-1 is not retained. +if echo "$deps" | grep -q "dependencies-input-1"; then exit 1; fi + +# Input-2 is retained. +echo "$deps" | grep -q "dependencies-input-2"