Skip to content

Commit 738d141

Browse files
authored
Merge pull request #14108 from fzakaria/fzakaria/shellcheck-multiple-3
shellcheck fixes for tests/functional/local-overlay-store
2 parents 7cbc0f9 + f394390 commit 738d141

20 files changed

+69
-72
lines changed

maintainers/flake-module.nix

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -122,29 +122,6 @@
122122
''^tests/functional/install-darwin\.sh$''
123123
''^tests/functional/legacy-ssh-store\.sh$''
124124
''^tests/functional/linux-sandbox\.sh$''
125-
''^tests/functional/local-overlay-store/add-lower-inner\.sh$''
126-
''^tests/functional/local-overlay-store/add-lower\.sh$''
127-
''^tests/functional/local-overlay-store/bad-uris\.sh$''
128-
''^tests/functional/local-overlay-store/build-inner\.sh$''
129-
''^tests/functional/local-overlay-store/build\.sh$''
130-
''^tests/functional/local-overlay-store/check-post-init-inner\.sh$''
131-
''^tests/functional/local-overlay-store/check-post-init\.sh$''
132-
''^tests/functional/local-overlay-store/common\.sh$''
133-
''^tests/functional/local-overlay-store/delete-duplicate-inner\.sh$''
134-
''^tests/functional/local-overlay-store/delete-duplicate\.sh$''
135-
''^tests/functional/local-overlay-store/delete-refs-inner\.sh$''
136-
''^tests/functional/local-overlay-store/delete-refs\.sh$''
137-
''^tests/functional/local-overlay-store/gc-inner\.sh$''
138-
''^tests/functional/local-overlay-store/gc\.sh$''
139-
''^tests/functional/local-overlay-store/optimise-inner\.sh$''
140-
''^tests/functional/local-overlay-store/optimise\.sh$''
141-
''^tests/functional/local-overlay-store/redundant-add-inner\.sh$''
142-
''^tests/functional/local-overlay-store/redundant-add\.sh$''
143-
''^tests/functional/local-overlay-store/remount\.sh$''
144-
''^tests/functional/local-overlay-store/stale-file-handle-inner\.sh$''
145-
''^tests/functional/local-overlay-store/stale-file-handle\.sh$''
146-
''^tests/functional/local-overlay-store/verify-inner\.sh$''
147-
''^tests/functional/local-overlay-store/verify\.sh$''
148125
''^tests/functional/logging\.sh$''
149126
''^tests/functional/misc\.sh$''
150127
''^tests/functional/multiple-outputs\.sh$''

tests/functional/local-overlay-store/add-lower.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# shellcheck shell=bash
12
source common.sh
23
source ../common/init.sh
34

tests/functional/local-overlay-store/bad-uris.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
# shellcheck shell=bash
12
source common.sh
23
source ../common/init.sh
34

45
requireEnvironment
56
setupConfig
67
setupStoreDirs
78

8-
mkdir -p $TEST_ROOT/bad_test
9+
mkdir -p "$TEST_ROOT"/bad_test
910
badTestRoot=$TEST_ROOT/bad_test
1011
storeBadRoot="local-overlay://?root=$badTestRoot&lower-store=$storeA&upper-layer=$storeBTop"
1112
storeBadLower="local-overlay://?root=$storeBRoot&lower-store=$badTestRoot&upper-layer=$storeBTop"
@@ -18,7 +19,8 @@ declare -a storesBad=(
1819
TODO_NixOS
1920

2021
for i in "${storesBad[@]}"; do
21-
echo $i
22+
echo "$i"
23+
# shellcheck disable=SC2119
2224
execUnshare <<EOF
2325
source common.sh
2426
setupStoreDirs

tests/functional/local-overlay-store/build-inner.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ mountOverlayfs
1818

1919
### Do a build in overlay store
2020

21-
path=$(nix-build ../hermetic.nix --arg busybox $busybox --arg seed 2 --store "$storeB" --no-out-link)
21+
path=$(nix-build ../hermetic.nix --arg busybox "$busybox" --arg seed 2 --store "$storeB" --no-out-link)
2222

2323
# Checking for path in lower layer (should fail)
24-
expect 1 stat $(toRealPath "$storeA/nix/store" "$path")
24+
expect 1 stat "$(toRealPath "$storeA/nix/store" "$path")"
2525

2626
# Checking for path in upper layer
27-
stat $(toRealPath "$storeBTop" "$path")
27+
stat "$(toRealPath "$storeBTop" "$path")"
2828

2929
# Verifying path in overlay store
3030
nix-store --verify-path --store "$storeB" "$path"

tests/functional/local-overlay-store/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# shellcheck shell=bash
12
source common.sh
23
source ../common/init.sh
34

tests/functional/local-overlay-store/check-post-init-inner.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,41 @@ mountOverlayfs
1919
### Check status
2020

2121
# Checking for path in lower layer
22-
stat $(toRealPath "$storeA/nix/store" "$pathInLowerStore")
22+
stat "$(toRealPath "$storeA/nix/store" "$pathInLowerStore")"
2323

2424
# Checking for path in upper layer (should fail)
25-
expect 1 stat $(toRealPath "$storeBTop" "$pathInLowerStore")
25+
expect 1 stat "$(toRealPath "$storeBTop" "$pathInLowerStore")"
2626

2727
# Checking for path in overlay store matching lower layer
28-
diff $(toRealPath "$storeA/nix/store" "$pathInLowerStore") $(toRealPath "$storeBRoot/nix/store" "$pathInLowerStore")
28+
diff "$(toRealPath "$storeA/nix/store" "$pathInLowerStore")" "$(toRealPath "$storeBRoot/nix/store" "$pathInLowerStore")"
2929

3030
# Checking requisites query agreement
3131
[[ \
32-
$(nix-store --store $storeA --query --requisites $drvPath) \
32+
$(nix-store --store "$storeA" --query --requisites "$drvPath") \
3333
== \
34-
$(nix-store --store $storeB --query --requisites $drvPath) \
34+
$(nix-store --store "$storeB" --query --requisites "$drvPath") \
3535
]]
3636

3737
# Checking referrers query agreement
38-
busyboxStore=$(nix store --store $storeA add-path $busybox)
38+
busyboxStore=$(nix store --store "$storeA" add-path "$busybox")
3939
[[ \
40-
$(nix-store --store $storeA --query --referrers $busyboxStore) \
40+
$(nix-store --store "$storeA" --query --referrers "$busyboxStore") \
4141
== \
42-
$(nix-store --store $storeB --query --referrers $busyboxStore) \
42+
$(nix-store --store "$storeB" --query --referrers "$busyboxStore") \
4343
]]
4444

4545
# Checking derivers query agreement
4646
[[ \
47-
$(nix-store --store $storeA --query --deriver $pathInLowerStore) \
47+
$(nix-store --store "$storeA" --query --deriver "$pathInLowerStore") \
4848
== \
49-
$(nix-store --store $storeB --query --deriver $pathInLowerStore) \
49+
$(nix-store --store "$storeB" --query --deriver "$pathInLowerStore") \
5050
]]
5151

5252
# Checking outputs query agreement
5353
[[ \
54-
$(nix-store --store $storeA --query --outputs $drvPath) \
54+
$(nix-store --store "$storeA" --query --outputs "$drvPath") \
5555
== \
56-
$(nix-store --store $storeB --query --outputs $drvPath) \
56+
$(nix-store --store "$storeB" --query --outputs "$drvPath") \
5757
]]
5858

5959
# Verifying path in lower layer
@@ -62,10 +62,10 @@ nix-store --verify-path --store "$storeA" "$pathInLowerStore"
6262
# Verifying path in merged-store
6363
nix-store --verify-path --store "$storeB" "$pathInLowerStore"
6464

65-
hashPart=$(echo $pathInLowerStore | sed "s^${NIX_STORE_DIR:-/nix/store}/^^" | sed 's/-.*//')
65+
hashPart=$(echo "$pathInLowerStore" | sed "s^${NIX_STORE_DIR:-/nix/store}/^^" | sed 's/-.*//')
6666

6767
# Lower store can find from hash part
68-
[[ $(nix store --store $storeA path-from-hash-part $hashPart) == $pathInLowerStore ]]
68+
[[ $(nix store --store "$storeA" path-from-hash-part "$hashPart") == "$pathInLowerStore" ]]
6969

7070
# merged store can find from hash part
71-
[[ $(nix store --store $storeB path-from-hash-part $hashPart) == $pathInLowerStore ]]
71+
[[ $(nix store --store "$storeB" path-from-hash-part "$hashPart") == "$pathInLowerStore" ]]

tests/functional/local-overlay-store/check-post-init.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# shellcheck shell=bash
12
source common.sh
23
source ../common/init.sh
34

tests/functional/local-overlay-store/common.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# shellcheck shell=bash
12
source ../common/vars.sh
23
source ../common/functions.sh
34

@@ -54,6 +55,7 @@ setupStoreDirs () {
5455
storeA="$storeVolume/store-a"
5556
storeBTop="$storeVolume/store-b"
5657
storeBRoot="$storeVolume/merged-store"
58+
# shellcheck disable=SC2034
5759
storeB="local-overlay://?root=$storeBRoot&lower-store=$storeA&upper-layer=$storeBTop"
5860
# Creating testing directories
5961
mkdir -p "$storeVolume"/{store-a/nix/store,store-b,merged-store/nix/store,workdir}
@@ -69,8 +71,10 @@ mountOverlayfs () {
6971
|| skipTest "overlayfs is not supported"
7072

7173
cleanupOverlay () {
74+
# shellcheck disable=2317
7275
umount -n "$storeBRoot/nix/store"
73-
rm -r $storeVolume/workdir
76+
# shellcheck disable=2317
77+
rm -r "$storeVolume"/workdir
7478
}
7579
trap cleanupOverlay EXIT
7680
}
@@ -82,16 +86,18 @@ remountOverlayfs () {
8286
toRealPath () {
8387
storeDir=$1; shift
8488
storePath=$1; shift
85-
echo $storeDir$(echo $storePath | sed "s^${NIX_STORE_DIR:-/nix/store}^^")
89+
# shellcheck disable=SC2001
90+
echo "$storeDir""$(echo "$storePath" | sed "s^${NIX_STORE_DIR:-/nix/store}^^")"
8691
}
8792

8893
initLowerStore () {
8994
# Init lower store with some stuff
9095
nix-store --store "$storeA" --add ../dummy
9196

9297
# Build something in lower store
93-
drvPath=$(nix-instantiate --store $storeA ../hermetic.nix --arg withFinalRefs true --arg busybox "$busybox" --arg seed 1)
94-
pathInLowerStore=$(nix-store --store "$storeA" --realise $drvPath)
98+
drvPath=$(nix-instantiate --store "$storeA" ../hermetic.nix --arg withFinalRefs true --arg busybox "$busybox" --arg seed 1)
99+
# shellcheck disable=SC2034
100+
pathInLowerStore=$(nix-store --store "$storeA" --realise "$drvPath")
95101
}
96102

97103
addTextToStore() {

tests/functional/local-overlay-store/delete-duplicate.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# shellcheck shell=bash
12
source common.sh
23
source ../common/init.sh
34

tests/functional/local-overlay-store/delete-refs-inner.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,26 @@ initLowerStore
1515
mountOverlayfs
1616

1717
export NIX_REMOTE="$storeB"
18+
# shellcheck disable=SC2034
1819
stateB="$storeBRoot/nix/var/nix"
1920
hermetic=$(nix-build ../hermetic.nix --no-out-link --arg busybox "$busybox" --arg withFinalRefs true --arg seed 2)
2021
input1=$(nix-build ../hermetic.nix --no-out-link --arg busybox "$busybox" --arg withFinalRefs true --arg seed 2 -A passthru.input1 -j0)
2122
input2=$(nix-build ../hermetic.nix --no-out-link --arg busybox "$busybox" --arg withFinalRefs true --arg seed 2 -A passthru.input2 -j0)
2223
input3=$(nix-build ../hermetic.nix --no-out-link --arg busybox "$busybox" --arg withFinalRefs true --arg seed 2 -A passthru.input3 -j0)
2324

2425
# Can't delete because referenced
25-
expectStderr 1 nix-store --delete $input1 | grepQuiet "Cannot delete path"
26-
expectStderr 1 nix-store --delete $input2 | grepQuiet "Cannot delete path"
27-
expectStderr 1 nix-store --delete $input3 | grepQuiet "Cannot delete path"
26+
expectStderr 1 nix-store --delete "$input1" | grepQuiet "Cannot delete path"
27+
expectStderr 1 nix-store --delete "$input2" | grepQuiet "Cannot delete path"
28+
expectStderr 1 nix-store --delete "$input3" | grepQuiet "Cannot delete path"
2829

2930
# These same paths are referenced in the lower layer (by the seed 1
3031
# build done in `initLowerStore`).
31-
expectStderr 1 nix-store --store "$storeA" --delete $input2 | grepQuiet "Cannot delete path"
32-
expectStderr 1 nix-store --store "$storeA" --delete $input3 | grepQuiet "Cannot delete path"
32+
expectStderr 1 nix-store --store "$storeA" --delete "$input2" | grepQuiet "Cannot delete path"
33+
expectStderr 1 nix-store --store "$storeA" --delete "$input3" | grepQuiet "Cannot delete path"
3334

3435
# Can delete
35-
nix-store --delete $hermetic
36+
nix-store --delete "$hermetic"
3637

3738
# Now unreferenced in upper layer, can delete
38-
nix-store --delete $input3
39-
nix-store --delete $input2
39+
nix-store --delete "$input3"
40+
nix-store --delete "$input2"

0 commit comments

Comments
 (0)