From 2d5114452d8a8f73c858f9beb6bfaafe35e7bf9a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 17 Mar 2009 16:33:48 +0000 Subject: [PATCH] * Regression test for the `exportReferencesGraph' derivation attribute. --- tests/Makefile.am | 6 +++--- tests/config.nix.in | 9 +++++++++ tests/dependencies.builder0.sh | 2 ++ tests/dependencies.nix | 22 ++++++++++++++++++++++ tests/dependencies.nix.in | 29 ----------------------------- tests/export-graph.nix | 23 +++++++++++++++++++++++ tests/export-graph.sh | 9 +++++++++ tests/logging.sh | 2 +- 8 files changed, 69 insertions(+), 33 deletions(-) create mode 100644 tests/config.nix.in create mode 100644 tests/dependencies.nix delete mode 100644 tests/dependencies.nix.in create mode 100644 tests/export-graph.nix create mode 100644 tests/export-graph.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index ab6ac426..e61d4faa 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,7 +3,7 @@ TESTS_ENVIRONMENT = $(SHELL) -e extra1 = $(shell pwd)/test-tmp/shared simple.sh substitutes.sh substitutes2.sh fallback.sh: simple.nix -dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh nix-build.sh install-package.sh check-refs.sh: dependencies.nix +dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh nix-build.sh install-package.sh check-refs.sh export-graph.sh: config.nix locking.sh: locking.nix parallel.sh: parallel.nix build-hook.sh: build-hook.nix @@ -19,7 +19,7 @@ TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \ fallback.sh nix-push.sh gc.sh gc-concurrent.sh verify.sh nix-pull.sh \ referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \ gc-runtime.sh install-package.sh check-refs.sh filter-source.sh \ - remote-store.sh export.sh + remote-store.sh export.sh export-graph.sh XFAIL_TESTS = @@ -30,7 +30,7 @@ $(TESTS): common.sh EXTRA_DIST = $(TESTS) \ simple.nix.in simple.builder.sh \ hash-check.nix \ - dependencies.nix.in dependencies.builder*.sh \ + dependencies.nix dependencies.builder*.sh \ locking.nix.in locking.builder.sh \ parallel.nix.in parallel.builder.sh \ build-hook.nix.in build-hook.hook.sh \ diff --git a/tests/config.nix.in b/tests/config.nix.in new file mode 100644 index 00000000..a58295f9 --- /dev/null +++ b/tests/config.nix.in @@ -0,0 +1,9 @@ +{ + mkDerivation = args: + derivation ({ + system = "@system@"; + builder = "@shell@"; + args = ["-e" args.builder]; + PATH = "@testPath@"; + } // removeAttrs args ["builder"]); +} diff --git a/tests/dependencies.builder0.sh b/tests/dependencies.builder0.sh index dc0bd9a9..ea4116d9 100644 --- a/tests/dependencies.builder0.sh +++ b/tests/dependencies.builder0.sh @@ -5,3 +5,5 @@ ln -s $input2 $out/input-2 # Self-reference. ln -s $out $out/self + +echo FOO diff --git a/tests/dependencies.nix b/tests/dependencies.nix new file mode 100644 index 00000000..a397e1ce --- /dev/null +++ b/tests/dependencies.nix @@ -0,0 +1,22 @@ +with import ./config.nix; + +let { + + input1 = mkDerivation { + name = "dependencies-input-1"; + builder = ./dependencies.builder1.sh; + }; + + input2 = mkDerivation { + name = "dependencies-input-2"; + builder = ./. ~ "dependencies.builder2.sh"; + }; + + body = mkDerivation { + name = "dependencies"; + builder = ./dependencies.builder0.sh + "/FOOBAR/../."; + input1 = input1 + "/."; + inherit input2; + }; + +} diff --git a/tests/dependencies.nix.in b/tests/dependencies.nix.in deleted file mode 100644 index c33c6a8d..00000000 --- a/tests/dependencies.nix.in +++ /dev/null @@ -1,29 +0,0 @@ -let { - - input1 = derivation { - name = "dependencies-input-1"; - system = "@system@"; - builder = "@shell@"; - args = ["-e" "-x" ./dependencies.builder1.sh]; - PATH = "@testPath@"; - }; - - input2 = derivation { - name = "dependencies-input-2"; - system = "@system@"; - builder = "@shell@"; - args = ["-e" "-x" (./. ~ "dependencies.builder2.sh")]; - PATH = "@testPath@"; - }; - - body = derivation { - name = "dependencies"; - system = "@system@"; - builder = "@shell@"; - args = ["-e" "-x" (./dependencies.builder0.sh + "/FOOBAR/../.")]; - PATH = "@testPath@"; - input1 = input1 + "/."; - inherit input2; - }; - -} \ No newline at end of file diff --git a/tests/export-graph.nix b/tests/export-graph.nix new file mode 100644 index 00000000..3e30d2dc --- /dev/null +++ b/tests/export-graph.nix @@ -0,0 +1,23 @@ +with import ./config.nix; + +rec { + + buildGraphBuilder = builtins.toFile "build-graph-builder" + '' + #cat refs + while read path; do + read drv + read nrRefs + echo "$path has $nrRefs references" + echo -n "$path" >> $out + for ((n = 0; n < $nrRefs; n++)); do read ref; echo "ref $ref"; done + done < refs + ''; + + buildGraph = mkDerivation { + name = "dependencies"; + builder = buildGraphBuilder; + exportReferencesGraph = ["refs" (import ./dependencies.nix)]; + }; + +} diff --git a/tests/export-graph.sh b/tests/export-graph.sh new file mode 100644 index 00000000..f31bc75a --- /dev/null +++ b/tests/export-graph.sh @@ -0,0 +1,9 @@ +source common.sh + +clearStore +clearProfiles + +outPath=$($nixbuild ./export-graph.nix) + +test $(nix-store -q --references ./result | wc -l) = 2 || fail "bad nr of references" +nix-store -q --references ./result | grep -q input-2 || fail "missing reference" diff --git a/tests/logging.sh b/tests/logging.sh index 585bce2d..60e2e123 100644 --- a/tests/logging.sh +++ b/tests/logging.sh @@ -19,5 +19,5 @@ if test "$xsltproc" != "false"; then # Ideally we would check that the generated HTML is valid... # A few checks... - grep "
  • .*.*echo FOO" $TEST_ROOT/log.html + grep "
  • .*.*FOO" $TEST_ROOT/log.html fi