$npx -y skills add openai/codex --skill remote-testsTesting against remote executors in integration tests.
| 1 | Remote executor tests exercise the app-server/exec-server split to ensure that agent features work |
| 2 | in both local and remote execution environments. |
| 3 | |
| 4 | Remote executor tests currently require an x86_64 Linux host machine. There are two flavors: |
| 5 | |
| 6 | 1. Docker (Linux exec-server) |
| 7 | 2. Wine (Windows exec-server) |
| 8 | |
| 9 | ## Test Fixtures |
| 10 | |
| 11 | Individual test cases must opt-in to being run against a remote executor. |
| 12 | |
| 13 | ### codex_core |
| 14 | |
| 15 | Use `TestCodexBuilder::build_with_auto_env()` to opt-in to remote execution in core integration |
| 16 | tests unless the test needs more precise control over its executor. |
| 17 | |
| 18 | ### app-server |
| 19 | |
| 20 | Start the server with `TestAppServer::new_with_auto_env()` unless the test defines its own |
| 21 | `$CODEX_HOME/environments.toml` or will define custom environments at runtime. |
| 22 | |
| 23 | Start threads with `TestAppServer::send_thread_start_request_with_auto_env()` if you've created the |
| 24 | server with the `auto_env` approach. Omit `ThreadStartParams.environments` (leave it as `None`) when |
| 25 | doing so. |
| 26 | |
| 27 | ## Test Skips |
| 28 | |
| 29 | If a test doesn't pass in a particular remote executor configuration you can skip it in just that |
| 30 | configuration. Include a string reason for future readers when the selected skip macro supports |
| 31 | one. |
| 32 | |
| 33 | Choose the skip macro by what causes the test to fail: |
| 34 | |
| 35 | - `skip_if_target_windows!`: Windows target behavior. |
| 36 | - `skip_if_wine_exec!`: Wine-exec runner constraints. |
| 37 | - `skip_if_host_windows!`: Windows host constraints. |
| 38 | - `skip_if_remote!`: Local-only test behavior. |
| 39 | - `skip_if_no_remote_env!`: Remote-only test behavior. |
| 40 | |
| 41 | Prefer defining tests that run in all host/target configurations by default. See the `$path-types` |
| 42 | skill for the most common changes required to make tests compatible. |
| 43 | |
| 44 | ## Docker |
| 45 | |
| 46 | Docker container is built and initialized via ./scripts/test-remote-env.sh. Sourcing this script |
| 47 | in bash also provides the `codex_remote_env_cleanup` function to use after testing. |
| 48 | |
| 49 | To run core integration tests against a Docker remote executor: |
| 50 | |
| 51 | ```bash |
| 52 | bash -c ' |
| 53 | set -euo pipefail |
| 54 | unset CODEX_TEST_REMOTE_EXEC_SERVER_URL |
| 55 | source scripts/test-remote-env.sh |
| 56 | trap codex_remote_env_cleanup EXIT |
| 57 | |
| 58 | cd codex-rs |
| 59 | just test -p codex-core --test all |
| 60 | ' |
| 61 | ``` |
| 62 | |
| 63 | To run app-server integration tests against a Docker remote executor: |
| 64 | |
| 65 | ```bash |
| 66 | bash -c ' |
| 67 | set -euo pipefail |
| 68 | unset CODEX_TEST_REMOTE_EXEC_SERVER_URL |
| 69 | source scripts/test-remote-env.sh |
| 70 | trap codex_remote_env_cleanup EXIT |
| 71 | |
| 72 | cd codex-rs |
| 73 | just test -p codex-app-server --test all |
| 74 | ' |
| 75 | ``` |
| 76 | |
| 77 | ## Wine |
| 78 | |
| 79 | These tests build an exec-server for Windows and run it under Wine, with the app-server staying on |
| 80 | the Linux host. The cross-platform build dependency means they only run in Bazel. |
| 81 | |
| 82 | For core integration tests: |
| 83 | |
| 84 | ```sh |
| 85 | bazel test //codex-rs/core:core-all-wine-exec-test |
| 86 | ``` |
| 87 | |
| 88 | For app-server integration tests: |
| 89 | |
| 90 | ```sh |
| 91 | bazel test //codex-rs/app-server:app-server-all-wine-exec-test |
| 92 | ``` |
| 93 | |
| 94 | ## Devboxes |
| 95 | |
| 96 | You can use a devbox to run these tests if you are running on a macOS machine. |
| 97 | |
| 98 | You can list devboxes via `applied_devbox ls`, pick the one with `codex` in the name. |
| 99 | Connect to devbox via `ssh <devbox_name>`. |
| 100 | Reuse the same checkout of codex in `~/code/codex`. Reset files if needed. Multiple checkouts take longer to build and take up more space. |
| 101 | Check whether the SHA and modified files are in sync between remote and local. |