mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
5c8136f48a
## Why We want to make it possible for an app-server orchestrator on one OS to control an exec-server on another host running a different OS. In practice this kinda already works if you get lucky and the two hosts have the same path format, but we mangle quite a lot of operations if either end is Windows. We should be able to test the cross-platform interactions for exec-server, but we want to do this fairly soon and need a lightweight option for testing. Using Wine to run the Windows side is far from perfect, but it should give us a decent measure of how well we're handling the basics of paths, process spawning, shell interaction, etc. Future changes will add actual exec-server tests and possibly extensions to the Wine testing environment. ## What To make the cross-target-triple build easy, these tests are added only to the Bazel build. This change adds an x86_64 Wine prebuilt managed by Bazel and some build rules that can set up the needed toolchain transition. The support library for running Wine in a test environment created by the Bazel rules comes with its own basic unit and integration tests. Their primary priority is to make sure we don't leak child processes on developer machines and that we can build and launch a basic hello world binary. ## Validation Confirmed these new tests are running on the [x86_64 bazel ubuntu jobs](https://github.com/openai/codex/actions/runs/27446432302/job/81132356855?pr=27937): ``` //bazel/rules/testing/wine:wine-smoke-test (cached) PASSED in 3.7s //bazel/rules/testing/wine:wine-test-support-unit-tests (cached) PASSED in 15.8s ```
54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
"""Makes a binary built for a foreign platform available as test data."""
|
|
|
|
_EXTRA_RUSTC_FLAGS = "@rules_rust//rust/settings:extra_rustc_flags"
|
|
|
|
def _foreign_platform_transition_impl(settings, attr):
|
|
# A transition cannot rewrite a dependency's rule attributes. Use the
|
|
# rules_rust build setting when every Rust target in the foreign
|
|
# configuration needs additional compiler or linker flags.
|
|
return {
|
|
"//command_line_option:platforms": [attr.platform],
|
|
_EXTRA_RUSTC_FLAGS: settings[_EXTRA_RUSTC_FLAGS] + attr.extra_rustc_flags,
|
|
}
|
|
|
|
_foreign_platform_transition = transition(
|
|
implementation = _foreign_platform_transition_impl,
|
|
inputs = [_EXTRA_RUSTC_FLAGS],
|
|
outputs = [
|
|
"//command_line_option:platforms",
|
|
_EXTRA_RUSTC_FLAGS,
|
|
],
|
|
)
|
|
|
|
def _foreign_platform_binary_impl(ctx):
|
|
if len(ctx.attr.binary) != 1:
|
|
fail("expected exactly one transitioned binary")
|
|
binary = ctx.attr.binary[0][DefaultInfo]
|
|
runfiles = ctx.runfiles(transitive_files = binary.files)
|
|
runfiles = runfiles.merge(binary.default_runfiles)
|
|
return [
|
|
DefaultInfo(
|
|
files = binary.files,
|
|
runfiles = runfiles,
|
|
),
|
|
]
|
|
|
|
foreign_platform_binary = rule(
|
|
implementation = _foreign_platform_binary_impl,
|
|
attrs = {
|
|
"binary": attr.label(
|
|
cfg = _foreign_platform_transition,
|
|
executable = True,
|
|
mandatory = True,
|
|
),
|
|
"extra_rustc_flags": attr.string_list(
|
|
doc = "Additional flags applied to every Rust target in the foreign configuration.",
|
|
),
|
|
"platform": attr.string(mandatory = True),
|
|
"_allowlist_function_transition": attr.label(
|
|
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
|
|
),
|
|
},
|
|
doc = "Builds `binary` for `platform` and exposes its files and runfiles.",
|
|
)
|