GH-50934: [C++][Dev] Fix shellcheck errors in cpp/build-support/run-test.sh - #50935
GH-50934: [C++][Dev] Fix shellcheck errors in cpp/build-support/run-test.sh#50935hiroyuki-sato wants to merge 8 commits into
Conversation
|
|
da4e451 to
7b9e1a6
Compare
|
rebased for re-run CI job |
|
@kou I don't think the two CI failures are related to this PR. What do you think? |
|
Failing C++ / AMD64 Conda C++ AVX2 is the new issue #50930 |
| ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) || { | ||
| echo "Failed to determine project root directory" >&2 | ||
| exit 1 | ||
| } |
There was a problem hiding this comment.
I also tried using set -e instead of || { echo "error"; }.
However, it seems we need to modify more code.
For example, this part causes the script to exit when the exit status is 1.
I'm not sure if this is the exact reason, but it seems to cause an error.
Do you have any idea?
"$TEST_EXECUTABLE" "$@" > "${LOGFILE}.raw" 2>&1
diff --git a/cpp/build-support/run-test.sh b/cpp/build-support/run-test.sh
index e3c0738410..0e02b1ab8a 100755
--- a/cpp/build-support/run-test.sh
+++ b/cpp/build-support/run-test.sh
@@ -23,12 +23,11 @@
# $ARGN - arguments for executable
#
+set -e
+
OUTPUT_ROOT="$1"
shift
-ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) || {
- echo "Failed to determine project root directory" >&2
- exit 1
-}
+ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
TEST_LOGDIR="$OUTPUT_ROOT/build/$1-logs"
mkdir -p "$TEST_LOGDIR"
@@ -38,10 +37,7 @@ shift
TEST_DEBUGDIR="$OUTPUT_ROOT/build/$RUN_TYPE-debug"
mkdir -p "$TEST_DEBUGDIR"
-TEST_DIRNAME=$(cd "$(dirname "$1")" && pwd) || {
- echo "Failed to change to test directory: $(dirname "$1")" >&2
- exit 1
-}
+TEST_DIRNAME=$(cd "$(dirname "$1")" && pwd)
TEST_FILENAME=$(basename "$1")
shift
TEST_EXECUTABLE="$TEST_DIRNAME/$TEST_FILENAME"
@@ -50,10 +46,7 @@ TEST_NAME=$(echo "$TEST_FILENAME" | sed -E -e 's/\..+$//') # Remove path and ext
# We run each test in its own subdir to avoid core file related races.
TEST_WORKDIR="$OUTPUT_ROOT/build/test-work/$TEST_NAME"
mkdir -p "$TEST_WORKDIR"
-pushd "$TEST_WORKDIR" >/dev/null || {
- echo "Failed to change to test working directory: $TEST_WORKDIR" >&2
- exit 1
-}
+pushd "$TEST_WORKDIR" >/dev/null
rm -f ./*
set -o pipefail
@@ -243,10 +236,7 @@ fi
print_coredumps
-popd || {
- echo "Failed to restore the previous working directory" >&2
- exit 1
-}
+popd
rm -Rf "$TEST_WORKDIR"
exit "$STATUS"This change cause the following errors.
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1775143Z Total Test time (real) = 548.94 sec
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1775314Z
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1775405Z The following tests FAILED:
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1775759Z 2 - arrow-buffer-test (Failed) arrow-tests unittest
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1776240Z 3 - arrow-extension-type-test (Failed) arrow-tests unittest
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1776688Z 4 - arrow-misc-test (Failed) arrow-tests unittest
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1777139Z 5 - arrow-public-api-test (Failed) arrow-tests unittest
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1777585Z 6 - arrow-scalar-test (Failed) arrow-tests unittest
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1778010Z 7 - arrow-type-test (Failed) arrow-tests unittest
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1778430Z 8 - arrow-table-test (Failed) arrow-tests unittest
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1778858Z 9 - arrow-tensor-test (Failed) arrow-tests unittest
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1779308Z 10 - arrow-sparse-tensor-test (Failed) arrow-tests unittest
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1779745Z 11 - arrow-stl-test (Failed) arrow-tests unittest
AMD64 Conda C++ AVX2 UNKNOWN STEP 2026-08-24T11:10:33.1780176Z 18 - arrow-generator-test (Failed) arrow-tests unittest
There was a problem hiding this comment.
How about this?
diff --git a/cpp/build-support/run-test.sh b/cpp/build-support/run-test.sh
index 20e225d8dd..b992a21226 100755
--- a/cpp/build-support/run-test.sh
+++ b/cpp/build-support/run-test.sh
@@ -92,8 +92,11 @@ function run_test() {
# even when retries are successful.
rm -f $XMLFILE
- $TEST_EXECUTABLE "$@" > $LOGFILE.raw 2>&1
- STATUS=$?
+ if $TEST_EXECUTABLE "$@" > $LOGFILE.raw 2>&1; then
+ STATUS=0
+ else
+ STATUS=1
+ fi
cat $LOGFILE.raw \
| ${PYTHON:-python} $ROOT/build-support/asan_symbolize.py \
| ${CXXFILT:-c++filt} \There was a problem hiding this comment.
Thank you for your comments. I'll try it. It looks like we need to make changes not only to this part, but also to other parts.
bc92179 to
45bba12
Compare
Rationale for this change
This is the sub issue #44748.
What changes are included in this PR?
Are these changes tested?
Yes.
Are there any user-facing changes?
No.