mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Enable --deny-warnings for cargo shear (#21616)
## Summary In https://github.com/openai/codex/pull/21584, we disabled doctests for crates that lack any doctests. We can enforce that property via `cargo shear --deny-warnings`: crates that lack doctests will be flagged if doctests are enabled, and crates with doctests will be flagged if doctests are disabled. A few additional notes: - By adding `--deny-warnings`, `cargo shear` also flagged a number of modules that were not reachable at all. Some of those have been removed. - This PR removes a usage of `windows_modules!` (since `cargo shear` and `rustfmt` couldn't see through it) in favor of simple `#[cfg(target_os = "windows")]` macros. As a consequence, many of these files exhibit churn in this PR, since they weren't being formatted by `rustfmt` at all on main. - Again, to make the code more analyzable, this PR also removes some usages of `#[path = "cwd_junction.rs"]` in favor of a more standard module structure. The bin sidecar structure is still retained, but, e.g., `windows-sandbox-rs/src/bin/command_runner.rs` was moved to `windows-sandbox-rs/src/bin/command_runner/main.rs`, and so on. --------- Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
use super::parse_freeform_args;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn parse_freeform_args_without_pragma() {
|
||||
let args = parse_freeform_args("output_text('ok');").expect("parse args");
|
||||
assert_eq!(args.code, "output_text('ok');");
|
||||
assert_eq!(args.yield_time_ms, None);
|
||||
assert_eq!(args.max_output_tokens, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_freeform_args_with_pragma() {
|
||||
let input = concat!(
|
||||
"// @exec: {\"yield_time_ms\": 15000, \"max_output_tokens\": 2000}\n",
|
||||
"output_text('ok');",
|
||||
);
|
||||
let args = parse_freeform_args(input).expect("parse args");
|
||||
assert_eq!(args.code, "output_text('ok');");
|
||||
assert_eq!(args.yield_time_ms, Some(15_000));
|
||||
assert_eq!(args.max_output_tokens, Some(2_000));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_freeform_args_rejects_unknown_key() {
|
||||
let err = parse_freeform_args("// @exec: {\"nope\": 1}\noutput_text('ok');")
|
||||
.expect_err("expected error");
|
||||
assert_eq!(
|
||||
err.to_string(),
|
||||
"exec pragma only supports `yield_time_ms` and `max_output_tokens`; got `nope`"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_freeform_args_rejects_missing_source() {
|
||||
let err = parse_freeform_args("// @exec: {\"yield_time_ms\": 10}").expect_err("expected error");
|
||||
assert_eq!(
|
||||
err.to_string(),
|
||||
"exec pragma must be followed by JavaScript source on subsequent lines"
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user