diff --git a/codex-rs/agent-identity/BUILD.bazel b/codex-rs/agent-identity/BUILD.bazel index 3957a19a92..5f49ffb72e 100644 --- a/codex-rs/agent-identity/BUILD.bazel +++ b/codex-rs/agent-identity/BUILD.bazel @@ -3,7 +3,7 @@ load("//:defs.bzl", "codex_rust_crate") codex_rust_crate( name = "agent-identity", crate_name = "codex_agent_identity", - test_sizes = { - "agent-identity-unit-tests-windows-cross": "medium", + test_tags_by_target = { + "agent-identity-unit-tests-windows-cross": ["exclusive-if-local"], }, ) diff --git a/codex-rs/apply-patch/BUILD.bazel b/codex-rs/apply-patch/BUILD.bazel index df0e714b6f..468f606eca 100644 --- a/codex-rs/apply-patch/BUILD.bazel +++ b/codex-rs/apply-patch/BUILD.bazel @@ -3,7 +3,7 @@ load("//:defs.bzl", "codex_rust_crate") codex_rust_crate( name = "apply-patch", crate_name = "codex_apply_patch", - test_sizes = { - "apply-patch-all-test-windows-cross": "medium", + test_tags_by_target = { + "apply-patch-all-test-windows-cross": ["exclusive-if-local"], }, ) diff --git a/codex-rs/file-system/BUILD.bazel b/codex-rs/file-system/BUILD.bazel index 0e311a7a22..4fe0ec7a9d 100644 --- a/codex-rs/file-system/BUILD.bazel +++ b/codex-rs/file-system/BUILD.bazel @@ -3,7 +3,7 @@ load("//:defs.bzl", "codex_rust_crate") codex_rust_crate( name = "file-system", crate_name = "codex_file_system", - test_sizes = { - "file-system-unit-tests-windows-cross": "medium", + test_tags_by_target = { + "file-system-unit-tests-windows-cross": ["exclusive-if-local"], }, ) diff --git a/codex-rs/memories/read/BUILD.bazel b/codex-rs/memories/read/BUILD.bazel index 2e49f74659..fb101c8513 100644 --- a/codex-rs/memories/read/BUILD.bazel +++ b/codex-rs/memories/read/BUILD.bazel @@ -3,7 +3,7 @@ load("//:defs.bzl", "codex_rust_crate") codex_rust_crate( name = "read", crate_name = "codex_memories_read", - test_sizes = { - "read-unit-tests-windows-cross": "medium", + test_tags_by_target = { + "read-unit-tests-windows-cross": ["exclusive-if-local"], }, ) diff --git a/codex-rs/secrets/BUILD.bazel b/codex-rs/secrets/BUILD.bazel index ddd2f3e511..0fefc47377 100644 --- a/codex-rs/secrets/BUILD.bazel +++ b/codex-rs/secrets/BUILD.bazel @@ -3,7 +3,7 @@ load("//:defs.bzl", "codex_rust_crate") codex_rust_crate( name = "secrets", crate_name = "codex_secrets", - test_sizes = { - "secrets-unit-tests-windows-cross": "medium", + test_tags_by_target = { + "secrets-unit-tests-windows-cross": ["exclusive-if-local"], }, ) diff --git a/codex-rs/state/BUILD.bazel b/codex-rs/state/BUILD.bazel index 57a7ad22dd..acf31d0f91 100644 --- a/codex-rs/state/BUILD.bazel +++ b/codex-rs/state/BUILD.bazel @@ -9,7 +9,7 @@ codex_rust_crate( "migrations/**", ]), crate_name = "codex_state", - test_sizes = { - "state-unit-tests-windows-cross": "medium", + test_tags_by_target = { + "state-unit-tests-windows-cross": ["exclusive-if-local"], }, ) diff --git a/codex-rs/utils/approval-presets/BUILD.bazel b/codex-rs/utils/approval-presets/BUILD.bazel index 54e9aea292..c66b9887b5 100644 --- a/codex-rs/utils/approval-presets/BUILD.bazel +++ b/codex-rs/utils/approval-presets/BUILD.bazel @@ -3,7 +3,7 @@ load("//:defs.bzl", "codex_rust_crate") codex_rust_crate( name = "approval-presets", crate_name = "codex_utils_approval_presets", - test_sizes = { - "approval-presets-unit-tests-windows-cross": "medium", + test_tags_by_target = { + "approval-presets-unit-tests-windows-cross": ["exclusive-if-local"], }, ) diff --git a/codex-rs/utils/rustls-provider/BUILD.bazel b/codex-rs/utils/rustls-provider/BUILD.bazel index 4a8a4d9c7f..65c6206104 100644 --- a/codex-rs/utils/rustls-provider/BUILD.bazel +++ b/codex-rs/utils/rustls-provider/BUILD.bazel @@ -5,6 +5,8 @@ codex_rust_crate( crate_name = "codex_utils_rustls_provider", test_sizes = { "rustls-provider-preinstalled-test-windows-cross": "medium", - "rustls-provider-unit-tests-windows-cross": "medium", + }, + test_tags_by_target = { + "rustls-provider-unit-tests-windows-cross": ["exclusive-if-local"], }, ) diff --git a/codex-rs/windows-sandbox-rs/BUILD.bazel b/codex-rs/windows-sandbox-rs/BUILD.bazel index c0c0f9ee7d..a4a7593bf7 100644 --- a/codex-rs/windows-sandbox-rs/BUILD.bazel +++ b/codex-rs/windows-sandbox-rs/BUILD.bazel @@ -6,7 +6,7 @@ codex_rust_crate( "codex-windows-sandbox-setup.manifest", ], crate_name = "codex_windows_sandbox", - test_sizes = { - "windows-sandbox-rs-unit-tests-windows-cross": "medium", + test_tags_by_target = { + "windows-sandbox-rs-unit-tests-windows-cross": ["exclusive-if-local"], }, ) diff --git a/defs.bzl b/defs.bzl index bdc9b09aeb..ff6907dcba 100644 --- a/defs.bzl +++ b/defs.bzl @@ -198,6 +198,7 @@ def codex_rust_crate( test_shard_counts = {}, test_sizes = {}, test_tags = [], + test_tags_by_target = {}, unit_test_timeout = None, extra_binaries = [], extra_binaries_non_windows = [], @@ -247,6 +248,8 @@ def codex_rust_crate( targets individually, including Windows-cross and Wine tests. 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_tags_by_target: Mapping from generated test target name to + additional Bazel tags for that target. 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 @@ -378,7 +381,7 @@ def codex_rust_crate( test_bin = ":" + unit_test_binary, workspace_root_marker = "//codex-rs/utils/cargo-bin:repo_root.marker", target_compatible_with = target_compatible_with, - tags = test_tags, + tags = _test_tags(test_tags, test_tags_by_target, unit_test_target_name), **unit_test_kwargs ) @@ -528,7 +531,7 @@ def codex_rust_crate( test_bin = ":" + integration_test_binary, workspace_root_marker = "//codex-rs/utils/cargo-bin:repo_root.marker", target_compatible_with = WINDOWS_GNULLVM_INCOMPATIBLE, - tags = test_tags, + tags = _test_tags(test_tags, test_tags_by_target, test_name), **test_kwargs ) else: @@ -554,7 +557,7 @@ def codex_rust_crate( rustc_env = rustc_env, env = integration_test_cargo_env, target_compatible_with = WINDOWS_GNULLVM_INCOMPATIBLE, - tags = test_tags, + tags = _test_tags(test_tags, test_tags_by_target, test_name), **test_kwargs ) @@ -604,7 +607,7 @@ def codex_rust_crate( test_bin = "//codex-rs/exec-server/testing:wine-exec-test-runner", workspace_root_marker = "//codex-rs/utils/cargo-bin:repo_root.marker", target_compatible_with = WINE_TEST_TARGET_COMPATIBLE_WITH, - tags = test_tags + ["manual"], + tags = _test_tags(test_tags, test_tags_by_target, wine_test_name) + ["manual"], **wine_test_kwargs ) @@ -642,7 +645,7 @@ def codex_rust_crate( test_bin = ":" + windows_cross_test_binary, workspace_root_marker = "//codex-rs/utils/cargo-bin:repo_root.marker", target_compatible_with = WINDOWS_GNULLVM_ONLY, - tags = test_tags, + tags = _test_tags(test_tags, test_tags_by_target, windows_cross_test_name), **windows_cross_test_kwargs ) @@ -662,6 +665,14 @@ def codex_rust_crate( if unknown_test_shard_counts: fail("test_shard_counts contains unknown generated test targets: {}".format(", ".join(unknown_test_shard_counts))) + unknown_test_tags = sorted([ + test_name + for test_name in test_tags_by_target + if test_name not in generated_test_names + ]) + if unknown_test_tags: + fail("test_tags_by_target contains unknown generated test targets: {}".format(", ".join(unknown_test_tags))) + def _test_shard_count(test_shard_counts, test_name): shard_count = test_shard_counts.get(test_name) if shard_count == None: @@ -672,6 +683,9 @@ def _test_shard_count(test_shard_counts, test_name): return shard_count +def _test_tags(test_tags, test_tags_by_target, test_name): + return test_tags + test_tags_by_target.get(test_name, []) + def _test_size(test_sizes, test_name): size = test_sizes.get(test_name, "small") if size not in ["small", "medium", "large", "enormous"]: