From 8f28a3ba25dd0dad6411a039bc01ad87c61a6e59 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 14 Sep 2011 05:59:29 +0000 Subject: Add a test for multiple outputs This currently fails. Yay test-driven development! --- tests/Makefile.am | 4 +++- tests/multiple-outputs.a.builder.sh | 6 ++++++ tests/multiple-outputs.b.builder.sh | 7 +++++++ tests/multiple-outputs.nix | 23 +++++++++++++++++++++++ tests/multiple-outputs.sh | 15 +++++++++++++++ 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/multiple-outputs.a.builder.sh create mode 100644 tests/multiple-outputs.b.builder.sh create mode 100644 tests/multiple-outputs.nix create mode 100644 tests/multiple-outputs.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index 676a9c387b18..0418f73e6cf5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -8,7 +8,7 @@ TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.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 export-graph.sh negative-caching.sh \ - binary-patching.sh timeout.sh secure-drv-outputs.sh + binary-patching.sh timeout.sh secure-drv-outputs.sh multiple-outputs.sh XFAIL_TESTS = @@ -35,6 +35,8 @@ EXTRA_DIST = $(TESTS) \ binary-patching.nix \ timeout.nix timeout.builder.sh \ secure-drv-outputs.nix \ + multiple-outputs.nix \ + multiple-outputs.a.builder.sh multiple-outputs.b.builder.sh \ $(wildcard lang/*.nix) $(wildcard lang/*.exp) $(wildcard lang/*.exp.xml) $(wildcard lang/*.flags) $(wildcard lang/dir*/*.nix) \ common.sh.in diff --git a/tests/multiple-outputs.a.builder.sh b/tests/multiple-outputs.a.builder.sh new file mode 100644 index 000000000000..657b7ea0adc5 --- /dev/null +++ b/tests/multiple-outputs.a.builder.sh @@ -0,0 +1,6 @@ +mkdir $first +mkdir $second +test -z $all + +echo "second" > $first/file +echo "first" > $second/file diff --git a/tests/multiple-outputs.b.builder.sh b/tests/multiple-outputs.b.builder.sh new file mode 100644 index 000000000000..bc63fc0681b0 --- /dev/null +++ b/tests/multiple-outputs.b.builder.sh @@ -0,0 +1,7 @@ +mkdir $out +test "$firstOutput $secondOutput" = "$allOutputs" +test "$defaultOutput" = "$firstOutput" +test "$(cat $first/file)" = "second" +test "$(cat $second/file)" = "first" + +echo "success" > $out/file diff --git a/tests/multiple-outputs.nix b/tests/multiple-outputs.nix new file mode 100644 index 000000000000..e8fbf91bfa89 --- /dev/null +++ b/tests/multiple-outputs.nix @@ -0,0 +1,23 @@ +with import ./config.nix; + +let + + a = mkDerivation { + name = "multiple-outputs-a"; + outputs = [ "first" "second" ]; + builder = ./multiple-outputs.a.builder.sh; + helloString = "Hello, world!"; + }; + +in + +assert a.second.helloString == "Hello, world!"; + +mkDerivation { + defaultOutput = a; + firstOutput = a.first.first; + secondOutput = a.second.first.first.second.second.first.second; + allOutputs = a.all; + name = "multiple-outputs-b"; + builder = ./multiple-outputs.b.builder.sh; +} diff --git a/tests/multiple-outputs.sh b/tests/multiple-outputs.sh new file mode 100644 index 000000000000..f4cd01234c5b --- /dev/null +++ b/tests/multiple-outputs.sh @@ -0,0 +1,15 @@ +source common.sh + +echo "Testing multiple outputs..." + +drvPath=$($nixinstantiate multiple-outputs.nix) + +echo "derivation is $drvPath" + +outPath=$($nixstore -rvv "$drvPath") + +echo "output path is $outPath" + +text=$(cat "$outPath"/file) +if test "$text" != "success"; then exit 1; fi + -- cgit 1.4.1