Skip to content

Commit 23017e3

Browse files
GH-46699: [CI][Dev] fix shellcheck errors in the ci/scripts/cpp_test.sh (#46700)
### Rationale for this change `ci/scripts/cpp_test.sh` violates two shellcheck rules. * SC2071: `< is for string comparisons. Use -lt instead.` * SC2086: `Double quote to prevent globbing and word splitting.` ``` ./ci/scripts/cpp_test.sh In ./ci/scripts/cpp_test.sh line 22: if [[ $# < 2 ]]; then ^-- SC2071 (error): < is for string comparisons. Use -lt instead. In ./ci/scripts/cpp_test.sh line 87: pushd ${build_dir} ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: pushd "${build_dir}" In ./ci/scripts/cpp_test.sh line 103: --parallel ${n_jobs} \ ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: --parallel "${n_jobs}" \ In ./ci/scripts/cpp_test.sh line 105: --timeout ${ARROW_CTEST_TIMEOUT:-300} \ ^-------------------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: --timeout "${ARROW_CTEST_TIMEOUT:-300}" \ In ./ci/scripts/cpp_test.sh line 111: examples=$(find ${binary_output_dir} -executable -name "*example") ^------------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: examples=$(find "${binary_output_dir}" -executable -name "*example") In ./ci/scripts/cpp_test.sh line 129: ${binary_output_dir}/arrow-ipc-stream-fuzz ${ARROW_TEST_DATA}/arrow-ipc-stream/crash-* ^------------------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: "${binary_output_dir}"/arrow-ipc-stream-fuzz "${ARROW_TEST_DATA}"/arrow-ipc-stream/crash-* In ./ci/scripts/cpp_test.sh line 130: ${binary_output_dir}/arrow-ipc-stream-fuzz ${ARROW_TEST_DATA}/arrow-ipc-stream/*-testcase-* ^------------------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: "${binary_output_dir}"/arrow-ipc-stream-fuzz "${ARROW_TEST_DATA}"/arrow-ipc-stream/*-testcase-* In ./ci/scripts/cpp_test.sh line 131: ${binary_output_dir}/arrow-ipc-file-fuzz ${ARROW_TEST_DATA}/arrow-ipc-file/*-testcase-* ^------------------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: "${binary_output_dir}"/arrow-ipc-file-fuzz "${ARROW_TEST_DATA}"/arrow-ipc-file/*-testcase-* In ./ci/scripts/cpp_test.sh line 132: ${binary_output_dir}/arrow-ipc-tensor-stream-fuzz ${ARROW_TEST_DATA}/arrow-ipc-tensor-stream/*-testcase-* ^------------------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: "${binary_output_dir}"/arrow-ipc-tensor-stream-fuzz "${ARROW_TEST_DATA}"/arrow-ipc-tensor-stream/*-testcase-* In ./ci/scripts/cpp_test.sh line 134: ${binary_output_dir}/parquet-arrow-fuzz ${ARROW_TEST_DATA}/parquet/fuzzing/*-testcase-* ^------------------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: "${binary_output_dir}"/parquet-arrow-fuzz "${ARROW_TEST_DATA}"/parquet/fuzzing/*-testcase-* For more information: https://www.shellcheck.net/wiki/SC2071 -- < is for string comparisons. Use ... https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... ``` ### What changes are included in this PR? * Use `-lt` instead of `<` * Quote variables. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: #46699 Authored-by: Hiroyuki Sato <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent c85c3d0 commit 23017e3

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ repos:
300300
?^ci/scripts/c_glib_build\.sh$|
301301
?^ci/scripts/c_glib_test\.sh$|
302302
?^ci/scripts/conan_setup\.sh$|
303+
?^ci/scripts/cpp_test\.sh$|
303304
?^ci/scripts/csharp_build\.sh$|
304305
?^ci/scripts/csharp_pack\.sh$|
305306
?^ci/scripts/download_tz_database\.sh$|

ci/scripts/cpp_test.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
set -ex
2121

22-
if [[ $# < 2 ]]; then
22+
if [[ $# -lt 2 ]]; then
2323
echo "Usage: $0 <Arrow dir> <build dir> [ctest args ...]"
2424
exit 1
2525
fi
@@ -84,7 +84,7 @@ if [ "${ARROW_EMSCRIPTEN:-OFF}" = "ON" ]; then
8484
n_jobs=1 # avoid spurious fails on emscripten due to loading too many big executables
8585
fi
8686

87-
pushd ${build_dir}
87+
pushd "${build_dir}"
8888

8989
if [ -z "${PYTHON}" ] && ! which python > /dev/null 2>&1; then
9090
export PYTHON="${PYTHON:-python3}"
@@ -100,15 +100,15 @@ else
100100
ctest \
101101
--label-regex unittest \
102102
--output-on-failure \
103-
--parallel ${n_jobs} \
103+
--parallel "${n_jobs}" \
104104
--repeat until-pass:3 \
105-
--timeout ${ARROW_CTEST_TIMEOUT:-300} \
105+
--timeout "${ARROW_CTEST_TIMEOUT:-300}" \
106106
"${ctest_options[@]}" \
107107
"$@"
108108
fi
109109

110110
if [ "${ARROW_BUILD_EXAMPLES}" == "ON" ]; then
111-
examples=$(find ${binary_output_dir} -executable -name "*example")
111+
examples=$(find "${binary_output_dir}" -executable -name "*example")
112112
if [ "${examples}" == "" ]; then
113113
echo "=================="
114114
echo "No examples found!"
@@ -126,12 +126,12 @@ fi
126126

127127
if [ "${ARROW_FUZZING}" == "ON" ]; then
128128
# Fuzzing regression tests
129-
${binary_output_dir}/arrow-ipc-stream-fuzz ${ARROW_TEST_DATA}/arrow-ipc-stream/crash-*
130-
${binary_output_dir}/arrow-ipc-stream-fuzz ${ARROW_TEST_DATA}/arrow-ipc-stream/*-testcase-*
131-
${binary_output_dir}/arrow-ipc-file-fuzz ${ARROW_TEST_DATA}/arrow-ipc-file/*-testcase-*
132-
${binary_output_dir}/arrow-ipc-tensor-stream-fuzz ${ARROW_TEST_DATA}/arrow-ipc-tensor-stream/*-testcase-*
129+
"${binary_output_dir}/arrow-ipc-stream-fuzz" "${ARROW_TEST_DATA}"/arrow-ipc-stream/crash-*
130+
"${binary_output_dir}/arrow-ipc-stream-fuzz" "${ARROW_TEST_DATA}"/arrow-ipc-stream/*-testcase-*
131+
"${binary_output_dir}/arrow-ipc-file-fuzz" "${ARROW_TEST_DATA}"/arrow-ipc-file/*-testcase-*
132+
"${binary_output_dir}/arrow-ipc-tensor-stream-fuzz" "${ARROW_TEST_DATA}"/arrow-ipc-tensor-stream/*-testcase-*
133133
if [ "${ARROW_PARQUET}" == "ON" ]; then
134-
${binary_output_dir}/parquet-arrow-fuzz ${ARROW_TEST_DATA}/parquet/fuzzing/*-testcase-*
134+
"${binary_output_dir}/parquet-arrow-fuzz" "${ARROW_TEST_DATA}"/parquet/fuzzing/*-testcase-*
135135
fi
136136
fi
137137

0 commit comments

Comments
 (0)