mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
shellcheck fix: tests/functional/fetchClosure.sh
This commit is contained in:
parent
230da1cbe7
commit
d07dd92db3
2 changed files with 25 additions and 24 deletions
|
|
@ -107,7 +107,6 @@
|
||||||
excludes = [
|
excludes = [
|
||||||
# We haven't linted these files yet
|
# We haven't linted these files yet
|
||||||
''^tests/functional/dump-db\.sh$''
|
''^tests/functional/dump-db\.sh$''
|
||||||
''^tests/functional/fetchClosure\.sh$''
|
|
||||||
''^tests/functional/fetchGit\.sh$''
|
''^tests/functional/fetchGit\.sh$''
|
||||||
''^tests/functional/fetchGitRefs\.sh$''
|
''^tests/functional/fetchGitRefs\.sh$''
|
||||||
''^tests/functional/fetchGitSubmodules\.sh$''
|
''^tests/functional/fetchGitSubmodules\.sh$''
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,14 @@ requireDaemonNewerThan "2.16.0pre20230524"
|
||||||
|
|
||||||
# Initialize binary cache.
|
# Initialize binary cache.
|
||||||
nonCaPath=$(nix build --json --file ./dependencies.nix --no-link | jq -r .[].outputs.out)
|
nonCaPath=$(nix build --json --file ./dependencies.nix --no-link | jq -r .[].outputs.out)
|
||||||
caPath=$(nix store make-content-addressed --json $nonCaPath | jq -r '.rewrites | map(.) | .[]')
|
caPath=$(nix store make-content-addressed --json "$nonCaPath" | jq -r '.rewrites | map(.) | .[]')
|
||||||
nix copy --to file://$cacheDir $nonCaPath
|
nix copy --to file://"$cacheDir" "$nonCaPath"
|
||||||
|
|
||||||
# Test basic fetchClosure rewriting from non-CA to CA.
|
# Test basic fetchClosure rewriting from non-CA to CA.
|
||||||
clearStore
|
clearStore
|
||||||
|
|
||||||
[ ! -e $nonCaPath ]
|
[ ! -e "$nonCaPath" ]
|
||||||
[ ! -e $caPath ]
|
[ ! -e "$caPath" ]
|
||||||
|
|
||||||
[[ $(nix eval -v --raw --expr "
|
[[ $(nix eval -v --raw --expr "
|
||||||
builtins.fetchClosure {
|
builtins.fetchClosure {
|
||||||
|
|
@ -32,10 +32,10 @@ clearStore
|
||||||
fromPath = $nonCaPath;
|
fromPath = $nonCaPath;
|
||||||
toPath = $caPath;
|
toPath = $caPath;
|
||||||
}
|
}
|
||||||
") = $caPath ]]
|
") = "$caPath" ]]
|
||||||
|
|
||||||
[ ! -e $nonCaPath ]
|
[ ! -e "$nonCaPath" ]
|
||||||
[ -e $caPath ]
|
[ -e "$caPath" ]
|
||||||
|
|
||||||
clearStore
|
clearStore
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ if [[ "$NIX_REMOTE" != "daemon" ]]; then
|
||||||
# TODO: Should the closure be rejected, despite single user mode?
|
# TODO: Should the closure be rejected, despite single user mode?
|
||||||
# [ ! -e $nonCaPath ]
|
# [ ! -e $nonCaPath ]
|
||||||
|
|
||||||
[ ! -e $caPath ]
|
[ ! -e "$caPath" ]
|
||||||
|
|
||||||
# We can use non-CA paths when we ask explicitly.
|
# We can use non-CA paths when we ask explicitly.
|
||||||
[[ $(nix eval --raw --no-require-sigs --expr "
|
[[ $(nix eval --raw --no-require-sigs --expr "
|
||||||
|
|
@ -64,15 +64,15 @@ if [[ "$NIX_REMOTE" != "daemon" ]]; then
|
||||||
fromPath = $nonCaPath;
|
fromPath = $nonCaPath;
|
||||||
inputAddressed = true;
|
inputAddressed = true;
|
||||||
}
|
}
|
||||||
") = $nonCaPath ]]
|
") = "$nonCaPath" ]]
|
||||||
|
|
||||||
[ -e $nonCaPath ]
|
[ -e "$nonCaPath" ]
|
||||||
[ ! -e $caPath ]
|
[ ! -e "$caPath" ]
|
||||||
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ ! -e $caPath ]
|
[ ! -e "$caPath" ]
|
||||||
|
|
||||||
# 'toPath' set to empty string should fail but print the expected path.
|
# 'toPath' set to empty string should fail but print the expected path.
|
||||||
expectStderr 1 nix eval -v --json --expr "
|
expectStderr 1 nix eval -v --json --expr "
|
||||||
|
|
@ -84,39 +84,41 @@ expectStderr 1 nix eval -v --json --expr "
|
||||||
" | grep "error: rewriting.*$nonCaPath.*yielded.*$caPath"
|
" | grep "error: rewriting.*$nonCaPath.*yielded.*$caPath"
|
||||||
|
|
||||||
# If fromPath is CA, then toPath isn't needed.
|
# If fromPath is CA, then toPath isn't needed.
|
||||||
nix copy --to file://$cacheDir $caPath
|
nix copy --to file://"$cacheDir" "$caPath"
|
||||||
|
|
||||||
clearStore
|
clearStore
|
||||||
|
|
||||||
[ ! -e $caPath ]
|
[ ! -e "$caPath" ]
|
||||||
|
|
||||||
[[ $(nix eval -v --raw --expr "
|
[[ $(nix eval -v --raw --expr "
|
||||||
builtins.fetchClosure {
|
builtins.fetchClosure {
|
||||||
fromStore = \"file://$cacheDir\";
|
fromStore = \"file://$cacheDir\";
|
||||||
fromPath = $caPath;
|
fromPath = $caPath;
|
||||||
}
|
}
|
||||||
") = $caPath ]]
|
") = "$caPath" ]]
|
||||||
|
|
||||||
[ -e $caPath ]
|
[ -e "$caPath" ]
|
||||||
|
|
||||||
# Check that URL query parameters aren't allowed.
|
# Check that URL query parameters aren't allowed.
|
||||||
clearStore
|
clearStore
|
||||||
narCache=$TEST_ROOT/nar-cache
|
narCache=$TEST_ROOT/nar-cache
|
||||||
rm -rf $narCache
|
rm -rf "$narCache"
|
||||||
(! nix eval -v --raw --expr "
|
(! nix eval -v --raw --expr "
|
||||||
builtins.fetchClosure {
|
builtins.fetchClosure {
|
||||||
fromStore = \"file://$cacheDir?local-nar-cache=$narCache\";
|
fromStore = \"file://$cacheDir?local-nar-cache=$narCache\";
|
||||||
fromPath = $caPath;
|
fromPath = $caPath;
|
||||||
}
|
}
|
||||||
")
|
")
|
||||||
(! [ -e $narCache ])
|
# shellcheck disable=SC2235
|
||||||
|
(! [ -e "$narCache" ])
|
||||||
|
|
||||||
# If toPath is specified but wrong, we check it (only) when the path is missing.
|
# If toPath is specified but wrong, we check it (only) when the path is missing.
|
||||||
clearStore
|
clearStore
|
||||||
|
|
||||||
badPath=$(echo $caPath | sed -e 's!/store/................................-!/store/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-!')
|
# shellcheck disable=SC2001
|
||||||
|
badPath=$(echo "$caPath" | sed -e 's!/store/................................-!/store/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-!')
|
||||||
|
|
||||||
[ ! -e $badPath ]
|
[ ! -e "$badPath" ]
|
||||||
|
|
||||||
expectStderr 1 nix eval -v --raw --expr "
|
expectStderr 1 nix eval -v --raw --expr "
|
||||||
builtins.fetchClosure {
|
builtins.fetchClosure {
|
||||||
|
|
@ -126,11 +128,11 @@ expectStderr 1 nix eval -v --raw --expr "
|
||||||
}
|
}
|
||||||
" | grep "error: rewriting.*$nonCaPath.*yielded.*$caPath.*while.*$badPath.*was expected"
|
" | grep "error: rewriting.*$nonCaPath.*yielded.*$caPath.*while.*$badPath.*was expected"
|
||||||
|
|
||||||
[ ! -e $badPath ]
|
[ ! -e "$badPath" ]
|
||||||
|
|
||||||
# We only check it when missing, as a performance optimization similar to what we do for fixed output derivations. So if it's already there, we don't check it.
|
# We only check it when missing, as a performance optimization similar to what we do for fixed output derivations. So if it's already there, we don't check it.
|
||||||
# It would be nice for this to fail, but checking it would be too(?) slow.
|
# It would be nice for this to fail, but checking it would be too(?) slow.
|
||||||
[ -e $caPath ]
|
[ -e "$caPath" ]
|
||||||
|
|
||||||
[[ $(nix eval -v --raw --expr "
|
[[ $(nix eval -v --raw --expr "
|
||||||
builtins.fetchClosure {
|
builtins.fetchClosure {
|
||||||
|
|
@ -138,7 +140,7 @@ expectStderr 1 nix eval -v --raw --expr "
|
||||||
fromPath = $badPath;
|
fromPath = $badPath;
|
||||||
toPath = $caPath;
|
toPath = $caPath;
|
||||||
}
|
}
|
||||||
") = $caPath ]]
|
") = "$caPath" ]]
|
||||||
|
|
||||||
|
|
||||||
# However, if the output address is unexpected, we can report it
|
# However, if the output address is unexpected, we can report it
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue