mirror of
https://github.com/openai/codex.git
synced 2026-04-26 07:35:29 +00:00
## Why The Bazel-backed `argument-comment-lint` CI path had two gaps: - Bazel wildcard target expansion skipped inline unit-test crates from `src/` modules because the generated `*-unit-tests-bin` `rust_test` targets are tagged `manual`. - `argument-comment-mismatch` was still only a warning in the Bazel and packaged-wrapper entrypoints, so a typoed `/*param_name*/` comment could still pass CI even when the lint detected it. That left CI blind to real linux-sandbox examples, including the missing `/*local_port*/` comment in `codex-rs/linux-sandbox/src/proxy_routing.rs` and typoed argument comments in `codex-rs/linux-sandbox/src/landlock.rs`. ## What Changed - Added `tools/argument-comment-lint/list-bazel-targets.sh` so Bazel lint runs cover `//codex-rs/...` plus the manual `rust_test` `*-unit-tests-bin` targets. - Updated `just argument-comment-lint`, `rust-ci.yml`, and `rust-ci-full.yml` to use that helper. - Promoted both `argument-comment-mismatch` and `uncommented-anonymous-literal-argument` to errors in every strict entrypoint: - `tools/argument-comment-lint/lint_aspect.bzl` - `tools/argument-comment-lint/src/bin/argument-comment-lint.rs` - `tools/argument-comment-lint/wrapper_common.py` - Added wrapper/bin coverage for the stricter lint flags and documented the behavior in `tools/argument-comment-lint/README.md`. - Fixed the now-covered callsites in `codex-rs/linux-sandbox/src/proxy_routing.rs`, `codex-rs/linux-sandbox/src/landlock.rs`, and `codex-rs/core/src/shell_snapshot_tests.rs`. This keeps the Bazel target expansion narrow while making the Bazel and prebuilt-linter paths enforce the same strict lint set. ## Verification - `python3 -m unittest discover -s tools/argument-comment-lint -p 'test_*.py'` - `cargo +nightly-2025-09-18 test --manifest-path tools/argument-comment-lint/Cargo.toml` - `just argument-comment-lint`
122 lines
3.4 KiB
Python
122 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
import unittest
|
|
|
|
import wrapper_common
|
|
|
|
|
|
class WrapperCommonTest(unittest.TestCase):
|
|
def test_defaults_to_workspace_and_all_targets(self) -> None:
|
|
parsed = wrapper_common.parse_wrapper_args([])
|
|
final_args = wrapper_common.build_final_args(parsed, Path("/repo/codex-rs/Cargo.toml"))
|
|
|
|
self.assertEqual(
|
|
final_args,
|
|
[
|
|
"--manifest-path",
|
|
"/repo/codex-rs/Cargo.toml",
|
|
"--workspace",
|
|
"--no-deps",
|
|
"--",
|
|
"--all-targets",
|
|
],
|
|
)
|
|
|
|
def test_forwarded_cargo_args_keep_single_separator(self) -> None:
|
|
parsed = wrapper_common.parse_wrapper_args(["-p", "codex-core", "--", "--tests"])
|
|
final_args = wrapper_common.build_final_args(parsed, Path("/repo/codex-rs/Cargo.toml"))
|
|
|
|
self.assertEqual(
|
|
final_args,
|
|
[
|
|
"--manifest-path",
|
|
"/repo/codex-rs/Cargo.toml",
|
|
"--no-deps",
|
|
"-p",
|
|
"codex-core",
|
|
"--",
|
|
"--tests",
|
|
],
|
|
)
|
|
|
|
def test_fix_does_not_add_all_targets(self) -> None:
|
|
parsed = wrapper_common.parse_wrapper_args(["--fix", "-p", "codex-core"])
|
|
final_args = wrapper_common.build_final_args(parsed, Path("/repo/codex-rs/Cargo.toml"))
|
|
|
|
self.assertEqual(
|
|
final_args,
|
|
[
|
|
"--manifest-path",
|
|
"/repo/codex-rs/Cargo.toml",
|
|
"--no-deps",
|
|
"--fix",
|
|
"-p",
|
|
"codex-core",
|
|
],
|
|
)
|
|
|
|
def test_explicit_manifest_and_workspace_are_preserved(self) -> None:
|
|
parsed = wrapper_common.parse_wrapper_args(
|
|
[
|
|
"--manifest-path",
|
|
"/tmp/custom/Cargo.toml",
|
|
"--workspace",
|
|
"--no-deps",
|
|
"--",
|
|
"--bins",
|
|
]
|
|
)
|
|
final_args = wrapper_common.build_final_args(parsed, Path("/repo/codex-rs/Cargo.toml"))
|
|
|
|
self.assertEqual(
|
|
final_args,
|
|
[
|
|
"--manifest-path",
|
|
"/tmp/custom/Cargo.toml",
|
|
"--workspace",
|
|
"--no-deps",
|
|
"--",
|
|
"--bins",
|
|
],
|
|
)
|
|
|
|
def test_explicit_package_manifest_does_not_force_workspace(self) -> None:
|
|
parsed = wrapper_common.parse_wrapper_args(
|
|
[
|
|
"--manifest-path",
|
|
"/tmp/custom/Cargo.toml",
|
|
]
|
|
)
|
|
final_args = wrapper_common.build_final_args(parsed, Path("/repo/codex-rs/Cargo.toml"))
|
|
|
|
self.assertEqual(
|
|
final_args,
|
|
[
|
|
"--no-deps",
|
|
"--manifest-path",
|
|
"/tmp/custom/Cargo.toml",
|
|
"--",
|
|
"--all-targets",
|
|
],
|
|
)
|
|
|
|
def test_default_lint_env_promotes_both_strict_lints(self) -> None:
|
|
env: dict[str, str] = {}
|
|
|
|
wrapper_common.set_default_lint_env(env)
|
|
|
|
self.assertEqual(
|
|
env["DYLINT_RUSTFLAGS"],
|
|
"-D argument-comment-mismatch "
|
|
"-D uncommented-anonymous-literal-argument "
|
|
"-A unknown_lints",
|
|
)
|
|
self.assertEqual(env["CARGO_INCREMENTAL"], "0")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|