From 81e570c6e6ddc46ff65b3d11bc9f0f4c60140a0b Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Mon, 7 Dec 2020 01:09:34 -0800 Subject: [PATCH] Fix //src/test/shell/bazel/remote:remote_execution_test test The stop_worker function in remote_utils.sh was broken with an unbounded variable error. This error somehow shadowed the return code of the test cases on macOS. Fixes https://github.com/bazelbuild/bazel/issues/12377 Fixes https://github.com/bazelbuild/bazel/issues/12376 Closes #12629. PiperOrigin-RevId: 346038409 --- src/test/shell/bazel/remote/remote_utils.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/shell/bazel/remote/remote_utils.sh b/src/test/shell/bazel/remote/remote_utils.sh index f5b10dd75e82b0..ce011606a3d3af 100644 --- a/src/test/shell/bazel/remote/remote_utils.sh +++ b/src/test/shell/bazel/remote/remote_utils.sh @@ -19,9 +19,11 @@ REMOTE_WORKER="$(rlocation io_bazel/src/tools/remote/worker)" function start_worker() { - work_path=$(mktemp -d "${TEST_TMPDIR}/remote.XXXXXXXX") - cas_path=$(mktemp -d "${TEST_TMPDIR}/remote.XXXXXXXX") - pid_file=$(mktemp -u "${TEST_TMPDIR}/remote.XXXXXXXX") + work_path="${TEST_TMPDIR}/remote.work_path" + cas_path="${TEST_TMPDIR}/remote.cas_path" + pid_file="${TEST_TMPDIR}/remote.pid_file" + mkdir -p "${work_path}" + mkdir -p "${cas_path}" worker_port=$(pick_random_unused_tcp_port) || fail "no port found" native_lib="${BAZEL_RUNFILES}/src/main/native/" "${REMOTE_WORKER}" \ @@ -43,10 +45,13 @@ function start_worker() { } function stop_worker() { + work_path="${TEST_TMPDIR}/remote.work_path" + cas_path="${TEST_TMPDIR}/remote.cas_path" + pid_file="${TEST_TMPDIR}/remote.pid_file" if [ -s "${pid_file}" ]; then local pid=$(cat "${pid_file}") kill -9 "${pid}" - rm -rf "${pid_file}" + rm -rf "${pid_file}" fi if [ -d "${work_path}" ]; then rm -rf "${work_path}"