* Regression test for the `exportReferencesGraph'

derivation attribute.
This commit is contained in:
Eelco Dolstra 2009-03-17 16:33:48 +00:00
parent 33ecb42991
commit 2d5114452d
8 changed files with 69 additions and 33 deletions

View File

@ -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 \

9
tests/config.nix.in Normal file
View File

@ -0,0 +1,9 @@
{
mkDerivation = args:
derivation ({
system = "@system@";
builder = "@shell@";
args = ["-e" args.builder];
PATH = "@testPath@";
} // removeAttrs args ["builder"]);
}

View File

@ -5,3 +5,5 @@ ln -s $input2 $out/input-2
# Self-reference.
ln -s $out $out/self
echo FOO

22
tests/dependencies.nix Normal file
View File

@ -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;
};
}

View File

@ -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;
};
}

23
tests/export-graph.nix Normal file
View File

@ -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)];
};
}

9
tests/export-graph.sh Normal file
View File

@ -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"

View File

@ -19,5 +19,5 @@ if test "$xsltproc" != "false"; then
# Ideally we would check that the generated HTML is valid...
# A few checks...
grep "<li>.*<code>.*echo FOO" $TEST_ROOT/log.html
grep "<li>.*<code>.*FOO" $TEST_ROOT/log.html
fi