* Tests for fixed-output derivations (and attribute selection, incidentally).

This commit is contained in:
Eelco Dolstra 2006-03-01 18:26:21 +00:00
parent 2167bf6b72
commit 78d84f5631
5 changed files with 67 additions and 1 deletions

View File

@ -12,11 +12,12 @@ substitutes2.sh: substitutes2.nix
fallback.sh: fallback.nix
gc-concurrent.sh: gc-concurrent.nix gc-concurrent2.nix
user-envs.sh: user-envs.nix
fixed.sh: fixed.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 \
referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh
referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh
XFAIL_TESTS =
@ -36,5 +37,6 @@ EXTRA_DIST = $(TESTS) \
gc-concurrent2.nix.in gc-concurrent2.builder.sh \
fallback.nix.in \
user-envs.nix.in user-envs.builder.sh \
fixed.nix.in fixed.builder1.sh fixed.builder2.sh \
$(wildcard lang/*.nix) $(wildcard lang/*.exp) \
common.sh.in

3
tests/fixed.builder1.sh Normal file
View File

@ -0,0 +1,3 @@
export PATH=/bin:/usr/bin:$PATH
echo "Hello World!" > $out

6
tests/fixed.builder2.sh Normal file
View File

@ -0,0 +1,6 @@
export PATH=/bin:/usr/bin:$PATH
mkdir $out
mkdir $out/bla
echo "Hello World!" > $out/foo
ln -s foo $out/bar

37
tests/fixed.nix.in Normal file
View File

@ -0,0 +1,37 @@
rec {
f = builder: mode: algo: hash: derivation {
name = "fixed";
system = "@system@";
builder = "@shell@";
args = ["-e" "-x" builder];
outputHashMode = mode;
outputHashAlgo = algo;
outputHash = hash;
};
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")
(f ./fixed.builder2.sh "recursive" "sha256" "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik")
];
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")
];
bad = [
(f ./fixed.builder1.sh "flat" "md5" "0ddd8be4b179a529afa5f2ffae4b9858")
];
reallyBad = [
# Hash too short, and not base-32 either.
(f ./fixed.builder1.sh "flat" "md5" "ddd8be4b179a529afa5f2ffae4b9858")
];
}

18
tests/fixed.sh Normal file
View File

@ -0,0 +1,18 @@
source common.sh
drvs=$($nixinstantiate fixed.nix -A good)
echo $drvs
$nixstore -r $drvs
drvs=$($nixinstantiate fixed.nix -A good2)
echo $drvs
$nixstore -r $drvs
drvs=$($nixinstantiate fixed.nix -A bad)
echo $drvs
if $nixstore -r $drvs; then false; fi
if $nixinstantiate fixed.nix -A reallyBad; then false; fi
# While we're at it, check attribute selection a bit more.
test $($nixinstantiate fixed.nix -A good.1 | wc -l) = 1