Skip to content

Commit 72b1508

Browse files
committed
lint(shellcheck): Fix warnings
Signed-off-by: Stephen Augustus <[email protected]>
1 parent f01a29f commit 72b1508

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

hack/test-go.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ done
3636
REPO_ROOT=$(git rev-parse --show-toplevel)
3737
cd "${REPO_ROOT}"
3838

39-
GO111MODULE=on go test -v -timeout="${TEST_TIMEOUT}s" -count=1 -cover -coverprofile coverage.out $(go list ./... | grep -v k8s.io/enhancements/cmd)
39+
GO111MODULE=on go test -v -timeout="${TEST_TIMEOUT}s" -count=1 -cover -coverprofile coverage.out "$(go list ./... | grep -v k8s.io/enhancements/cmd)"
40+
4041
go tool cover -html coverage.out -o coverage.html

hack/verify.sh

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21-
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
21+
# cd to the repo root
22+
REPO_ROOT=$(git rev-parse --show-toplevel)
23+
cd "${REPO_ROOT}"
2224

2325
# Some useful colors.
2426
if [[ -z "${color_start-}" ]]; then
2527
declare -r color_start="\033["
2628
declare -r color_red="${color_start}0;31m"
27-
declare -r color_yellow="${color_start}0;33m"
2829
declare -r color_green="${color_start}0;32m"
2930
declare -r color_norm="${color_start}0m"
3031
fi
@@ -38,7 +39,7 @@ EXCLUDED_PATTERNS=(
3839
"verify-golangci-lint.sh"
3940
)
4041

41-
EXCLUDED_CHECKS=$(ls ${EXCLUDED_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/} 2>/dev/null || true)
42+
EXCLUDED_CHECKS=$(ls ${EXCLUDED_PATTERNS[@]/#/${REPO_ROOT}\/hack\/} 2>/dev/null || true)
4243

4344
function is-excluded {
4445
for e in ${EXCLUDED_CHECKS[@]}; do
@@ -57,14 +58,14 @@ function run-cmd {
5758
fi
5859
}
5960

60-
# Collect Failed tests in this Array , initialize it to nil
61+
# Collect failed tests in this array; initialize it to nil
6162
FAILED_TESTS=()
6263

6364
function print-failed-tests {
6465
echo -e "========================"
6566
echo -e "${color_red}FAILED TESTS${color_norm}"
6667
echo -e "========================"
67-
for t in ${FAILED_TESTS[@]}; do
68+
for t in "${FAILED_TESTS[@]}"; do
6869
echo -e "${color_red}${t}${color_norm}"
6970
done
7071
}
@@ -74,23 +75,30 @@ function run-checks {
7475
local -r runner=$2
7576

7677
local t
78+
local check_name
79+
local start
80+
7781
for t in $(ls ${pattern})
7882
do
79-
local check_name="$(basename "${t}")"
83+
check_name="$(basename "${t}")"
8084
if is-excluded "${t}" ; then
8185
echo "Skipping ${check_name}"
8286
continue
8387
fi
88+
8489
echo -e "Verifying ${check_name}"
85-
local start=$(date +%s)
90+
91+
start=$(date +%s)
8692
run-cmd "${runner}" "${t}" && tr=$? || tr=$?
87-
local elapsed=$(($(date +%s) - ${start}))
93+
local elapsed=$(($(date +%s) - start))
94+
8895
if [[ ${tr} -eq 0 ]]; then
8996
echo -e "${color_green}SUCCESS${color_norm} ${check_name}\t${elapsed}s"
9097
else
9198
echo -e "${color_red}FAILED${color_norm} ${check_name}\t${elapsed}s"
9299
ret=1
93-
FAILED_TESTS+=(${t})
100+
101+
FAILED_TESTS+=("${t}")
94102
fi
95103
done
96104
}
@@ -114,11 +122,12 @@ if ${SILENT} ; then
114122
fi
115123

116124
ret=0
117-
run-checks "${KUBE_ROOT}/hack/verify-*.sh" bash
125+
run-checks "${REPO_ROOT}/hack/verify-*.sh" bash
118126

119127
if [[ ${ret} -eq 1 ]]; then
120-
print-failed-tests
128+
print-failed-tests
121129
fi
130+
122131
exit ${ret}
123132

124133
# ex: ts=2 sw=2 et filetype=sh

0 commit comments

Comments
 (0)