From 509f79f12b3190db4be4ff00f8b47ea7026f76e8 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Tue, 1 Oct 2024 03:32:21 -0700 Subject: [PATCH] Enable C/C++ remote tests on macOS Also ensure that the remote worker doesn't fail executions when the spawn fails, but instead sends back the result of the unsuccessful execution. Closes #23085. PiperOrigin-RevId: 680944273 Change-Id: Ic4e0ba5e6f814e89465776e8b06e4ff88e761080 --- src/test/shell/bazel/remote/BUILD | 3 + .../remote/build_without_the_bytes_test.sh | 79 ++--------------- .../bazel/remote/remote_execution_test.sh | 84 ++----------------- 3 files changed, 16 insertions(+), 150 deletions(-) diff --git a/src/test/shell/bazel/remote/BUILD b/src/test/shell/bazel/remote/BUILD index 60cfdb035c3603..f6e2a899c24a6b 100644 --- a/src/test/shell/bazel/remote/BUILD +++ b/src/test/shell/bazel/remote/BUILD @@ -30,6 +30,9 @@ sh_test( "@bazel_tools//tools/bash/runfiles", ], shard_count = 5, + tags = [ + "requires-network", # for Bzlmod (apple_support) + ], ) sh_test( diff --git a/src/test/shell/bazel/remote/build_without_the_bytes_test.sh b/src/test/shell/bazel/remote/build_without_the_bytes_test.sh index a9ae20eb0d77d1..da02000c962d5a 100755 --- a/src/test/shell/bazel/remote/build_without_the_bytes_test.sh +++ b/src/test/shell/bazel/remote/build_without_the_bytes_test.sh @@ -89,13 +89,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 \ @@ -106,13 +99,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 \ @@ -123,13 +109,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 \ @@ -140,13 +119,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 \ @@ -383,13 +355,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' @@ -434,13 +399,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' @@ -569,13 +527,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 @@ -610,8 +561,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 } @@ -649,13 +605,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 < a/BUILD <& $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 < a/BUILD <> 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", @@ -3289,62 +3241,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"