Files
codex/codex-rs/core/BUILD.bazel
T
Dmitriy Kovalenko 17b00277cc Make Bazel Rust tests portable across Linux environments (#63773)
## Why

Some test fixtures depend on `python3` being on the host's `PATH` or
on reading Rust's process arguments from a constructor. Bazel workers
need a declared Python runtime, and musl does not provide those
arguments to constructors.

## What changed

- Put Bazel's Python 3.12 runtime on `PATH` for Linux test suites that
  invoke `python3`, including their Wine launchers.
- Use standalone helper binaries for exec-server and sandbox fixtures on
  musl, and read `/proc/self/cmdline` for the MCP hook fixture.
- Add launcher options for test execution tags and for routing selected
  Linux cases to a local companion target that shares the test binary.
- Adjust test fixtures for platform differences in file creation
  timestamps and shell script execution. Keep cloud-config error tests
  pointed at their mock server after startup falls back to defaults.

## Testing

Exercise marketplace upgrade negotiation at Git 2.20 and check whether
the installed Git supports limiting the refs advertised by the clone.

GitOrigin-RevId: 3a83cde954d52ca29d346d67488c9a25c0790614
2026-11-24 23:57:49 +00:00

65 lines
2.2 KiB
Python

load("//:defs.bzl", "codex_rust_crate")
codex_rust_crate(
name = "core",
compile_data = glob(["assets/**"]),
crate_name = "codex_core",
crate_srcs = glob(["src/**/*.rs"]) + [
"//codex-rs/ext/guardian-v2:src/sync_reviewer/reviewer_config.rs",
],
extra_binaries = [
"//codex-rs/bwrap:bwrap",
"//codex-rs/code-mode-host:codex-code-mode-host",
"//codex-rs/linux-sandbox:codex-linux-sandbox",
"//codex-rs/message-board-mcp:codex-message-board-mcp",
"//codex-rs/rmcp-client:test_stdio_server",
"//codex-rs/rmcp-client:test_streamable_http_server",
"//codex-rs/cli:codex",
"//codex-rs/windows-sandbox-rs:codex-command-runner",
"//codex-rs/windows-sandbox-rs:codex-windows-managed-deny-probe",
"//codex-rs/windows-sandbox-rs:codex-windows-sandbox-setup",
],
integration_compile_data_extra = glob(["assets/**"]) + [
"//codex-rs/message-board:tests/common/mod.rs",
"//codex-rs/prompts:templates/permissions/approval_policy/on_request_rule_request_permission.md",
],
integration_test_timeout = "long",
linux_python_tests = [
"core-all-test",
"core-unit-tests",
],
run_tests_with_wine_exec = True,
rustc_env = {
# Keep manifest-root path lookups inside the Bazel execroot for code
# that relies on env!("CARGO_MANIFEST_DIR").
"CARGO_MANIFEST_DIR": "codex-rs/core",
},
test_data_extra = [
"//codex-rs/message-board-mcp:package-files",
"config.schema.json",
] + glob(["src/**/snapshots/**"]) + [
],
test_shard_counts = {
"core-all-test": 16,
"core-unit-tests": 16,
},
test_tags = ["no-sandbox"],
test_threads = select({
"@platforms//os:macos": 1,
"//conditions:default": 0,
}),
unit_test_srcs = glob([
"src/**/*_test.rs",
"src/**/*_tests.rs",
"src/**/tests.rs",
"src/**/tests/**/*.rs",
]) + [
"src/apps/render.rs",
"src/config/schema.rs",
"src/context/world_state/test_support.rs",
"src/guardian/test_host.rs",
"src/plugins/test_support.rs",
],
unit_test_timeout = "long",
)