mirror of
https://github.com/NixOS/nix
synced 2025-07-10 04:43:53 +02:00
Merge branch 'master' into overlayfs-store
This commit is contained in:
commit
18945e3f44
131 changed files with 1958 additions and 4473 deletions
|
@ -216,6 +216,17 @@ expectStderr() {
|
|||
return 0
|
||||
}
|
||||
|
||||
# Run a command and check whether the stderr matches stdin.
|
||||
# Show a diff when output does not match.
|
||||
# Usage:
|
||||
#
|
||||
# assertStderr nix profile remove nothing << EOF
|
||||
# error: This error is expected
|
||||
# EOF
|
||||
assertStderr() {
|
||||
diff -u /dev/stdin <($@ 2>/dev/null 2>&1)
|
||||
}
|
||||
|
||||
needLocalStore() {
|
||||
if [[ "$NIX_REMOTE" == "daemon" ]]; then
|
||||
skipTest "Can’t run through the daemon ($1)"
|
||||
|
|
|
@ -41,3 +41,14 @@ mkdir -p $TEST_ROOT/xyzzy $TEST_ROOT/foo
|
|||
ln -sfn ../xyzzy $TEST_ROOT/foo/bar
|
||||
printf 123 > $TEST_ROOT/xyzzy/default.nix
|
||||
[[ $(nix eval --impure --expr "import $TEST_ROOT/foo/bar") = 123 ]]
|
||||
|
||||
# Test --arg-from-file.
|
||||
[[ "$(nix eval --raw --arg-from-file foo config.nix --expr '{ foo }: { inherit foo; }' foo)" = "$(cat config.nix)" ]]
|
||||
|
||||
# Check that special(-ish) files are drained.
|
||||
if [[ -e /proc/version ]]; then
|
||||
[[ "$(nix eval --raw --arg-from-file foo /proc/version --expr '{ foo }: { inherit foo; }' foo)" = "$(cat /proc/version)" ]]
|
||||
fi
|
||||
|
||||
# Test --arg-from-stdin.
|
||||
[[ "$(echo bla | nix eval --raw --arg-from-stdin foo --expr '{ foo }: { inherit foo; }' foo)" = bla ]]
|
||||
|
|
|
@ -564,6 +564,16 @@ nix flake lock "$flake3Dir"
|
|||
nix flake update flake2/flake1 --flake "$flake3Dir"
|
||||
[[ $(jq -r .nodes.flake1_2.locked.rev "$flake3Dir/flake.lock") =~ $hash2 ]]
|
||||
|
||||
# Test updating multiple inputs.
|
||||
nix flake lock "$flake3Dir" --override-input flake1 flake1/master/$hash1
|
||||
nix flake lock "$flake3Dir" --override-input flake2/flake1 flake1/master/$hash1
|
||||
[[ $(jq -r .nodes.flake1.locked.rev "$flake3Dir/flake.lock") =~ $hash1 ]]
|
||||
[[ $(jq -r .nodes.flake1_2.locked.rev "$flake3Dir/flake.lock") =~ $hash1 ]]
|
||||
|
||||
nix flake update flake1 flake2/flake1 --flake "$flake3Dir"
|
||||
[[ $(jq -r .nodes.flake1.locked.rev "$flake3Dir/flake.lock") =~ $hash2 ]]
|
||||
[[ $(jq -r .nodes.flake1_2.locked.rev "$flake3Dir/flake.lock") =~ $hash2 ]]
|
||||
|
||||
# Test 'nix flake metadata --json'.
|
||||
nix flake metadata "$flake3Dir" --json | jq .
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ mkdir subdir
|
|||
pushd subdir
|
||||
|
||||
success=("" . .# .#test ../subdir ../subdir#test "$PWD")
|
||||
failure=("path:$PWD")
|
||||
failure=("path:$PWD" "../simple.nix")
|
||||
|
||||
for i in "${success[@]}"; do
|
||||
nix build $i || fail "flake should be found by searching up directories"
|
||||
|
|
|
@ -56,3 +56,12 @@ echo Run Hello World! > $TEST_ROOT/dummy3/dir/executable
|
|||
path3=$(nix store add --mode git --hash-algo sha1 $TEST_ROOT/dummy3)
|
||||
hash3=$(nix-store -q --hash $path3)
|
||||
test "$hash3" = "sha256:08y3nm3mvn9qvskqnf13lfgax5lh73krxz4fcjd5cp202ggpw9nv"
|
||||
|
||||
rm -rf $TEST_ROOT/dummy3
|
||||
mkdir -p $TEST_ROOT/dummy3
|
||||
mkdir -p $TEST_ROOT/dummy3/dir
|
||||
touch $TEST_ROOT/dummy3/dir/file
|
||||
ln -s './hello/world.txt' $TEST_ROOT/dummy3/dir/symlink
|
||||
path3=$(nix store add --mode git --hash-algo sha1 $TEST_ROOT/dummy3)
|
||||
hash3=$(nix-store -q --hash $path3)
|
||||
test "$hash3" = "sha256:1dwazas8irzpar89s8k2bnp72imfw7kgg4aflhhsfnicg8h428f3"
|
||||
|
|
69
tests/functional/help.sh
Normal file
69
tests/functional/help.sh
Normal file
|
@ -0,0 +1,69 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
# test help output
|
||||
|
||||
nix-build --help
|
||||
nix-shell --help
|
||||
|
||||
nix-env --help
|
||||
nix-env --install --help
|
||||
nix-env --upgrade --help
|
||||
nix-env --uninstall --help
|
||||
nix-env --set --help
|
||||
nix-env --set-flag --help
|
||||
nix-env --query --help
|
||||
nix-env --switch-profile --help
|
||||
nix-env --list-generations --help
|
||||
nix-env --delete-generations --help
|
||||
nix-env --switch-generation --help
|
||||
nix-env --rollback --help
|
||||
|
||||
nix-store --help
|
||||
nix-store --realise --help
|
||||
nix-store --serve --help
|
||||
nix-store --gc --help
|
||||
nix-store --delete --help
|
||||
nix-store --query --help
|
||||
nix-store --add --help
|
||||
nix-store --add-fixed --help
|
||||
nix-store --verify --help
|
||||
nix-store --verify-path --help
|
||||
nix-store --repair-path --help
|
||||
nix-store --dump --help
|
||||
nix-store --restore --help
|
||||
nix-store --export --help
|
||||
nix-store --import --help
|
||||
nix-store --optimise --help
|
||||
nix-store --read-log --help
|
||||
nix-store --dump-db --help
|
||||
nix-store --load-db --help
|
||||
nix-store --print-env --help
|
||||
nix-store --generate-binary-cache-key --help
|
||||
|
||||
nix-channel --help
|
||||
nix-collect-garbage --help
|
||||
nix-copy-closure --help
|
||||
nix-daemon --help
|
||||
nix-hash --help
|
||||
nix-instantiate --help
|
||||
nix-prefetch-url --help
|
||||
|
||||
function subcommands() {
|
||||
jq -r '
|
||||
def recurse($prefix):
|
||||
to_entries[] |
|
||||
($prefix + [.key]) as $newPrefix |
|
||||
(if .value | has("commands") then
|
||||
($newPrefix, (.value.commands | recurse($newPrefix)))
|
||||
else
|
||||
$newPrefix
|
||||
end);
|
||||
.args.commands | recurse([]) | join(" ")
|
||||
'
|
||||
}
|
||||
|
||||
nix __dump-cli | subcommands | while IFS= read -r cmd; do
|
||||
nix $cmd --help
|
||||
done
|
6
tests/functional/lang/eval-fail-eol-1.err.exp
Normal file
6
tests/functional/lang/eval-fail-eol-1.err.exp
Normal file
|
@ -0,0 +1,6 @@
|
|||
error: undefined variable 'invalid'
|
||||
at /pwd/lang/eval-fail-eol-1.nix:2:1:
|
||||
1| # foo
|
||||
2| invalid
|
||||
| ^
|
||||
3| # bar
|
3
tests/functional/lang/eval-fail-eol-1.nix
Normal file
3
tests/functional/lang/eval-fail-eol-1.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
# foo
|
||||
invalid
|
||||
# bar
|
6
tests/functional/lang/eval-fail-eol-2.err.exp
Normal file
6
tests/functional/lang/eval-fail-eol-2.err.exp
Normal file
|
@ -0,0 +1,6 @@
|
|||
error: undefined variable 'invalid'
|
||||
at /pwd/lang/eval-fail-eol-2.nix:2:1:
|
||||
1| # foo
|
||||
2| invalid
|
||||
| ^
|
||||
3| # bar
|
2
tests/functional/lang/eval-fail-eol-2.nix
Normal file
2
tests/functional/lang/eval-fail-eol-2.nix
Normal file
|
@ -0,0 +1,2 @@
|
|||
# foo
invalid
|
||||
# bar
|
6
tests/functional/lang/eval-fail-eol-3.err.exp
Normal file
6
tests/functional/lang/eval-fail-eol-3.err.exp
Normal file
|
@ -0,0 +1,6 @@
|
|||
error: undefined variable 'invalid'
|
||||
at /pwd/lang/eval-fail-eol-3.nix:2:1:
|
||||
1| # foo
|
||||
2| invalid
|
||||
| ^
|
||||
3| # bar
|
3
tests/functional/lang/eval-fail-eol-3.nix
Normal file
3
tests/functional/lang/eval-fail-eol-3.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
# foo
|
||||
invalid
|
||||
# bar
|
1
tests/functional/lang/eval-okay-inherit-attr-pos.exp
Normal file
1
tests/functional/lang/eval-okay-inherit-attr-pos.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ { column = 17; file = "/pwd/lang/eval-okay-inherit-attr-pos.nix"; line = 4; } { column = 19; file = "/pwd/lang/eval-okay-inherit-attr-pos.nix"; line = 4; } { column = 21; file = "/pwd/lang/eval-okay-inherit-attr-pos.nix"; line = 5; } { column = 23; file = "/pwd/lang/eval-okay-inherit-attr-pos.nix"; line = 5; } ]
|
12
tests/functional/lang/eval-okay-inherit-attr-pos.nix
Normal file
12
tests/functional/lang/eval-okay-inherit-attr-pos.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
let
|
||||
d = 0;
|
||||
x = 1;
|
||||
y = { inherit d x; };
|
||||
z = { inherit (y) d x; };
|
||||
in
|
||||
[
|
||||
(builtins.unsafeGetAttrPos "d" y)
|
||||
(builtins.unsafeGetAttrPos "x" y)
|
||||
(builtins.unsafeGetAttrPos "d" z)
|
||||
(builtins.unsafeGetAttrPos "x" z)
|
||||
]
|
|
@ -3,3 +3,4 @@ error: attribute 'x' already defined at «stdin»:1:3
|
|||
2| y = 456;
|
||||
3| x = 789;
|
||||
| ^
|
||||
4| }
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
error: attribute 'x' already defined at «stdin»:9:5
|
||||
at «stdin»:10:17:
|
||||
at «stdin»:10:18:
|
||||
9| x = 789;
|
||||
10| inherit (as) x;
|
||||
| ^
|
||||
| ^
|
||||
11| };
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
error: attribute 'x' already defined at «stdin»:9:5
|
||||
at «stdin»:10:17:
|
||||
at «stdin»:10:18:
|
||||
9| x = 789;
|
||||
10| inherit (as) x;
|
||||
| ^
|
||||
| ^
|
||||
11| };
|
||||
|
|
|
@ -3,3 +3,4 @@ error: attribute 'services.ssh.port' already defined at «stdin»:2:3
|
|||
2| services.ssh.port = 22;
|
||||
3| services.ssh.port = 23;
|
||||
| ^
|
||||
4| }
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
error: attribute 'x' already defined at «stdin»:6:12
|
||||
at «stdin»:7:12:
|
||||
error: attribute 'x' already defined at «stdin»:6:13
|
||||
at «stdin»:7:13:
|
||||
6| inherit x;
|
||||
7| inherit x;
|
||||
| ^
|
||||
| ^
|
||||
8| };
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: syntax error, unexpected end of file, expecting '"'
|
||||
at «stdin»:3:5:
|
||||
at «stdin»:3:6:
|
||||
2| # Note that this file must not end with a newline.
|
||||
3| a 1"$
|
||||
| ^
|
||||
| ^
|
||||
|
|
5
tests/functional/lang/parse-fail-eof-pos.err.exp
Normal file
5
tests/functional/lang/parse-fail-eof-pos.err.exp
Normal file
|
@ -0,0 +1,5 @@
|
|||
error: syntax error, unexpected end of file
|
||||
at «stdin»:3:1:
|
||||
2| # no content
|
||||
3|
|
||||
| ^
|
2
tests/functional/lang/parse-fail-eof-pos.nix
Normal file
2
tests/functional/lang/parse-fail-eof-pos.nix
Normal file
|
@ -0,0 +1,2 @@
|
|||
(
|
||||
# no content
|
|
@ -1,6 +1,6 @@
|
|||
error: undefined variable 'gcc'
|
||||
at «stdin»:8:12:
|
||||
7|
|
||||
at «stdin»:9:13:
|
||||
8| body = ({
|
||||
| ^
|
||||
9| inherit gcc;
|
||||
| ^
|
||||
10| }).gcc;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
error: syntax error, unexpected ':', expecting '}'
|
||||
at «stdin»:3:13:
|
||||
2|
|
||||
3| f = {x, y :
|
||||
3| f = {x, y : ["baz" "bar" z "bat"]}: x + y;
|
||||
| ^
|
||||
4|
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
error: syntax error, unexpected invalid token, expecting end of file
|
||||
at «stdin»:1:5:
|
||||
1| 123 テ
|
||||
1| 123 é 4
|
||||
| ^
|
||||
2|
|
||||
|
|
|
@ -1 +1 @@
|
|||
({ fetchurl, localServer ? false, httpServer ? false, sslSupport ? false, pythonBindings ? false, javaSwigBindings ? false, javahlBindings ? false, stdenv, openssl ? null, httpd ? null, db4 ? null, expat, swig ? null, j2sdk ? null }: assert (expat != null); assert (localServer -> (db4 != null)); assert (httpServer -> ((httpd != null) && ((httpd).expat == expat))); assert (sslSupport -> ((openssl != null) && (httpServer -> ((httpd).openssl == openssl)))); assert (pythonBindings -> ((swig != null) && (swig).pythonSupport)); assert (javaSwigBindings -> ((swig != null) && (swig).javaSupport)); assert (javahlBindings -> (j2sdk != null)); ((stdenv).mkDerivation { inherit expat httpServer javaSwigBindings javahlBindings localServer pythonBindings sslSupport; builder = /foo/bar; db4 = (if localServer then db4 else null); httpd = (if httpServer then httpd else null); j2sdk = (if javaSwigBindings then (swig).j2sdk else (if javahlBindings then j2sdk else null)); name = "subversion-1.1.1"; openssl = (if sslSupport then openssl else null); patches = (if javahlBindings then [ (/javahl.patch) ] else [ ]); python = (if pythonBindings then (swig).python else null); src = (fetchurl { md5 = "a180c3fe91680389c210c99def54d9e0"; url = "http://subversion.tigris.org/tarballs/subversion-1.1.1.tar.bz2"; }); swig = (if (pythonBindings || javaSwigBindings) then swig else null); }))
|
||||
({ db4 ? null, expat, fetchurl, httpServer ? false, httpd ? null, j2sdk ? null, javaSwigBindings ? false, javahlBindings ? false, localServer ? false, openssl ? null, pythonBindings ? false, sslSupport ? false, stdenv, swig ? null }: assert (expat != null); assert (localServer -> (db4 != null)); assert (httpServer -> ((httpd != null) && ((httpd).expat == expat))); assert (sslSupport -> ((openssl != null) && (httpServer -> ((httpd).openssl == openssl)))); assert (pythonBindings -> ((swig != null) && (swig).pythonSupport)); assert (javaSwigBindings -> ((swig != null) && (swig).javaSupport)); assert (javahlBindings -> (j2sdk != null)); ((stdenv).mkDerivation { inherit expat httpServer javaSwigBindings javahlBindings localServer pythonBindings sslSupport; builder = /foo/bar; db4 = (if localServer then db4 else null); httpd = (if httpServer then httpd else null); j2sdk = (if javaSwigBindings then (swig).j2sdk else (if javahlBindings then j2sdk else null)); name = "subversion-1.1.1"; openssl = (if sslSupport then openssl else null); patches = (if javahlBindings then [ (/javahl.patch) ] else [ ]); python = (if pythonBindings then (swig).python else null); src = (fetchurl { md5 = "a180c3fe91680389c210c99def54d9e0"; url = "http://subversion.tigris.org/tarballs/subversion-1.1.1.tar.bz2"; }); swig = (if (pythonBindings || javaSwigBindings) then swig else null); }))
|
||||
|
|
|
@ -129,7 +129,8 @@ nix_tests = \
|
|||
read-only-store.sh \
|
||||
nested-sandboxing.sh \
|
||||
impure-env.sh \
|
||||
debugger.sh
|
||||
debugger.sh \
|
||||
help.sh
|
||||
|
||||
ifeq ($(HAVE_LIBCPUID), 1)
|
||||
nix_tests += compute-levels.sh
|
||||
|
|
|
@ -74,10 +74,49 @@ nix profile upgrade flake1
|
|||
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello NixOS" ]]
|
||||
nix profile history | grep "packages.$system.default: 1.0, 1.0-man -> 2.0, 2.0-man"
|
||||
|
||||
# Test upgrading package using regular expression.
|
||||
printf 2.1 > $flake1Dir/version
|
||||
nix profile upgrade --regex '.*'
|
||||
[[ $(readlink $TEST_HOME/.nix-profile/bin/hello) =~ .*-profile-test-2\.1/bin/hello ]]
|
||||
nix profile rollback
|
||||
|
||||
# Test upgrading all packages
|
||||
printf 2.2 > $flake1Dir/version
|
||||
nix profile upgrade --all
|
||||
[[ $(readlink $TEST_HOME/.nix-profile/bin/hello) =~ .*-profile-test-2\.2/bin/hello ]]
|
||||
nix profile rollback
|
||||
printf 1.0 > $flake1Dir/version
|
||||
|
||||
# Test --all exclusivity.
|
||||
assertStderr nix --offline profile upgrade --all foo << EOF
|
||||
error: --all cannot be used with package names or regular expressions.
|
||||
Try 'nix --help' for more information.
|
||||
EOF
|
||||
|
||||
# Test matching no packages using literal package name.
|
||||
assertStderr nix --offline profile upgrade this_package_is_not_installed << EOF
|
||||
warning: Package name 'this_package_is_not_installed' does not match any packages in the profile.
|
||||
warning: No packages to upgrade. Use 'nix profile list' to see the current profile.
|
||||
EOF
|
||||
|
||||
# Test matching no packages using regular expression.
|
||||
assertStderr nix --offline profile upgrade --regex '.*unknown_package.*' << EOF
|
||||
warning: Regex '.*unknown_package.*' does not match any packages in the profile.
|
||||
warning: No packages to upgrade. Use 'nix profile list' to see the current profile.
|
||||
EOF
|
||||
|
||||
# Test removing all packages using regular expression.
|
||||
nix profile remove --regex '.*' 2>&1 | grep "removed 2 packages, kept 0 packages"
|
||||
nix profile rollback
|
||||
|
||||
# Test 'history', 'diff-closures'.
|
||||
nix profile diff-closures
|
||||
|
||||
# Test rollback.
|
||||
printf World > $flake1Dir/who
|
||||
nix profile upgrade flake1
|
||||
printf NixOS > $flake1Dir/who
|
||||
nix profile upgrade flake1
|
||||
nix profile rollback
|
||||
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue