Fix rules_cc integration tests under Bazel@HEAD downstream CI In Bazel downstream CI (`--use_but`), Bazelisk links `USE_BAZEL_VERSION` to a Bazel binary under `/tmp`. On Linux, `--sandbox_tmpfs_path=/tmp` hides `/tmp` inside the test sandbox, which makes the `@local_bazel//:bazel` symlink dangle and causes all integration tests to fail immediately. Also, OSS integration tests used the default 300s timeout instead of `long`, causing `//tests/integration:cc_integration_test` to time out on Intel macOS workers. - Copy the resolved Bazel binary (`cp -L`) instead of symlinking it on non-Windows platforms in `local_bazel.bzl`. - Default `timeout = "long"` in `rules_cc_integration_test.bzl.oss`. PiperOrigin-RevId: 1025490292 Change-Id: I70351b1e48be3f71f7661b8728b2a877ec78b506
diff --git a/local_bazel.bzl b/local_bazel.bzl index ab937b9..4e478fe 100644 --- a/local_bazel.bzl +++ b/local_bazel.bzl
@@ -33,7 +33,15 @@ if bazel_path == None: fail("Neither '%s' or '%s' not found on PATH." % (bazel_real, bazel_name)) - repository_ctx.symlink(bazel_path, link_name) + if "windows" in repository_ctx.os.name.lower(): + repository_ctx.symlink(bazel_path, link_name) + else: + # Dereference and copy instead of symlinking so the binary remains + # accessible inside sandboxes with --sandbox_tmpfs_path=/tmp when + # USE_BAZEL_VERSION points to a binary under /tmp. + result = repository_ctx.execute(["cp", "-L", str(bazel_path), link_name]) + if result.return_code != 0: + fail("Failed to copy '%s' to '%s': %s" % (bazel_path, link_name, result.stderr)) # sh_binary on Windows must end with .exe but we want a consistent target name, so we # wrap it in an alias.
diff --git a/tests/integration/rules_cc_integration_test.bzl b/tests/integration/rules_cc_integration_test.bzl index a5c0e03..60b719e 100644 --- a/tests/integration/rules_cc_integration_test.bzl +++ b/tests/integration/rules_cc_integration_test.bzl
@@ -21,6 +21,7 @@ test_script, data = [], env = {}, + timeout = "long", **kwargs): """Integration test for rules_cc. @@ -29,6 +30,7 @@ test_script: The shell script for the test. data: (optional) Additional data dependencies required for the test. env: (optional) Additional environment variables to pass to the test. + timeout: (optional) Timeout for the test target. **kwargs: Additional arguments to pass to the test target. """ @@ -55,5 +57,6 @@ "@rules_shell//shell/runfiles", ] + data, env = test_env, + timeout = timeout, **kwargs )