mirror of
https://github.com/NixOS/nix
synced 2025-07-10 04:43:53 +02:00
Merge remote-tracking branch 'origin/master' into relative-flakes
This commit is contained in:
commit
cd0127f957
112 changed files with 2268 additions and 434 deletions
|
@ -29,6 +29,47 @@ echo "$hash2"
|
|||
|
||||
test "$hash1" = "sha256:$hash2"
|
||||
|
||||
# The contents can be accessed through a symlink, and this symlink has no effect on the hash
|
||||
# https://github.com/NixOS/nix/issues/11941
|
||||
test_issue_11941() {
|
||||
local expected actual
|
||||
mkdir -p "$TEST_ROOT/foo/bar" && ln -s "$TEST_ROOT/foo" "$TEST_ROOT/foo-link"
|
||||
|
||||
# legacy
|
||||
expected=$(nix-store --add-fixed --recursive sha256 "$TEST_ROOT/foo/bar")
|
||||
actual=$(nix-store --add-fixed --recursive sha256 "$TEST_ROOT/foo-link/bar")
|
||||
[[ "$expected" == "$actual" ]]
|
||||
actual=$(nix-store --add "$TEST_ROOT/foo-link/bar")
|
||||
[[ "$expected" == "$actual" ]]
|
||||
|
||||
# nix store add
|
||||
actual=$(nix store add --hash-algo sha256 --mode nar "$TEST_ROOT/foo/bar")
|
||||
[[ "$expected" == "$actual" ]]
|
||||
|
||||
# cleanup
|
||||
rm -r "$TEST_ROOT/foo" "$TEST_ROOT/foo-link"
|
||||
}
|
||||
test_issue_11941
|
||||
|
||||
# A symlink is added to the store as a symlink, not as a copy of the target
|
||||
test_add_symlink() {
|
||||
ln -s /bin "$TEST_ROOT/my-bin"
|
||||
|
||||
# legacy
|
||||
path=$(nix-store --add-fixed --recursive sha256 "$TEST_ROOT/my-bin")
|
||||
[[ "$(readlink "$path")" == /bin ]]
|
||||
path=$(nix-store --add "$TEST_ROOT/my-bin")
|
||||
[[ "$(readlink "$path")" == /bin ]]
|
||||
|
||||
# nix store add
|
||||
path=$(nix store add --hash-algo sha256 --mode nar "$TEST_ROOT/my-bin")
|
||||
[[ "$(readlink "$path")" == /bin ]]
|
||||
|
||||
# cleanup
|
||||
rm "$TEST_ROOT/my-bin"
|
||||
}
|
||||
test_add_symlink
|
||||
|
||||
#### New style commands
|
||||
|
||||
clearStoreIfPossible
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
int = 123;
|
||||
str = "foo";
|
||||
str = "foo\nbar";
|
||||
attr.foo = "bar";
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ EOF
|
|||
nix eval --expr 'assert 1 + 2 == 3; true'
|
||||
|
||||
[[ $(nix eval int -f "./eval.nix") == 123 ]]
|
||||
[[ $(nix eval str -f "./eval.nix") == '"foo"' ]]
|
||||
[[ $(nix eval str --raw -f "./eval.nix") == 'foo' ]]
|
||||
[[ $(nix eval str -f "./eval.nix") == '"foo\nbar"' ]]
|
||||
[[ $(nix eval str --raw -f "./eval.nix") == $'foo\nbar' ]]
|
||||
[[ "$(nix eval attr -f "./eval.nix")" == '{ foo = "bar"; }' ]]
|
||||
[[ $(nix eval attr --json -f "./eval.nix") == '{"foo":"bar"}' ]]
|
||||
[[ $(nix eval int -f - < "./eval.nix") == 123 ]]
|
||||
|
@ -28,7 +28,8 @@ nix eval --expr 'assert 1 + 2 == 3; true'
|
|||
|
||||
nix-instantiate --eval -E 'assert 1 + 2 == 3; true'
|
||||
[[ $(nix-instantiate -A int --eval "./eval.nix") == 123 ]]
|
||||
[[ $(nix-instantiate -A str --eval "./eval.nix") == '"foo"' ]]
|
||||
[[ $(nix-instantiate -A str --eval "./eval.nix") == '"foo\nbar"' ]]
|
||||
[[ $(nix-instantiate -A str --raw --eval "./eval.nix") == $'foo\nbar' ]]
|
||||
[[ "$(nix-instantiate -A attr --eval "./eval.nix")" == '{ foo = "bar"; }' ]]
|
||||
[[ $(nix-instantiate -A attr --eval --json "./eval.nix") == '{"foo":"bar"}' ]]
|
||||
[[ $(nix-instantiate -A int --eval - < "./eval.nix") == 123 ]]
|
||||
|
|
|
@ -63,3 +63,16 @@ flakeref=git+file://$rootRepo\?submodules=1\&dir=submodule
|
|||
echo '"foo"' > "$rootRepo"/submodule/sub.nix
|
||||
[[ $(nix eval --json "$flakeref#sub" ) = '"foo"' ]]
|
||||
[[ $(nix flake metadata --json "$flakeref" | jq -r .locked.rev) = null ]]
|
||||
|
||||
# Test that `nix flake metadata` parses `submodule` correctly.
|
||||
cat > "$rootRepo"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
};
|
||||
}
|
||||
EOF
|
||||
git -C "$rootRepo" add flake.nix
|
||||
git -C "$rootRepo" commit -m "Add flake.nix"
|
||||
|
||||
storePath=$(nix flake metadata --json "$rootRepo?submodules=1" | jq -r .path)
|
||||
[[ -e "$storePath/submodule" ]]
|
||||
|
|
|
@ -92,3 +92,32 @@ try2 md5 "20f3ffe011d4cfa7d72bfabef7882836"
|
|||
rm "$TEST_ROOT/hash-path/hello"
|
||||
ln -s x "$TEST_ROOT/hash-path/hello"
|
||||
try2 md5 "f78b733a68f5edbdf9413899339eaa4a"
|
||||
|
||||
# Flat mode supports process substitution
|
||||
h=$(nix hash path --mode flat --type sha256 --base32 <(printf "SMASH THE STATE"))
|
||||
[[ 0d9n3r2i4m1zgy0wpqbsyabsfzgs952066bfp8gwvcg4mkr4r5g8 == "$h" ]]
|
||||
|
||||
# Flat mode supports process substitution (hash file)
|
||||
h=$(nix hash file --type sha256 --base32 <(printf "SMASH THE STATE"))
|
||||
[[ 0d9n3r2i4m1zgy0wpqbsyabsfzgs952066bfp8gwvcg4mkr4r5g8 == "$h" ]]
|
||||
|
||||
# Symlinks in the ancestry are ok and don't affect the result
|
||||
mkdir -p "$TEST_ROOT/simple" "$TEST_ROOT/try/to/mess/with/it"
|
||||
echo hi > "$TEST_ROOT/simple/hi"
|
||||
ln -s "$TEST_ROOT/simple" "$TEST_ROOT/try/to/mess/with/it/simple-link"
|
||||
h=$(nix hash path --type sha256 --base32 "$TEST_ROOT/simple/hi")
|
||||
[[ 1xmr8jicvzszfzpz46g37mlpvbzjl2wpwvl2b05psipssyp1sm8h == "$h" ]]
|
||||
h=$(nix hash path --type sha256 --base32 "$TEST_ROOT/try/to/mess/with/it/simple-link/hi")
|
||||
[[ 1xmr8jicvzszfzpz46g37mlpvbzjl2wpwvl2b05psipssyp1sm8h == "$h" ]]
|
||||
|
||||
# nix hash --mode nar does not canonicalize a symlink argument.
|
||||
# Otherwise it can't generate a NAR whose root is a symlink.
|
||||
# If you want to follow the symlink, pass $(realpath -s ...) instead.
|
||||
ln -s /non-existent-48cujwe8ndf4as0bne "$TEST_ROOT/symlink-to-nowhere"
|
||||
h=$(nix hash path --mode nar --type sha256 --base32 "$TEST_ROOT/symlink-to-nowhere")
|
||||
[[ 1bl5ry3x1fcbwgr5c2x50bn572iixh4j1p6ax5isxly2ddgn8pbp == "$h" ]] # manually verified hash
|
||||
if [[ -e /bin ]]; then
|
||||
ln -s /bin "$TEST_ROOT/symlink-to-bin"
|
||||
h=$(nix hash path --mode nar --type sha256 --base32 "$TEST_ROOT/symlink-to-bin")
|
||||
[[ 0z2mdmkd43l0ijdxfbj1y8vzli15yh9b09n3a3rrygmjshbyypsw == "$h" ]] # manually verified hash
|
||||
fi
|
||||
|
|
BIN
tests/functional/lang/eval-fail-string-nul-1.err.exp
Normal file
BIN
tests/functional/lang/eval-fail-string-nul-1.err.exp
Normal file
Binary file not shown.
BIN
tests/functional/lang/eval-fail-string-nul-1.nix
Normal file
BIN
tests/functional/lang/eval-fail-string-nul-1.nix
Normal file
Binary file not shown.
BIN
tests/functional/lang/eval-fail-string-nul-2.err.exp
Normal file
BIN
tests/functional/lang/eval-fail-string-nul-2.err.exp
Normal file
Binary file not shown.
BIN
tests/functional/lang/eval-fail-string-nul-2.nix
Normal file
BIN
tests/functional/lang/eval-fail-string-nul-2.nix
Normal file
Binary file not shown.
8
tests/functional/lang/eval-fail-toJSON-non-utf-8.err.exp
Normal file
8
tests/functional/lang/eval-fail-toJSON-non-utf-8.err.exp
Normal file
|
@ -0,0 +1,8 @@
|
|||
error:
|
||||
… while calling the 'toJSON' builtin
|
||||
at /pwd/lang/eval-fail-toJSON-non-utf-8.nix:1:1:
|
||||
1| builtins.toJSON "_invalid UTF-8: ÿ_"
|
||||
| ^
|
||||
2|
|
||||
|
||||
error: JSON serialization error: [json.exception.type_error.316] invalid UTF-8 byte at index 16: 0xFF
|
1
tests/functional/lang/eval-fail-toJSON-non-utf-8.nix
Normal file
1
tests/functional/lang/eval-fail-toJSON-non-utf-8.nix
Normal file
|
@ -0,0 +1 @@
|
|||
builtins.toJSON "_invalid UTF-8: ÿ_"
|
|
@ -4,8 +4,6 @@ project('nix-functional-tests',
|
|||
'cpp_std=c++2a',
|
||||
# TODO(Qyriad): increase the warning level
|
||||
'warning_level=1',
|
||||
'debug=true',
|
||||
'optimization=2',
|
||||
'errorlogs=true', # Please print logs for tests that fail
|
||||
],
|
||||
meson_version : '>= 1.3',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue