Files
codex/codex-rs/mxc-sandbox/src/native_tests.rs
T
zm-oai 818bde0995 Include Win32 error codes in MXC process launch failures (#61227)
## Why

MXC launch errors omit the native Windows error code, while the SDK diagnostics can contain command, environment, and working-directory data.

## What changed

Extract the numeric error code from recognized `CreateProcessW` failures and append it to the launch error without exposing the remaining SDK diagnostics. Preserve the existing error message when no code can be extracted.

## Testing

Add unit tests for extracting the code without trailing diagnostics and rejecting nonnumeric codes and errors from other APIs.

GitOrigin-RevId: ddfa6635ab4fe9293ab4d31f9fcd7cfe563d4928
2026-11-13 01:43:44 +00:00

21 lines
536 B
Rust

#![cfg(test)]
use super::create_process_error;
#[test]
fn returns_only_the_native_create_process_error() {
let api = "CreateProcessW(PROC_THREAD_ATTRIBUTE_SECURITY_ENVIRONMENT) failed: ";
assert_eq!(
create_process_error(&format!("{api}WIN32_ERROR(5) (working directory: private)")),
Some(5)
);
assert_eq!(
create_process_error(&format!("{api}WIN32_ERROR(private)")),
None
);
assert_eq!(
create_process_error("another API failed: WIN32_ERROR(5)"),
None
);
}