Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable C/C++ remote tests on macOS #23085

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/test/shell/bazel/remote/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ sh_test(
"@bazel_tools//tools/bash/runfiles",
],
shard_count = 5,
tags = [
"requires-network", # for Bzlmod (apple_support)
],
)

sh_test(
Expand Down
79 changes: 7 additions & 72 deletions src/test/shell/bazel/remote/build_without_the_bytes_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ EOF
function test_cc_tree_remote_executor_download_all() {
# Regression test for https://github.com/bazelbuild/bazel/issues/19988.

if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

setup_cc_tree

bazel build \
Expand All @@ -108,13 +101,6 @@ function test_cc_tree_remote_executor_download_all() {
}

function test_cc_tree_remote_executor_download_minimal() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

setup_cc_tree

bazel build \
Expand All @@ -125,13 +111,6 @@ function test_cc_tree_remote_executor_download_minimal() {
}

function test_cc_tree_remote_cache_download_minimal() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

setup_cc_tree

bazel build \
Expand All @@ -142,13 +121,6 @@ function test_cc_tree_remote_cache_download_minimal() {
}

function test_cc_tree_prefetching_download_minimal() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

setup_cc_tree

bazel build \
Expand Down Expand Up @@ -385,13 +357,6 @@ EOF
function test_downloads_toplevel_runfiles() {
# Test that --remote_download_toplevel fetches only the top level binaries
# and generated runfiles.
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

mkdir -p a

cat > a/create_bar.tmpl <<'EOF'
Expand Down Expand Up @@ -436,13 +401,6 @@ EOF
# particular, cc_binary links against a symlinked imported .so file, and only
# the symlink is in the runfiles.
function test_downloads_toplevel_symlink_action() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

mkdir -p a

cat > a/bar.cc <<'EOF'
Expand Down Expand Up @@ -571,13 +529,6 @@ EOF
}

function test_download_toplevel_templated_tree_artifact() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

mkdir -p a

# We need the top-level output to be a tree artifact generated by a template
Expand Down Expand Up @@ -612,8 +563,13 @@ EOF
--output_groups=compilation_outputs \
//a:main || fail "Failed to build //a:main"

if ! [[ -f bazel-bin/a/_pic_objs/main/dir/foo.pic.o ]]; then
fail "Expected toplevel output bazel-out/a/_pic_objs/main/dir/foo.pic.o to be downloaded"
if [[ "$PLATFORM" == "darwin" ]]; then
expected_object_file=bazel-bin/a/_objs/main/dir/foo.o
else
expected_object_file=bazel-bin/a/_pic_objs/main/dir/foo.pic.o
fi
if ! [[ -f "$expected_object_file" ]]; then
fail "Expected toplevel output $expected_object_file to be downloaded"
fi
}

Expand Down Expand Up @@ -651,13 +607,6 @@ function test_download_toplevel_test_rule() {
# the test.log and test.xml file are downloaded but not the test binary.
# However when building a test then the test binary should be downloaded.

if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

mkdir -p a
cat > a/BUILD <<EOF
package(default_visibility = ["//visibility:public"])
Expand Down Expand Up @@ -729,26 +678,12 @@ EOF
}

function test_non_test_toplevel_targets_toplevel() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

do_test_non_test_toplevel_targets --remote_download_toplevel

[[ -f bazel-bin/a/foo.txt ]] || fail "Expected a/foo.txt to be downloaded"
}

function test_non_test_toplevel_targets_minimal() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

do_test_non_test_toplevel_targets --remote_download_minimal

[[ ! -f bazel-bin/a/foo.txt ]] || fail "Expected a/foo.txt to not be downloaded"
Expand Down
84 changes: 6 additions & 78 deletions src/test/shell/bazel/remote/remote_execution_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,6 @@ EOF
}

function test_cc_binary() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

mkdir -p a
cat > a/BUILD <<EOF
package(default_visibility = ["//visibility:public"])
Expand All @@ -301,19 +294,12 @@ EOF
--remote_executor=grpc://localhost:${worker_port} \
//a:test >& $TEST_log \
|| fail "Failed to build //a:test with remote execution"
expect_log "6 processes: 4 internal, 2 remote"
expect_log "[0-9] processes: [0-9] internal, 2 remote\\."
diff bazel-bin/a/test ${TEST_TMPDIR}/test_expected \
|| fail "Remote execution generated different result"
}

function test_cc_test() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

mkdir -p a
cat > a/BUILD <<EOF
package(default_visibility = ["//visibility:public"])
Expand All @@ -336,13 +322,6 @@ EOF
}

function test_cc_test_split_xml() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

mkdir -p a
cat > a/BUILD <<EOF
package(default_visibility = ["//visibility:public"])
Expand Down Expand Up @@ -2396,13 +2375,6 @@ EOF
# Older versions of gcov are not supported with bazel coverage and so will be skipped.
# See the above `test_java_rbe_coverage_produces_report` for more information.
function test_cc_rbe_coverage_produces_report() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

# Check to see if intermediate files are supported, otherwise skip.
gcov --help | grep "\-i," || return 0

Expand Down Expand Up @@ -2520,13 +2492,6 @@ EOF
# returned non-empty.
# See the above `test_java_rbe_coverage_produces_report` for more information.
function test_cc_rbe_coverage_produces_report_with_llvm() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

local -r clang=$(which clang)
if [[ ! -x "${clang}" ]]; then
echo "clang not installed. Skipping"
Expand Down Expand Up @@ -3062,13 +3027,6 @@ EOF
}

function test_external_cc_test() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

setup_external_cc_test

bazel test \
Expand All @@ -3078,13 +3036,6 @@ function test_external_cc_test() {
}

function test_external_cc_test_sibling_repository_layout() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

setup_external_cc_test

bazel test \
Expand Down Expand Up @@ -3193,6 +3144,7 @@ function setup_cc_binary_tool_with_dynamic_deps() {
local repo=$1

cat >> MODULE.bazel <<'EOF'
bazel_dep(name = "apple_support", version = "1.17.0")
local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
local_repository(
name = "other_repo",
Expand Down Expand Up @@ -3255,62 +3207,38 @@ EOF
}

function test_cc_binary_tool_with_dynamic_deps() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

setup_cc_binary_tool_with_dynamic_deps .

bazel build \
--incompatible_macos_set_install_name \
--remote_executor=grpc://localhost:${worker_port} \
//pkg:rule >& $TEST_log || fail "Build should succeed"
}

function test_cc_binary_tool_with_dynamic_deps_sibling_repository_layout() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

setup_cc_binary_tool_with_dynamic_deps .

bazel build \
--incompatible_macos_set_install_name \
--experimental_sibling_repository_layout \
--remote_executor=grpc://localhost:${worker_port} \
//pkg:rule >& $TEST_log || fail "Build should succeed"
}

function test_external_cc_binary_tool_with_dynamic_deps() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

setup_cc_binary_tool_with_dynamic_deps other_repo

bazel build \
--incompatible_macos_set_install_name \
--remote_executor=grpc://localhost:${worker_port} \
@other_repo//pkg:rule >& $TEST_log || fail "Build should succeed"
}

function test_external_cc_binary_tool_with_dynamic_deps_sibling_repository_layout() {
if [[ "$PLATFORM" == "darwin" ]]; then
# TODO(b/37355380): This test is disabled due to RemoteWorker not supporting
# setting SDKROOT and DEVELOPER_DIR appropriately, as is required of
# action executors in order to select the appropriate Xcode toolchain.
return 0
fi

setup_cc_binary_tool_with_dynamic_deps other_repo

bazel build \
--incompatible_macos_set_install_name \
--experimental_sibling_repository_layout \
--remote_executor=grpc://localhost:${worker_port} \
@other_repo//pkg:rule >& $TEST_log || fail "Build should succeed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,7 @@ public void waitExecution(WaitExecutionRequest wr, StreamObserver<Operation> res
return;
}
((ServerCallStreamObserver<Operation>) responseObserver)
.setOnCancelHandler(
() -> {
future.cancel(true);
operationsCache.remove(opName);
});
.setOnCancelHandler(() -> operationsCache.remove(opName));
waitExecution(opName, future, responseObserver);
}

Expand Down Expand Up @@ -238,11 +234,7 @@ public void execute(ExecuteRequest request, StreamObserver<Operation> responseOb
executorService.submit(() -> execute(context, request, opName));
operationsCache.put(opName, future);
((ServerCallStreamObserver<Operation>) responseObserver)
.setOnCancelHandler(
() -> {
future.cancel(true);
operationsCache.remove(opName);
});
.setOnCancelHandler(() -> operationsCache.remove(opName));
// Send the first operation.
responseObserver.onNext(Operation.newBuilder().setName(opName).build());
// When the operation completes, send the result.
Expand Down
Loading