Files
codex/bazel/rules/testing/compat/exec_server_compat_test.bzl
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

50 lines
1.8 KiB
Python

"""Bazel coverage for app-server and exec-server release compatibility."""
load("//:defs.bzl", "workspace_root_test")
def exec_server_compat_test(
name,
comparison_binary = None,
current_binary = "//codex-rs/cli:codex",
release = None,
tags = []):
"""Tests both executor directions against another Codex build or release.
Args:
name: Name of the generated compatibility test target.
comparison_binary: Built Codex executable to compare with the current build.
current_binary: Built Codex executable representing the current version.
release: External release repository exposing `:codex` and `:package`.
tags: Additional Bazel tags for the generated test target.
"""
if (comparison_binary == None) == (release == None):
fail("exactly one of comparison_binary and release must be set")
comparison = comparison_binary if release == None else release + "//:codex"
data = [] if release == None else [release + "//:package"]
comparison_alias = name + "-comparison-binary"
native.alias(
name = comparison_alias,
actual = comparison,
tags = ["manual"],
visibility = ["//visibility:private"],
)
workspace_root_test(
name = name,
args = ["--test-threads=1"],
data = data,
runfile_env = {
"//codex-rs/bwrap:bwrap": "CARGO_BIN_EXE_bwrap",
current_binary: "CODEX_TEST_CURRENT_CODEX",
":" + comparison_alias: "CODEX_TEST_RELEASED_CODEX",
},
tags = ["no-sandbox"] + tags,
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
test_bin = "//bazel/rules/testing/compat:exec-server-compat-test-bin",
workspace_root_marker = "//codex-rs/utils/cargo-bin:repo_root.marker",
)