From 51e7e32c3bf7c2fb5045b0655c2edc1fbf347455 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 17 Mar 2009 17:11:55 +0000 Subject: * Refactoring: renamed *.nix.in to *.nix. --- tests/Makefile.am | 36 +++++++++------------------ tests/build-hook.nix | 21 ++++++++++++++++ tests/build-hook.nix.in | 28 --------------------- tests/check-refs.nix | 58 ++++++++++++++++++++++++++++++++++++++++++++ tests/check-refs.nix.in | 59 --------------------------------------------- tests/config.nix.in | 16 +++++++++--- tests/export-graph.nix | 1 - tests/filter-source.nix | 12 +++++++++ tests/filter-source.nix.in | 12 --------- tests/fixed.nix | 50 ++++++++++++++++++++++++++++++++++++++ tests/fixed.nix.in | 51 --------------------------------------- tests/gc-concurrent.nix | 27 +++++++++++++++++++++ tests/gc-concurrent.nix.in | 28 --------------------- tests/gc-concurrent.sh | 4 +-- tests/gc-concurrent2.nix.in | 28 --------------------- tests/gc-runtime.nix | 17 +++++++++++++ tests/gc-runtime.nix.in | 23 ------------------ tests/locking.nix | 17 +++++++++++++ tests/locking.nix.in | 19 --------------- tests/parallel.nix | 17 +++++++++++++ tests/parallel.nix.in | 20 --------------- tests/simple.nix | 8 ++++++ tests/simple.nix.in | 7 ------ tests/user-envs.nix | 28 +++++++++++++++++++++ tests/user-envs.nix.in | 30 ----------------------- 25 files changed, 281 insertions(+), 336 deletions(-) create mode 100644 tests/build-hook.nix delete mode 100644 tests/build-hook.nix.in create mode 100644 tests/check-refs.nix delete mode 100644 tests/check-refs.nix.in create mode 100644 tests/filter-source.nix delete mode 100644 tests/filter-source.nix.in create mode 100644 tests/fixed.nix delete mode 100644 tests/fixed.nix.in create mode 100644 tests/gc-concurrent.nix delete mode 100644 tests/gc-concurrent.nix.in delete mode 100644 tests/gc-concurrent2.nix.in create mode 100644 tests/gc-runtime.nix delete mode 100644 tests/gc-runtime.nix.in create mode 100644 tests/locking.nix delete mode 100644 tests/locking.nix.in create mode 100644 tests/parallel.nix delete mode 100644 tests/parallel.nix.in create mode 100644 tests/simple.nix delete mode 100644 tests/simple.nix.in create mode 100644 tests/user-envs.nix delete mode 100644 tests/user-envs.nix.in diff --git a/tests/Makefile.am b/tests/Makefile.am index e61d4faa85a7..cad41d0526c1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,18 +2,6 @@ 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 export-graph.sh: config.nix -locking.sh: locking.nix -parallel.sh: parallel.nix -build-hook.sh: build-hook.nix -gc-concurrent.sh: gc-concurrent.nix gc-concurrent2.nix simple.nix -user-envs.sh: user-envs.nix -fixed.sh: fixed.nix -gc-runtime.sh: gc-runtime.nix -check-refs.sh: check-refs.nix -filter-source.sh: filter-source.nix - TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \ locking.sh parallel.sh build-hook.sh substitutes.sh substitutes2.sh \ fallback.sh nix-push.sh gc.sh gc-concurrent.sh verify.sh nix-pull.sh \ @@ -25,22 +13,22 @@ XFAIL_TESTS = include ../substitute.mk -$(TESTS): common.sh +$(TESTS): common.sh config.nix EXTRA_DIST = $(TESTS) \ - simple.nix.in simple.builder.sh \ + simple.nix simple.builder.sh \ hash-check.nix \ 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 \ + locking.nix locking.builder.sh \ + parallel.nix parallel.builder.sh \ + build-hook.nix build-hook.hook.sh \ substituter.sh substituter2.sh \ - gc-concurrent.nix.in gc-concurrent.builder.sh \ - gc-concurrent2.nix.in gc-concurrent2.builder.sh \ - user-envs.nix.in user-envs.builder.sh \ - fixed.nix.in fixed.builder1.sh fixed.builder2.sh \ - gc-runtime.nix.in \ - check-refs.nix.in \ - filter-source.nix.in \ + gc-concurrent.nix gc-concurrent.builder.sh gc-concurrent2.builder.sh \ + user-envs.nix user-envs.builder.sh \ + fixed.nix fixed.builder1.sh fixed.builder2.sh \ + gc-runtime.nix \ + check-refs.nix \ + filter-source.nix \ + export-graph.nix \ $(wildcard lang/*.nix) $(wildcard lang/*.exp) $(wildcard lang/*.exp.xml) $(wildcard lang/*.flags) \ common.sh.in diff --git a/tests/build-hook.nix b/tests/build-hook.nix new file mode 100644 index 000000000000..e4954537f393 --- /dev/null +++ b/tests/build-hook.nix @@ -0,0 +1,21 @@ +with import ./config.nix; + +let + + input1 = mkDerivation { + name = "build-hook-input-1"; + builder = ./dependencies.builder1.sh; + }; + + input2 = mkDerivation { + name = "build-hook-input-2"; + builder = ./dependencies.builder2.sh; + }; + +in + + mkDerivation { + name = "build-hook"; + builder = ./dependencies.builder0.sh; + inherit input1 input2; + } diff --git a/tests/build-hook.nix.in b/tests/build-hook.nix.in deleted file mode 100644 index 697cab81e104..000000000000 --- a/tests/build-hook.nix.in +++ /dev/null @@ -1,28 +0,0 @@ -let { - - input1 = derivation { - name = "build-hook-input-1"; - system = "@system@"; - builder = "@shell@"; - args = ["-e" "-x" ./dependencies.builder1.sh]; - PATH = "@testPath@"; - }; - - input2 = derivation { - name = "build-hook-input-2"; - system = "@system@"; - builder = "@shell@"; - args = ["-e" "-x" ./dependencies.builder2.sh]; - PATH = "@testPath@"; - }; - - body = derivation { - name = "build-hook"; - system = "@system@"; - builder = "@shell@"; - args = ["-e" "-x" ./dependencies.builder0.sh]; - PATH = "@testPath@"; - inherit input1 input2; - }; - -} \ No newline at end of file diff --git a/tests/check-refs.nix b/tests/check-refs.nix new file mode 100644 index 000000000000..63791fe16094 --- /dev/null +++ b/tests/check-refs.nix @@ -0,0 +1,58 @@ +with import ./config.nix; + +rec { + + dep = import ./dependencies.nix; + + makeTest = nr: args: mkDerivation ({ + name = "check-refs-" + toString nr; + } // args); + + src = builtins.toFile "aux-ref" "bla bla"; + + test1 = makeTest 1 { + builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link"; + inherit dep; + }; + + test2 = makeTest 2 { + builder = builtins.toFile "builder.sh" "mkdir $out; ln -s ${src} $out/link"; + inherit dep; + }; + + test3 = makeTest 3 { + builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link"; + allowedReferences = []; + inherit dep; + }; + + test4 = makeTest 4 { + builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link"; + allowedReferences = [dep]; + inherit dep; + }; + + test5 = makeTest 5 { + builder = builtins.toFile "builder.sh" "mkdir $out"; + allowedReferences = []; + inherit dep; + }; + + test6 = makeTest 6 { + builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $out $out/link"; + allowedReferences = []; + inherit dep; + }; + + test7 = makeTest 7 { + builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $out $out/link"; + allowedReferences = ["out"]; + inherit dep; + }; + + test8 = makeTest 8 { + builder = builtins.toFile "builder.sh" "mkdir $out; ln -s ${test1} $out/link"; + inherit dep; + }; + +} diff --git a/tests/check-refs.nix.in b/tests/check-refs.nix.in deleted file mode 100644 index a3738fa43d20..000000000000 --- a/tests/check-refs.nix.in +++ /dev/null @@ -1,59 +0,0 @@ -rec { - - dep = import ./dependencies.nix; - - makeTest = nr: args: derivation ({ - name = "check-refs-" + toString nr; - system = "@system@"; - builder = "@shell@"; - PATH = "@testPath@"; - } // args); - - src = builtins.toFile "aux-ref" "bla bla"; - - test1 = makeTest 1 { - args = ["-e" "-x" (builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link")]; - inherit dep; - }; - - test2 = makeTest 2 { - args = ["-e" "-x" (builtins.toFile "builder.sh" "mkdir $out; ln -s ${src} $out/link")]; - inherit dep; - }; - - test3 = makeTest 3 { - args = ["-e" "-x" (builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link")]; - allowedReferences = []; - inherit dep; - }; - - test4 = makeTest 4 { - args = ["-e" "-x" (builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link")]; - allowedReferences = [dep]; - inherit dep; - }; - - test5 = makeTest 5 { - args = ["-e" "-x" (builtins.toFile "builder.sh" "mkdir $out")]; - allowedReferences = []; - inherit dep; - }; - - test6 = makeTest 6 { - args = ["-e" "-x" (builtins.toFile "builder.sh" "mkdir $out; ln -s $out $out/link")]; - allowedReferences = []; - inherit dep; - }; - - test7 = makeTest 7 { - args = ["-e" "-x" (builtins.toFile "builder.sh" "mkdir $out; ln -s $out $out/link")]; - allowedReferences = ["out"]; - inherit dep; - }; - - test8 = makeTest 8 { - args = ["-e" "-x" (builtins.toFile "builder.sh" "mkdir $out; ln -s ${test1} $out/link")]; - inherit dep; - }; - -} diff --git a/tests/config.nix.in b/tests/config.nix.in index a58295f9828f..2bfee8b44b19 100644 --- a/tests/config.nix.in +++ b/tests/config.nix.in @@ -1,9 +1,17 @@ -{ +rec { + shell = "@shell@"; + + path = "@testPath@"; + + system = "@system@"; + + shared = "@extra1@"; + mkDerivation = args: derivation ({ - system = "@system@"; - builder = "@shell@"; + inherit system; + builder = shell; args = ["-e" args.builder]; - PATH = "@testPath@"; + PATH = path; } // removeAttrs args ["builder"]); } diff --git a/tests/export-graph.nix b/tests/export-graph.nix index 3e30d2dcea7a..b7afa2a85b9b 100644 --- a/tests/export-graph.nix +++ b/tests/export-graph.nix @@ -4,7 +4,6 @@ rec { buildGraphBuilder = builtins.toFile "build-graph-builder" '' - #cat refs while read path; do read drv read nrRefs diff --git a/tests/filter-source.nix b/tests/filter-source.nix new file mode 100644 index 000000000000..a620f0fda5c4 --- /dev/null +++ b/tests/filter-source.nix @@ -0,0 +1,12 @@ +with import ./config.nix; + +mkDerivation { + name = "filter"; + builder = builtins.toFile "builder" "ln -s $input $out"; + input = + let filter = path: type: + type != "symlink" + && baseNameOf path != "foo" + && !((import ./lang/lib.nix).hasSuffix ".bak" (baseNameOf path)); + in builtins.filterSource filter ./test-tmp/filterin; +} diff --git a/tests/filter-source.nix.in b/tests/filter-source.nix.in deleted file mode 100644 index 6fd494794e0c..000000000000 --- a/tests/filter-source.nix.in +++ /dev/null @@ -1,12 +0,0 @@ -derivation { - name = "filter"; - system = "@system@"; - builder = "@shell@"; - args = ["-e" "-x" (builtins.toFile "builder" "PATH=@testPath@; ln -s $input $out")]; - input = - let filter = path: type: - type != "symlink" - && baseNameOf path != "foo" - && !((import ./lang/lib.nix).hasSuffix ".bak" (baseNameOf path)); - in builtins.filterSource filter ./test-tmp/filterin; -} diff --git a/tests/fixed.nix b/tests/fixed.nix new file mode 100644 index 000000000000..76580ffa19e8 --- /dev/null +++ b/tests/fixed.nix @@ -0,0 +1,50 @@ +with import ./config.nix; + +rec { + + f2 = dummy: builder: mode: algo: hash: mkDerivation { + name = "fixed"; + inherit builder; + outputHashMode = mode; + outputHashAlgo = algo; + outputHash = hash; + inherit dummy; + impureEnvVars = ["IMPURE_VAR1" "IMPURE_VAR2"]; + }; + + f = f2 ""; + + good = [ + (f ./fixed.builder1.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858") + (f ./fixed.builder1.sh "flat" "sha1" "a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b") + (f ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42") + (f ./fixed.builder2.sh "recursive" "sha1" "vw46m23bizj4n8afrc0fj19wrp7mj3c0") + ]; + + good2 = [ + # Yes, this looks fscked up: builder2 doesn't have that result. + # But Nix sees that an output with the desired hash already + # exists, and will refrain from building it. + (f ./fixed.builder2.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858") + ]; + + sameAsAdd = + f ./fixed.builder2.sh "recursive" "sha256" "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik"; + + bad = [ + (f ./fixed.builder1.sh "flat" "md5" "0ddd8be4b179a529afa5f2ffae4b9858") + ]; + + reallyBad = [ + # Hash too short, and not base-32 either. + (f ./fixed.builder1.sh "flat" "md5" "ddd8be4b179a529afa5f2ffae4b9858") + ]; + + # Test for building two derivations in parallel that produce the + # same output path because they're fixed-output derivations. + parallelSame = [ + (f2 "foo" ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42") + (f2 "bar" ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42") + ]; + +} diff --git a/tests/fixed.nix.in b/tests/fixed.nix.in deleted file mode 100644 index ad5306cf6ac4..000000000000 --- a/tests/fixed.nix.in +++ /dev/null @@ -1,51 +0,0 @@ -rec { - - f2 = dummy: builder: mode: algo: hash: derivation { - name = "fixed"; - system = "@system@"; - builder = "@shell@"; - args = ["-e" "-x" builder]; - outputHashMode = mode; - outputHashAlgo = algo; - outputHash = hash; - PATH = "@testPath@"; - inherit dummy; - impureEnvVars = ["IMPURE_VAR1" "IMPURE_VAR2"]; - }; - - f = f2 ""; - - good = [ - (f ./fixed.builder1.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858") - (f ./fixed.builder1.sh "flat" "sha1" "a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b") - (f ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42") - (f ./fixed.builder2.sh "recursive" "sha1" "vw46m23bizj4n8afrc0fj19wrp7mj3c0") - ]; - - good2 = [ - # Yes, this looks fscked up: builder2 doesn't have that result. - # But Nix sees that an output with the desired hash already - # exists, and will refrain from building it. - (f ./fixed.builder2.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858") - ]; - - sameAsAdd = - f ./fixed.builder2.sh "recursive" "sha256" "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik"; - - bad = [ - (f ./fixed.builder1.sh "flat" "md5" "0ddd8be4b179a529afa5f2ffae4b9858") - ]; - - reallyBad = [ - # Hash too short, and not base-32 either. - (f ./fixed.builder1.sh "flat" "md5" "ddd8be4b179a529afa5f2ffae4b9858") - ]; - - # Test for building two derivations in parallel that produce the - # same output path because they're fixed-output derivations. - parallelSame = [ - (f2 "foo" ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42") - (f2 "bar" ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42") - ]; - -} diff --git a/tests/gc-concurrent.nix b/tests/gc-concurrent.nix new file mode 100644 index 000000000000..c0595cc471b9 --- /dev/null +++ b/tests/gc-concurrent.nix @@ -0,0 +1,27 @@ +with import ./config.nix; + +rec { + + input1 = mkDerivation { + name = "dependencies-input-1"; + builder = ./dependencies.builder1.sh; + }; + + input2 = mkDerivation { + name = "dependencies-input-2"; + builder = ./dependencies.builder2.sh; + }; + + test1 = mkDerivation { + name = "gc-concurrent"; + builder = ./gc-concurrent.builder.sh; + inherit input1 input2; + }; + + test2 = mkDerivation { + name = "gc-concurrent2"; + builder = ./gc-concurrent2.builder.sh; + inherit input1 input2; + }; + +} diff --git a/tests/gc-concurrent.nix.in b/tests/gc-concurrent.nix.in deleted file mode 100644 index cf9f673137da..000000000000 --- a/tests/gc-concurrent.nix.in +++ /dev/null @@ -1,28 +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 = "gc-concurrent"; - system = "@system@"; - builder = "@shell@"; - args = ["-e" "-x" ./gc-concurrent.builder.sh]; - PATH = "@testPath@"; - inherit input1 input2; - }; - -} \ No newline at end of file diff --git a/tests/gc-concurrent.sh b/tests/gc-concurrent.sh index fbc9497206c1..8ae511e4facd 100644 --- a/tests/gc-concurrent.sh +++ b/tests/gc-concurrent.sh @@ -2,10 +2,10 @@ source common.sh $NIX_BIN_DIR/nix-collect-garbage -vvvvv -drvPath1=$($nixinstantiate gc-concurrent.nix) +drvPath1=$($nixinstantiate gc-concurrent.nix -A test1) outPath1=$($nixstore -q $drvPath1) -drvPath2=$($nixinstantiate gc-concurrent2.nix) +drvPath2=$($nixinstantiate gc-concurrent.nix -A test2) outPath2=$($nixstore -q $drvPath2) drvPath3=$($nixinstantiate simple.nix) diff --git a/tests/gc-concurrent2.nix.in b/tests/gc-concurrent2.nix.in deleted file mode 100644 index d331e9c82d9f..000000000000 --- a/tests/gc-concurrent2.nix.in +++ /dev/null @@ -1,28 +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 = "gc-concurrent2"; - system = "@system@"; - builder = "@shell@"; - args = ["-e" "-x" ./gc-concurrent2.builder.sh]; - PATH = "@testPath@"; - inherit input1 input2; - }; - -} \ No newline at end of file diff --git a/tests/gc-runtime.nix b/tests/gc-runtime.nix new file mode 100644 index 000000000000..ee5980bdff98 --- /dev/null +++ b/tests/gc-runtime.nix @@ -0,0 +1,17 @@ +with import ./config.nix; + +mkDerivation { + name = "gc-runtime"; + builder = + # Test inline source file definitions. + builtins.toFile "builder.sh" '' + mkdir $out + + cat > $out/program < $out/program <