mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
* 1000th revision!
* A test to verify that locking of output paths (caused by concurrent invocations of Nix) works correctly.
This commit is contained in:
parent
a7bbe73971
commit
f044ccf702
4 changed files with 50 additions and 2 deletions
|
@ -11,11 +11,15 @@ TESTS_ENVIRONMENT = TEST_ROOT=$(TEST_ROOT) \
|
||||||
|
|
||||||
simple.sh: simple.nix
|
simple.sh: simple.nix
|
||||||
dependencies.sh: dependencies.nix
|
dependencies.sh: dependencies.nix
|
||||||
|
locking.sh: locking.nix
|
||||||
|
|
||||||
TESTS = init.sh simple.sh dependencies.sh
|
TESTS = init.sh simple.sh dependencies.sh locking.sh
|
||||||
|
|
||||||
|
XFAIL_TESTS =
|
||||||
|
|
||||||
include ../substitute.mk
|
include ../substitute.mk
|
||||||
|
|
||||||
EXTRA_DIST = $(TESTS) \
|
EXTRA_DIST = $(TESTS) \
|
||||||
simple.nix.in simple.builder.sh \
|
simple.nix.in simple.builder.sh \
|
||||||
dependencies.nix.in dependencies.builder*.sh
|
dependencies.nix.in dependencies.builder*.sh \
|
||||||
|
locking.nix.in locking.builder.sh
|
9
tests/locking.builder.sh
Normal file
9
tests/locking.builder.sh
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
export PATH=/bin:/usr/bin:$PATH
|
||||||
|
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
touch $out
|
||||||
|
# Use `>>'; without proper locking this will cause text duplication.
|
||||||
|
echo -n $(cat $inputs)$text >> $out
|
||||||
|
|
||||||
|
sleep 2
|
18
tests/locking.nix.in
Normal file
18
tests/locking.nix.in
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
let {
|
||||||
|
|
||||||
|
mkDrv = text: inputs: derivation {
|
||||||
|
name = "locking";
|
||||||
|
system = "@system@";
|
||||||
|
builder = "@shell@";
|
||||||
|
args = ["-e" "-x" ./locking.builder.sh];
|
||||||
|
inherit text inputs;
|
||||||
|
};
|
||||||
|
|
||||||
|
a = mkDrv "a" [];
|
||||||
|
b = mkDrv "b" [a];
|
||||||
|
c = mkDrv "c" [a b];
|
||||||
|
d = mkDrv "d" [a];
|
||||||
|
e = mkDrv "e" [c d];
|
||||||
|
|
||||||
|
body = e;
|
||||||
|
}
|
17
tests/locking.sh
Normal file
17
tests/locking.sh
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
storeExpr=$($TOP/src/nix-instantiate/nix-instantiate locking.nix)
|
||||||
|
|
||||||
|
echo "store expr is $storeExpr"
|
||||||
|
|
||||||
|
for i in $(seq 1 5); do
|
||||||
|
echo "WORKER $i"
|
||||||
|
$TOP/src/nix-store/nix-store -rvvB "$storeExpr" &
|
||||||
|
done
|
||||||
|
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
outPath=$($TOP/src/nix-store/nix-store -qnfvvvvv "$storeExpr")
|
||||||
|
|
||||||
|
echo "output path is $outPath"
|
||||||
|
|
||||||
|
text=$(cat "$outPath")
|
||||||
|
if test "$text" != "aabcade"; then exit 1; fi
|
Loading…
Reference in a new issue