Limit Bazel integration test threads on macOS (#39609)

## What changed

- Add a `test_threads` option to `codex_rust_crate` that sets
  `RUST_TEST_THREADS` for sharded integration tests when configured.
- Run the `core` and `app-server` Bazel integration tests with one Rust test
  thread on macOS, leaving the thread count unchanged on other platforms.

GitOrigin-RevId: 118147413eb141f557d9ee82858860617d61acce
This commit is contained in:
jif
2026-08-19 20:25:00 +00:00
committed by copyberry
parent 5c305eb50b
commit c19482a768
3 changed files with 14 additions and 0 deletions

View File

@@ -24,4 +24,8 @@ codex_rust_crate(
"app-server-unit-tests": 8,
},
test_tags = ["no-sandbox"],
test_threads = select({
"@platforms//os:macos": 1,
"//conditions:default": 0,
}),
)

View File

@@ -50,5 +50,9 @@ codex_rust_crate(
"core-unit-tests": 8,
},
test_tags = ["no-sandbox"],
test_threads = select({
"@platforms//os:macos": 1,
"//conditions:default": 0,
}),
unit_test_timeout = "long",
)

View File

@@ -87,6 +87,8 @@ def _workspace_root_test_impl(ctx):
key: ctx.expand_location(value, targets = location_targets.values())
for key, value in ctx.attr.env.items()
}
if ctx.attr.test_threads:
env["RUST_TEST_THREADS"] = str(ctx.attr.test_threads)
return [
DefaultInfo(
@@ -159,6 +161,7 @@ workspace_root_test = rule(
executable = True,
mandatory = True,
),
"test_threads": attr.int(),
"workspace_root_marker": attr.label(
allow_single_file = True,
mandatory = True,
@@ -203,6 +206,7 @@ def codex_rust_crate(
test_data_extra = [],
test_shard_counts = {},
test_tags = [],
test_threads = 0,
unit_test_timeout = None,
extra_binaries = [],
extra_binaries_non_windows = [],
@@ -254,6 +258,7 @@ def codex_rust_crate(
them Bazel's default three attempts.
test_tags: Tags applied to unit + integration test targets.
Typically used to disable the sandbox, but see https://bazel.build/reference/be/common-definitions#common.tags
test_threads: Optional Rust test thread limit for sharded integration tests.
unit_test_timeout: Optional Bazel timeout for the unit-test target
generated from `src/**/*.rs`.
extra_binaries: Additional binary labels to surface as test data and
@@ -564,6 +569,7 @@ def codex_rust_crate(
# manifest-only platforms.
runfile_env = integration_test_cargo_env_runfiles,
test_bin = ":" + integration_test_binary,
test_threads = test_threads,
workspace_root_marker = "//codex-rs/utils/cargo-bin:repo_root.marker",
target_compatible_with = WINDOWS_GNULLVM_INCOMPATIBLE,
tags = test_tags,