From 598c7805feaf0a2148d4c357e97a25cd2a47b38a Mon Sep 17 00:00:00 2001 From: Googler Date: Mon, 16 Jan 2023 03:19:09 -0800 Subject: [PATCH] Add integration tests for https://github.com/bazelbuild/bazel/pull/17195. PiperOrigin-RevId: 502341854 Change-Id: I2d5d60d218359621b91f48528aa0b49c319db767 --- .../remote/build_without_the_bytes_test.sh | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) 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 932ed9c8953e25..b1c26be5815b5d 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 @@ -537,6 +537,64 @@ EOF || fail "Expected test binary bazel-bin/a/test to be downloaded" } +function do_test_non_test_toplevel_targets() { + # Regression test for https://github.com/bazelbuild/bazel/issues/17190. + # + # Test that when using --remote_download_toplevel with bazel test, outputs of + # non-test targets are downloaded. When using --remote_download_minimal with + # bazel test, outputs of non-test targets are not downloaded. + + mkdir -p a + cat > a/BUILD <<'EOF' +genrule( + name = "foo", + srcs = [], + outs = ["foo.txt"], + cmd = "echo \"foo\" > \"$@\"", +) + +cc_test( + name = 'test', + srcs = [ 'test.cc' ], +) +EOF + cat > a/test.cc < +int main() { std::cout << "Hello test!" << std::endl; return 0; } +EOF + + bazel test \ + --remote_executor=grpc://localhost:${worker_port} \ + $@ \ + //a/... || fail "failed to test" +} + +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" +} + function test_downloads_minimal_bep() { # Test that when using --remote_download_minimal all URI's in the BEP # are rewritten as bytestream://..