Skip to content

Commit 97fb46d

Browse files
committed
Merge bitcoin/bitcoin#32880: ci: Avoid cd into build dir
fad191f ci: Avoid cd into build dir (MarcoFalke) Pull request description: Changing into the build dir is confusing and brittle, because the following commands implicitly assume it. So they could break on unrelated changes. The changes are required for stuff like: * cmake presets (see bitcoin/bitcoin#30871 (comment)) * meta ci tests (like bitcoin/bitcoin#32874) So remove the `cd` and just make the build dir explicit. ACKs for top commit: hebasto: ACK fad191f, I have reviewed the code and it looks OK. Tree-SHA512: a88a9341445ffe28a0dac3815f235ec8eb0459d10a91a80829fd3184762d3c807d0f68c56243b20c04a6efa5becd8a7fad568f43c2b1e6af1ff8ba07b140ef87
2 parents 69b9ad0 + fad191f commit 97fb46d

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

ci/test/03_test_script.sh

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,22 @@ PRINT_CCACHE_STATISTICS="ccache --version | head -n 1 && ccache --show-stats"
115115

116116
# Folder where the build is done.
117117
BASE_BUILD_DIR=${BASE_BUILD_DIR:-$BASE_SCRATCH_DIR/build-$HOST}
118-
mkdir -p "${BASE_BUILD_DIR}"
119-
cd "${BASE_BUILD_DIR}"
120118

121119
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_INSTALL_PREFIX=$BASE_OUTDIR -Werror=dev"
122120

123121
if [[ "${RUN_TIDY}" == "true" ]]; then
124122
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
125123
fi
126124

127-
bash -c "cmake -S $BASE_ROOT_DIR $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( (cat $(cmake -P "${BASE_ROOT_DIR}/ci/test/GetCMakeLogFiles.cmake")) && false)"
125+
bash -c "cmake -S $BASE_ROOT_DIR -B ${BASE_BUILD_DIR} $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( (cat $(cmake -P "${BASE_ROOT_DIR}/ci/test/GetCMakeLogFiles.cmake")) && false)"
128126

129-
bash -c "cmake --build . $MAKEJOBS --target all $GOAL" || ( echo "Build failure. Verbose build follows." && cmake --build . --target all "$GOAL" --verbose ; false )
127+
# shellcheck disable=SC2086
128+
cmake --build "${BASE_BUILD_DIR}" "$MAKEJOBS" --target all $GOAL || (
129+
echo "Build failure. Verbose build follows."
130+
# shellcheck disable=SC2086
131+
cmake --build "${BASE_BUILD_DIR}" -j1 --target all $GOAL --verbose
132+
false
133+
)
130134

131135
bash -c "${PRINT_CCACHE_STATISTICS}"
132136
du -sh "${DEPENDS_DIR}"/*/
@@ -137,11 +141,17 @@ if [ -n "$USE_VALGRIND" ]; then
137141
fi
138142

139143
if [ "$RUN_CHECK_DEPS" = "true" ]; then
140-
"${BASE_ROOT_DIR}/contrib/devtools/check-deps.sh" .
144+
"${BASE_ROOT_DIR}/contrib/devtools/check-deps.sh" "${BASE_BUILD_DIR}"
141145
fi
142146

143147
if [ "$RUN_UNIT_TESTS" = "true" ]; then
144-
DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" CTEST_OUTPUT_ON_FAILURE=ON ctest --stop-on-failure "${MAKEJOBS}" --timeout $(( TEST_RUNNER_TIMEOUT_FACTOR * 60 ))
148+
DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" \
149+
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" \
150+
CTEST_OUTPUT_ON_FAILURE=ON \
151+
ctest --test-dir "${BASE_BUILD_DIR}" \
152+
--stop-on-failure \
153+
"${MAKEJOBS}" \
154+
--timeout $(( TEST_RUNNER_TIMEOUT_FACTOR * 60 ))
145155
fi
146156

147157
if [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then
@@ -151,7 +161,16 @@ fi
151161
if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then
152162
# parses TEST_RUNNER_EXTRA as an array which allows for multiple arguments such as TEST_RUNNER_EXTRA='--exclude "rpc_bind.py --ipv6"'
153163
eval "TEST_RUNNER_EXTRA=($TEST_RUNNER_EXTRA)"
154-
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" test/functional/test_runner.py --ci "${MAKEJOBS}" --tmpdirprefix "${BASE_SCRATCH_DIR}"/test_runner/ --ansi --combinedlogslen=99999999 --timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" "${TEST_RUNNER_EXTRA[@]}" --quiet --failfast
164+
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" \
165+
"${BASE_BUILD_DIR}/test/functional/test_runner.py" \
166+
--ci "${MAKEJOBS}" \
167+
--tmpdirprefix "${BASE_SCRATCH_DIR}/test_runner/" \
168+
--ansi \
169+
--combinedlogslen=99999999 \
170+
--timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" \
171+
"${TEST_RUNNER_EXTRA[@]}" \
172+
--quiet \
173+
--failfast
155174
fi
156175

157176
if [ "${RUN_TIDY}" = "true" ]; then
@@ -185,5 +204,11 @@ fi
185204

186205
if [ "$RUN_FUZZ_TESTS" = "true" ]; then
187206
# shellcheck disable=SC2086
188-
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" test/fuzz/test_runner.py ${FUZZ_TESTS_CONFIG} "${MAKEJOBS}" -l DEBUG "${DIR_FUZZ_IN}" --empty_min_time=60
207+
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" \
208+
"${BASE_BUILD_DIR}/test/fuzz/test_runner.py" \
209+
${FUZZ_TESTS_CONFIG} \
210+
"${MAKEJOBS}" \
211+
-l DEBUG \
212+
"${DIR_FUZZ_IN}" \
213+
--empty_min_time=60
189214
fi

0 commit comments

Comments
 (0)