@@ -17,25 +17,25 @@ requireDaemonNewerThan "2.16.0pre20230524"
1717
1818# Initialize binary cache.
1919nonCaPath=$( nix build --json --file ./dependencies.nix --no-link | jq -r .[].outputs.out)
20- caPath=$( nix store make-content-addressed --json $nonCaPath | jq -r ' .rewrites | map(.) | .[]' )
21- nix copy --to file://$cacheDir $nonCaPath
20+ caPath=$( nix store make-content-addressed --json " $nonCaPath " | jq -r ' .rewrites | map(.) | .[]' )
21+ nix copy --to file://" $cacheDir " " $nonCaPath "
2222
2323# Test basic fetchClosure rewriting from non-CA to CA.
2424clearStore
2525
26- [ ! -e $nonCaPath ]
27- [ ! -e $caPath ]
26+ [ ! -e " $nonCaPath " ]
27+ [ ! -e " $caPath " ]
2828
2929[[ $( nix eval -v --raw --expr "
3030 builtins.fetchClosure {
3131 fromStore = \" file://$cacheDir \" ;
3232 fromPath = $nonCaPath ;
3333 toPath = $caPath ;
3434 }
35- " ) = $caPath ]]
35+ " ) = " $caPath " ]]
3636
37- [ ! -e $nonCaPath ]
38- [ -e $caPath ]
37+ [ ! -e " $nonCaPath " ]
38+ [ -e " $caPath " ]
3939
4040clearStore
4141
@@ -55,7 +55,7 @@ if [[ "$NIX_REMOTE" != "daemon" ]]; then
5555 # TODO: Should the closure be rejected, despite single user mode?
5656 # [ ! -e $nonCaPath ]
5757
58- [ ! -e $caPath ]
58+ [ ! -e " $caPath " ]
5959
6060 # We can use non-CA paths when we ask explicitly.
6161 [[ $( nix eval --raw --no-require-sigs --expr "
@@ -64,15 +64,15 @@ if [[ "$NIX_REMOTE" != "daemon" ]]; then
6464 fromPath = $nonCaPath ;
6565 inputAddressed = true;
6666 }
67- " ) = $nonCaPath ]]
67+ " ) = " $nonCaPath " ]]
6868
69- [ -e $nonCaPath ]
70- [ ! -e $caPath ]
69+ [ -e " $nonCaPath " ]
70+ [ ! -e " $caPath " ]
7171
7272
7373fi
7474
75- [ ! -e $caPath ]
75+ [ ! -e " $caPath " ]
7676
7777# 'toPath' set to empty string should fail but print the expected path.
7878expectStderr 1 nix eval -v --json --expr "
@@ -84,39 +84,41 @@ expectStderr 1 nix eval -v --json --expr "
8484" | grep " error: rewriting.*$nonCaPath .*yielded.*$caPath "
8585
8686# If fromPath is CA, then toPath isn't needed.
87- nix copy --to file://$cacheDir $caPath
87+ nix copy --to file://" $cacheDir " " $caPath "
8888
8989clearStore
9090
91- [ ! -e $caPath ]
91+ [ ! -e " $caPath " ]
9292
9393[[ $( nix eval -v --raw --expr "
9494 builtins.fetchClosure {
9595 fromStore = \" file://$cacheDir \" ;
9696 fromPath = $caPath ;
9797 }
98- " ) = $caPath ]]
98+ " ) = " $caPath " ]]
9999
100- [ -e $caPath ]
100+ [ -e " $caPath " ]
101101
102102# Check that URL query parameters aren't allowed.
103103clearStore
104104narCache=$TEST_ROOT /nar-cache
105- rm -rf $narCache
105+ rm -rf " $narCache "
106106(! nix eval -v --raw --expr "
107107 builtins.fetchClosure {
108108 fromStore = \" file://$cacheDir ?local-nar-cache=$narCache \" ;
109109 fromPath = $caPath ;
110110 }
111111" )
112- (! [ -e $narCache ])
112+ # shellcheck disable=SC2235
113+ (! [ -e " $narCache " ])
113114
114115# If toPath is specified but wrong, we check it (only) when the path is missing.
115116clearStore
116117
117- badPath=$( echo $caPath | sed -e ' s!/store/................................-!/store/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-!' )
118+ # shellcheck disable=SC2001
119+ badPath=$( echo " $caPath " | sed -e ' s!/store/................................-!/store/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-!' )
118120
119- [ ! -e $badPath ]
121+ [ ! -e " $badPath " ]
120122
121123expectStderr 1 nix eval -v --raw --expr "
122124 builtins.fetchClosure {
@@ -126,19 +128,19 @@ expectStderr 1 nix eval -v --raw --expr "
126128 }
127129" | grep " error: rewriting.*$nonCaPath .*yielded.*$caPath .*while.*$badPath .*was expected"
128130
129- [ ! -e $badPath ]
131+ [ ! -e " $badPath " ]
130132
131133# 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.
132134# It would be nice for this to fail, but checking it would be too(?) slow.
133- [ -e $caPath ]
135+ [ -e " $caPath " ]
134136
135137[[ $( nix eval -v --raw --expr "
136138 builtins.fetchClosure {
137139 fromStore = \" file://$cacheDir \" ;
138140 fromPath = $badPath ;
139141 toPath = $caPath ;
140142 }
141- " ) = $caPath ]]
143+ " ) = " $caPath " ]]
142144
143145
144146# However, if the output address is unexpected, we can report it
0 commit comments