fix(tests/unified): use argparse mutex group for --test-dir/--test-file

The previous mutual-exclusion check compared --test-dir against its
default string literal, so passing --test-file together with an
explicit --test-dir tests/unified/test_cases silently bypassed the
check. Replace with argparse.add_mutually_exclusive_group() and apply
the default path post-parse so the bare invocation still works.
This commit is contained in:
thrialectics 2026-05-05 12:31:23 -04:00
parent c165c51fae
commit 5eafd67c33
1 changed files with 5 additions and 7 deletions

View File

@ -12,13 +12,13 @@ from tests.unified.runner import UnifiedTestRunner
async def main():
parser = argparse.ArgumentParser(description="Run Unified Honcho Tests")
parser.add_argument(
target_group = parser.add_mutually_exclusive_group()
target_group.add_argument(
"--test-dir",
type=str,
default="tests/unified/test_cases",
help="Directory containing JSON test files",
)
parser.add_argument(
target_group.add_argument(
"--test-file",
type=str,
help="Path to a single JSON test file to run",
@ -32,10 +32,8 @@ async def main():
args = parser.parse_args()
# Validate mutually exclusive args
if args.test_file and args.test_dir != "tests/unified/test_cases":
print("Error: Cannot specify both --test-file and --test-dir")
sys.exit(1)
if args.test_file is None and args.test_dir is None:
args.test_dir = "tests/unified/test_cases"
if args.test_file:
test_path = Path(args.test_file)