Files
codex/codex-rs/cli/src/config_override_args_tests.rs
T
Benjamin Carlsson cf24cd5a93 Centralize CLI config flag expansion (#65134)
## What changed

Expand root feature toggles and auto-review flags in the config
argument module before dispatch. Keep auto-review expansion for
`resume` in its command-specific path.

## Testing

Extend the `mcp add` argument test to check that a root `--disable`
follows the collected `-c` overrides and that the command-scoped
override still takes precedence. The test also checks that `-c` after
`--` is forwarded to the MCP server command.

GitOrigin-RevId: 6a7b2a8dddb9043dbfde6b8a20cd98cef5b39ab0
2026-12-02 01:42:03 +00:00

58 lines
1.5 KiB
Rust

//! Regression coverage for overrides split across CLI command boundaries.
use super::try_parse_from;
use crate::Subcommand;
use crate::mcp_cmd::McpSubcommand;
use pretty_assertions::assert_eq;
#[test]
fn preserves_scoped_overrides_and_forwarded_arguments() {
let mut cli = try_parse_from([
"codex",
"--config=features.unified_exec=true",
"--disable",
"unified_exec",
"mcp",
"-cmodel=example",
"add",
"example",
"-c",
"features.unified_exec=true",
"--",
"program",
"-c",
"payload",
])
.expect("parse");
assert_eq!(
cli.config_overrides.raw_overrides,
[
"features.unified_exec=true",
"model=example",
"features.unified_exec=true"
]
);
super::expand_flags(&mut cli).expect("expand");
let Some(Subcommand::Mcp(mut mcp)) = cli.subcommand else {
panic!("expected mcp");
};
crate::prepend_config_flags(&mut mcp.config_overrides, cli.config_overrides);
assert_eq!(
mcp.config_overrides.raw_overrides,
[
"features.unified_exec=true",
"model=example",
"features.unified_exec=true",
"features.unified_exec=false",
"features.unified_exec=true"
]
);
let McpSubcommand::Add(add) = mcp.subcommand else {
panic!("expected add");
};
assert_eq!(
add.transport_args.stdio.expect("stdio transport").command,
["program", "-c", "payload"],
);
}