forked from lix-project/lix
* Refactor a bit so that more tests can be added.
This commit is contained in:
parent
b5363810bb
commit
46e42c92c1
|
@ -36,7 +36,6 @@ EXTRA_DIST = $(TESTS) \
|
||||||
timeout.nix timeout.builder.sh \
|
timeout.nix timeout.builder.sh \
|
||||||
secure-drv-outputs.nix \
|
secure-drv-outputs.nix \
|
||||||
multiple-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) \
|
$(wildcard lang/*.nix) $(wildcard lang/*.exp) $(wildcard lang/*.exp.xml) $(wildcard lang/*.flags) $(wildcard lang/dir*/*.nix) \
|
||||||
common.sh.in
|
common.sh.in
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
mkdir $first
|
|
||||||
mkdir $second
|
|
||||||
test -z $all
|
|
||||||
|
|
||||||
echo "second" > $first/file
|
|
||||||
echo "first" > $second/file
|
|
|
@ -1,7 +0,0 @@
|
||||||
mkdir $out
|
|
||||||
test "$firstOutput $secondOutput" = "$allOutputs"
|
|
||||||
test "$defaultOutput" = "$firstOutput"
|
|
||||||
test "$(cat $firstOutput/file)" = "second"
|
|
||||||
test "$(cat $secondOutput/file)" = "first"
|
|
||||||
|
|
||||||
echo "success" > $out/file
|
|
|
@ -1,23 +1,35 @@
|
||||||
with import ./config.nix;
|
with import ./config.nix;
|
||||||
|
|
||||||
let
|
rec {
|
||||||
|
|
||||||
a = mkDerivation {
|
a = mkDerivation {
|
||||||
name = "multiple-outputs-a";
|
name = "multiple-outputs-a";
|
||||||
outputs = [ "first" "second" ];
|
outputs = [ "first" "second" ];
|
||||||
builder = ./multiple-outputs.a.builder.sh;
|
builder = builtins.toFile "builder.sh"
|
||||||
|
''
|
||||||
|
mkdir $first $second
|
||||||
|
test -z $all
|
||||||
|
echo "second" > $first/file
|
||||||
|
echo "first" > $second/file
|
||||||
|
'';
|
||||||
helloString = "Hello, world!";
|
helloString = "Hello, world!";
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
b = mkDerivation {
|
||||||
|
defaultOutput = assert a.second.helloString == "Hello, world!"; a;
|
||||||
assert a.second.helloString == "Hello, world!";
|
|
||||||
|
|
||||||
mkDerivation {
|
|
||||||
defaultOutput = a;
|
|
||||||
firstOutput = a.first.first;
|
firstOutput = a.first.first;
|
||||||
secondOutput = a.second.first.first.second.second.first.second;
|
secondOutput = a.second.first.first.second.second.first.second;
|
||||||
allOutputs = a.all;
|
allOutputs = a.all;
|
||||||
name = "multiple-outputs-b";
|
name = "multiple-outputs-b";
|
||||||
builder = ./multiple-outputs.b.builder.sh;
|
builder = builtins.toFile "builder.sh"
|
||||||
|
''
|
||||||
|
mkdir $out
|
||||||
|
test "$firstOutput $secondOutput" = "$allOutputs"
|
||||||
|
test "$defaultOutput" = "$firstOutput"
|
||||||
|
test "$(cat $firstOutput/file)" = "second"
|
||||||
|
test "$(cat $secondOutput/file)" = "first"
|
||||||
|
echo "success" > $out/file
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,6 @@ source common.sh
|
||||||
|
|
||||||
echo "Testing multiple outputs..."
|
echo "Testing multiple outputs..."
|
||||||
|
|
||||||
drvPath=$(nix-instantiate multiple-outputs.nix)
|
outPath=$(nix-build multiple-outputs.nix -A b)
|
||||||
|
|
||||||
echo "derivation is $drvPath"
|
|
||||||
|
|
||||||
outPath=$(nix-store -rvv "$drvPath")
|
|
||||||
|
|
||||||
echo "output path is $outPath"
|
echo "output path is $outPath"
|
||||||
|
[ "$(cat "$outPath"/file)" = "success" ]
|
||||||
text=$(cat "$outPath"/file)
|
|
||||||
if test "$text" != "success"; then exit 1; fi
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue