Skip to content

Commit a2380a7

Browse files
author
Takashi Matsuo
authored
testing: add RUNS_PER_TEST environment variable (#3466)
1 parent e8350a3 commit a2380a7

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

ci/kokoro/docker/build-in-docker-bazel.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ echo "Using Bazel in ${BAZEL_BIN}"
4646
echo "================================================================"
4747

4848
bazel_args=("--test_output=errors" "--verbose_failures=true" "--keep_going")
49+
if [[ -n "${RUNS_PER_TEST}" ]]; then
50+
bazel_args+=("--runs_per_test=${RUNS_PER_TEST}")
51+
fi
52+
4953
if [[ -n "${BAZEL_CONFIG}" ]]; then
5054
bazel_args+=("--config" "${BAZEL_CONFIG}")
5155
fi

ci/kokoro/docker/build-in-docker-cmake.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ _EOF_
145145
fi
146146
fi
147147

148+
ctest_args=("--output-on-failure")
149+
if [[ -n "${RUNS_PER_TEST}" ]]; then
150+
ctest_args+=("--repeat-until-fail" "${RUNS_PER_TEST}")
151+
fi
152+
148153
if [[ "${BUILD_TESTING:-}" = "yes" ]]; then
149154
# When the user does a super-build the tests are hidden in a subdirectory.
150155
# We can tell that ${BINARY_DIR} does not have the tests by checking for this
@@ -155,7 +160,7 @@ if [[ "${BUILD_TESTING:-}" = "yes" ]]; then
155160
echo
156161
echo "${COLOR_YELLOW}Running unit tests $(date)${COLOR_RESET}"
157162
echo
158-
(cd "${BINARY_DIR}" && ctest --output-on-failure)
163+
(cd "${BINARY_DIR}" && ctest "${ctest_args[@]}")
159164

160165
echo
161166
echo "${COLOR_YELLOW}Completed unit tests $(date)${COLOR_RESET}"

ci/kokoro/docker/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ docker_flags=(
391391
# produces properly colorized error messages.
392392
"--env" "TERM=${TERM:-dumb}"
393393

394+
# If set, add a flag --runs_per_test=<value> to bazel or --repeat-until-fail
395+
# to ctest.
396+
"--env" "RUNS_PER_TEST=${RUNS_PER_TEST:-}"
397+
394398
# Tells scripts whether they are running as part of a CI or not.
395399
"--env" "RUNNING_CI=${RUNNING_CI:-no}"
396400

0 commit comments

Comments
 (0)