mirror of
https://github.com/openai/codex.git
synced 2026-04-28 18:32:04 +03:00
109 lines
3.0 KiB
Python
109 lines
3.0 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",
|
|
],
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|