mirror of
https://github.com/NixOS/nix
synced 2025-07-08 02:43:54 +02:00
Merge remote-tracking branch 'origin/master' into nix-profile-stable-names
This commit is contained in:
commit
e21b3cf9db
147 changed files with 3377 additions and 1263 deletions
|
@ -40,3 +40,11 @@ if [[ ! -n "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
|||
(! ls $NIX_STORE_DIR/*.drv)
|
||||
fi
|
||||
ls $eval_store/nix/store/*.drv
|
||||
|
||||
clearStore
|
||||
rm -rf "$eval_store"
|
||||
|
||||
# Confirm that import-from-derivation builds on the build store
|
||||
[[ $(nix eval --eval-store "$eval_store?require-sigs=false" --impure --raw --file ./ifd.nix) = hi ]]
|
||||
ls $NIX_STORE_DIR/*dependencies-top/foobar
|
||||
(! ls $eval_store/nix/store/*dependencies-top/foobar)
|
||||
|
|
|
@ -48,6 +48,15 @@ rec {
|
|||
(f ./fixed.builder1.sh "flat" "md5" "ddd8be4b179a529afa5f2ffae4b9858")
|
||||
];
|
||||
|
||||
badReferences = mkDerivation rec {
|
||||
name = "bad-hash";
|
||||
builder = script;
|
||||
script = builtins.toFile "installer.sh" "echo $script >$out";
|
||||
outputHash = "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "flat";
|
||||
};
|
||||
|
||||
# Test for building two derivations in parallel that produce the
|
||||
# same output path because they're fixed-output derivations.
|
||||
parallelSame = [
|
||||
|
|
|
@ -26,6 +26,11 @@ nix-build fixed.nix -A good2 --no-out-link
|
|||
echo 'testing reallyBad...'
|
||||
nix-instantiate fixed.nix -A reallyBad && fail "should fail"
|
||||
|
||||
if isDaemonNewer "2.20pre20240108"; then
|
||||
echo 'testing fixed with references...'
|
||||
expectStderr 1 nix-build fixed.nix -A badReferences | grepQuiet "not allowed to refer to other store paths"
|
||||
fi
|
||||
|
||||
# While we're at it, check attribute selection a bit more.
|
||||
echo 'testing attribute selection...'
|
||||
test $(nix-instantiate fixed.nix -A good.1 | wc -l) = 1
|
||||
|
|
10
tests/functional/ifd.nix
Normal file
10
tests/functional/ifd.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
with import ./config.nix;
|
||||
import (
|
||||
mkDerivation {
|
||||
name = "foo";
|
||||
bla = import ./dependencies.nix {};
|
||||
buildCommand = "
|
||||
echo \\\"hi\\\" > $out
|
||||
";
|
||||
}
|
||||
)
|
44
tests/functional/lang/eval-fail-duplicate-traces.err.exp
Normal file
44
tests/functional/lang/eval-fail-duplicate-traces.err.exp
Normal file
|
@ -0,0 +1,44 @@
|
|||
error:
|
||||
… from call site
|
||||
at /pwd/lang/eval-fail-duplicate-traces.nix:9:3:
|
||||
8| in
|
||||
9| throwAfter 2
|
||||
| ^
|
||||
10|
|
||||
|
||||
… while calling 'throwAfter'
|
||||
at /pwd/lang/eval-fail-duplicate-traces.nix:4:16:
|
||||
3| let
|
||||
4| throwAfter = n:
|
||||
| ^
|
||||
5| if n > 0
|
||||
|
||||
… from call site
|
||||
at /pwd/lang/eval-fail-duplicate-traces.nix:6:10:
|
||||
5| if n > 0
|
||||
6| then throwAfter (n - 1)
|
||||
| ^
|
||||
7| else throw "Uh oh!";
|
||||
|
||||
… while calling 'throwAfter'
|
||||
at /pwd/lang/eval-fail-duplicate-traces.nix:4:16:
|
||||
3| let
|
||||
4| throwAfter = n:
|
||||
| ^
|
||||
5| if n > 0
|
||||
|
||||
… from call site
|
||||
at /pwd/lang/eval-fail-duplicate-traces.nix:6:10:
|
||||
5| if n > 0
|
||||
6| then throwAfter (n - 1)
|
||||
| ^
|
||||
7| else throw "Uh oh!";
|
||||
|
||||
… while calling 'throwAfter'
|
||||
at /pwd/lang/eval-fail-duplicate-traces.nix:4:16:
|
||||
3| let
|
||||
4| throwAfter = n:
|
||||
| ^
|
||||
5| if n > 0
|
||||
|
||||
error: Uh oh!
|
9
tests/functional/lang/eval-fail-duplicate-traces.nix
Normal file
9
tests/functional/lang/eval-fail-duplicate-traces.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Check that we only omit duplicate stack traces when there's a bunch of them.
|
||||
# Here, there's only a couple duplicate entries, so we output them all.
|
||||
let
|
||||
throwAfter = n:
|
||||
if n > 0
|
||||
then throwAfter (n - 1)
|
||||
else throw "Uh oh!";
|
||||
in
|
||||
throwAfter 2
|
|
@ -0,0 +1,38 @@
|
|||
error:
|
||||
… from call site
|
||||
at /pwd/lang/eval-fail-infinite-recursion-lambda.nix:1:1:
|
||||
1| (x: x x) (x: x x)
|
||||
| ^
|
||||
2|
|
||||
|
||||
… while calling anonymous lambda
|
||||
at /pwd/lang/eval-fail-infinite-recursion-lambda.nix:1:2:
|
||||
1| (x: x x) (x: x x)
|
||||
| ^
|
||||
2|
|
||||
|
||||
… from call site
|
||||
at /pwd/lang/eval-fail-infinite-recursion-lambda.nix:1:5:
|
||||
1| (x: x x) (x: x x)
|
||||
| ^
|
||||
2|
|
||||
|
||||
… while calling anonymous lambda
|
||||
at /pwd/lang/eval-fail-infinite-recursion-lambda.nix:1:11:
|
||||
1| (x: x x) (x: x x)
|
||||
| ^
|
||||
2|
|
||||
|
||||
… from call site
|
||||
at /pwd/lang/eval-fail-infinite-recursion-lambda.nix:1:14:
|
||||
1| (x: x x) (x: x x)
|
||||
| ^
|
||||
2|
|
||||
|
||||
(19997 duplicate frames omitted)
|
||||
|
||||
error: stack overflow; max-call-depth exceeded
|
||||
at /pwd/lang/eval-fail-infinite-recursion-lambda.nix:1:14:
|
||||
1| (x: x x) (x: x x)
|
||||
| ^
|
||||
2|
|
|
@ -0,0 +1 @@
|
|||
(x: x x) (x: x x)
|
57
tests/functional/lang/eval-fail-mutual-recursion.err.exp
Normal file
57
tests/functional/lang/eval-fail-mutual-recursion.err.exp
Normal file
|
@ -0,0 +1,57 @@
|
|||
error:
|
||||
… from call site
|
||||
at /pwd/lang/eval-fail-mutual-recursion.nix:36:3:
|
||||
35| in
|
||||
36| throwAfterA true 10
|
||||
| ^
|
||||
37|
|
||||
|
||||
… while calling 'throwAfterA'
|
||||
at /pwd/lang/eval-fail-mutual-recursion.nix:29:26:
|
||||
28|
|
||||
29| throwAfterA = recurse: n:
|
||||
| ^
|
||||
30| if n > 0
|
||||
|
||||
… from call site
|
||||
at /pwd/lang/eval-fail-mutual-recursion.nix:31:10:
|
||||
30| if n > 0
|
||||
31| then throwAfterA recurse (n - 1)
|
||||
| ^
|
||||
32| else if recurse
|
||||
|
||||
(19 duplicate frames omitted)
|
||||
|
||||
… from call site
|
||||
at /pwd/lang/eval-fail-mutual-recursion.nix:33:10:
|
||||
32| else if recurse
|
||||
33| then throwAfterB true 10
|
||||
| ^
|
||||
34| else throw "Uh oh!";
|
||||
|
||||
… while calling 'throwAfterB'
|
||||
at /pwd/lang/eval-fail-mutual-recursion.nix:22:26:
|
||||
21| let
|
||||
22| throwAfterB = recurse: n:
|
||||
| ^
|
||||
23| if n > 0
|
||||
|
||||
… from call site
|
||||
at /pwd/lang/eval-fail-mutual-recursion.nix:24:10:
|
||||
23| if n > 0
|
||||
24| then throwAfterB recurse (n - 1)
|
||||
| ^
|
||||
25| else if recurse
|
||||
|
||||
(19 duplicate frames omitted)
|
||||
|
||||
… from call site
|
||||
at /pwd/lang/eval-fail-mutual-recursion.nix:26:10:
|
||||
25| else if recurse
|
||||
26| then throwAfterA false 10
|
||||
| ^
|
||||
27| else throw "Uh oh!";
|
||||
|
||||
(21 duplicate frames omitted)
|
||||
|
||||
error: Uh oh!
|
36
tests/functional/lang/eval-fail-mutual-recursion.nix
Normal file
36
tests/functional/lang/eval-fail-mutual-recursion.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
# Check that stack frame deduplication only affects consecutive intervals, and
|
||||
# that they are reported independently of any preceding sections, even if
|
||||
# they're indistinguishable.
|
||||
#
|
||||
# In terms of the current implementation, we check that we clear the set of
|
||||
# "seen frames" after eliding a group of frames.
|
||||
#
|
||||
# Suppose we have:
|
||||
# - 10 frames in a function A
|
||||
# - 10 frames in a function B
|
||||
# - 10 frames in a function A
|
||||
#
|
||||
# We want to output:
|
||||
# - a few frames of A (skip the rest)
|
||||
# - a few frames of B (skip the rest)
|
||||
# - a few frames of A (skip the rest)
|
||||
#
|
||||
# If we implemented this in the naive manner, we'd instead get:
|
||||
# - a few frames of A (skip the rest)
|
||||
# - a few frames of B (skip the rest, _and_ skip the remaining frames of A)
|
||||
let
|
||||
throwAfterB = recurse: n:
|
||||
if n > 0
|
||||
then throwAfterB recurse (n - 1)
|
||||
else if recurse
|
||||
then throwAfterA false 10
|
||||
else throw "Uh oh!";
|
||||
|
||||
throwAfterA = recurse: n:
|
||||
if n > 0
|
||||
then throwAfterA recurse (n - 1)
|
||||
else if recurse
|
||||
then throwAfterB true 10
|
||||
else throw "Uh oh!";
|
||||
in
|
||||
throwAfterA true 10
|
|
@ -1 +1 @@
|
|||
trace: [ <CODE> ]
|
||||
trace: [ «thunk» ]
|
||||
|
|
1
tests/functional/lang/eval-okay-repeated-empty-attrs.exp
Normal file
1
tests/functional/lang/eval-okay-repeated-empty-attrs.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ { } { } ]
|
2
tests/functional/lang/eval-okay-repeated-empty-attrs.nix
Normal file
2
tests/functional/lang/eval-okay-repeated-empty-attrs.nix
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Tests that empty attribute sets are not printed as `«repeated»`.
|
||||
[ {} {} ]
|
1
tests/functional/lang/eval-okay-repeated-empty-list.exp
Normal file
1
tests/functional/lang/eval-okay-repeated-empty-list.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ [ ] [ ] ]
|
1
tests/functional/lang/eval-okay-repeated-empty-list.nix
Normal file
1
tests/functional/lang/eval-okay-repeated-empty-list.nix
Normal file
|
@ -0,0 +1 @@
|
|||
[ [] [] ]
|
|
@ -129,15 +129,15 @@ nix_tests = \
|
|||
impure-env.sh
|
||||
|
||||
ifeq ($(HAVE_LIBCPUID), 1)
|
||||
nix_tests += compute-levels.sh
|
||||
nix_tests += compute-levels.sh
|
||||
endif
|
||||
|
||||
ifeq ($(ENABLE_BUILD), yes)
|
||||
nix_tests += test-libstoreconsumer.sh
|
||||
nix_tests += test-libstoreconsumer.sh
|
||||
|
||||
ifeq ($(BUILD_SHARED_LIBS), 1)
|
||||
nix_tests += plugins.sh
|
||||
endif
|
||||
ifeq ($(BUILD_SHARED_LIBS), 1)
|
||||
nix_tests += plugins.sh
|
||||
endif
|
||||
endif
|
||||
|
||||
$(d)/test-libstoreconsumer.sh.test $(d)/test-libstoreconsumer.sh.test-debug: \
|
||||
|
|
|
@ -19,18 +19,7 @@ else
|
|||
fi
|
||||
|
||||
# Test import-from-derivation through the daemon.
|
||||
[[ $(nix eval --impure --raw --expr '
|
||||
with import ./config.nix;
|
||||
import (
|
||||
mkDerivation {
|
||||
name = "foo";
|
||||
bla = import ./dependencies.nix {};
|
||||
buildCommand = "
|
||||
echo \\\"hi\\\" > $out
|
||||
";
|
||||
}
|
||||
)
|
||||
') = hi ]]
|
||||
[[ $(nix eval --impure --raw --file ./ifd.nix) = hi ]]
|
||||
|
||||
storeCleared=1 NIX_REMOTE_=$NIX_REMOTE $SHELL ./user-envs.sh
|
||||
|
||||
|
|
|
@ -23,4 +23,20 @@ with import ./config.nix;
|
|||
chmod +x $dev/bin/hello2
|
||||
'';
|
||||
};
|
||||
|
||||
salve-mundi = mkDerivation {
|
||||
name = "salve-mundi";
|
||||
outputs = [ "out" ];
|
||||
meta.outputsToInstall = [ "out" ];
|
||||
buildCommand =
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
|
||||
cat > $out/bin/hello <<EOF
|
||||
#! ${shell}
|
||||
echo "Salve Mundi from $out/bin/hello"
|
||||
EOF
|
||||
chmod +x $out/bin/hello
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -10,6 +10,14 @@ nix shell -f shell-hello.nix hello -c hello NixOS | grep 'Hello NixOS'
|
|||
nix shell -f shell-hello.nix hello^dev -c hello2 | grep 'Hello2'
|
||||
nix shell -f shell-hello.nix 'hello^*' -c hello2 | grep 'Hello2'
|
||||
|
||||
|
||||
if isDaemonNewer "2.20.0pre20231220"; then
|
||||
# Test that command line attribute ordering is reflected in the PATH
|
||||
# https://github.com/NixOS/nix/issues/7905
|
||||
nix shell -f shell-hello.nix hello salve-mundi -c hello | grep 'Hello World'
|
||||
nix shell -f shell-hello.nix salve-mundi hello -c hello | grep 'Salve Mundi'
|
||||
fi
|
||||
|
||||
requireSandboxSupport
|
||||
|
||||
chmod -R u+w $TEST_ROOT/store0 || true
|
||||
|
|
|
@ -12,4 +12,4 @@ test-libstoreconsumer_CXXFLAGS += -I src/libutil -I src/libstore
|
|||
|
||||
test-libstoreconsumer_LIBS = libstore libutil
|
||||
|
||||
test-libstoreconsumer_LDFLAGS = -pthread $(SODIUM_LIBS) $(EDITLINE_LIBS) $(BOOST_LDFLAGS) $(LOWDOWN_LIBS)
|
||||
test-libstoreconsumer_LDFLAGS = $(THREAD_LDFLAGS) $(SODIUM_LIBS) $(EDITLINE_LIBS) $(BOOST_LDFLAGS) $(LOWDOWN_LIBS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue