Skip to content

fix: CLI error reporting for cmd? and cd with absolute paths - #129

Merged
oguyon merged 2 commits into
framework-devfrom
feat/cli-robustness-tests
Mar 22, 2026
Merged

fix: CLI error reporting for cmd? and cd with absolute paths#129
oguyon merged 2 commits into
framework-devfrom
feat/cli-robustness-tests

Conversation

@oguyon

@oguyon oguyon commented Mar 22, 2026

Copy link
Copy Markdown
Member

Summary

Adds a comprehensive CLI robustness test suite and fixes two error reporting bugs discovered by it.

CLI robustness test suite (new)

  • tests/cli/cli_robustness_tests.milk — 109 annotated test cases covering parsing, built-in commands, variables, arithmetic, flow control, user functions, command chaining, shell features, and error conditions.
  • tests/cli/run_cli_robustness_tests.sh — Bash test runner that feeds test blocks to milk-cli via FIFO mode, captures output, and categorizes results as PASS/FAIL/MISSING_ERROR/CRASH/HANG.
  • .agents/workflows/cli-robustness-test.md — Workflow for running the test suite.

Bug fixes

  1. cmd? with unknown commandhelp_command() in CLIcore_help.c now returns RETURN_FAILURE when the queried command is not found. Previously it always returned RETURN_SUCCESS even after printing "does not exist".

  2. cd /absolute/path silent failure — Extended the tokenizer raw-string bypass in CLIcore_UI.c to treat /-prefixed arguments as raw strings (same as - prefixed arguments). The / in absolute paths was being interpreted as division by cli_parse(), causing a silent parse error that skipped command execution entirely.

Test expectation corrections

  • mem.mk2Dim and mem.rm with no arguments correctly create a local FPS with default values — updated test expectations from #EXPECT:ERR to #EXPECT:OK.
  • Added does not exist to the runner's error-detection grep pattern.

Prompt Summary

User requested a comprehensive CLI test suite to identify bad behavior (crashes, missing error messages). The test suite was created and run, revealing 4 MISSING_ERROR cases. Two were real bugs (fixed here), two were false positives (test expectations corrected).

AI Authorship

  • Model: Claude Sonnet 4.6 (Anthropic) via Antigravity
  • User edits: None — all changes authored by the agent.

oguyon added 2 commits March 21, 2026 14:24
Add comprehensive automated test suite for milk-cli:

- tests/cli/cli_robustness_tests.milk: 109 annotated test
  cases covering basic parsing, help/discovery, builtins,
  missing/wrong arguments, variables, arithmetic, flow
  control, user functions, command chaining, shell features
  (pipes, redirects, here-strings, command substitution),
  error conditions, set flags, readonly/declare.

- tests/cli/run_cli_robustness_tests.sh: Bash test runner
  that feeds tests one-by-one to milk-cli, captures output,
  checks for crashes/hangs/missing error messages, and
  prints a summary report.

- .agents/workflows/cli-robustness-test.md: Workflow for
  running the test suite.

Initial run: 105 pass, 4 MISSING_ERROR (no error message
printed for: cmd? with unknown command, cd to nonexistent
directory, mem.mk2Dim with no args, mem.rm with no args).
Fix two CLI error reporting bugs found by the robustness test suite:

1. help_command() (cmd?) now returns RETURN_FAILURE when the queried
   command is not found. Previously it always returned RETURN_SUCCESS
   even when printing "does not exist", misleading the caller.

2. Extend tokenizer raw-string bypass to treat arguments starting
   with '/' as raw strings (same as '-' prefixed arguments). This
   fixes cd /absolute/path where the '/' was misinterpreted as
   division by cli_parse(), causing a silent parse error that
   skipped command execution entirely.

Update test expectations: mem.mk2Dim and mem.rm with no arguments
correctly create a local FPS with defaults — this is expected
FPS behavior, not an error. Also add 'does not exist' to the
runner grep pattern for error detection.
@oguyon
oguyon merged commit 92f2cc0 into framework-dev Mar 22, 2026
4 of 5 checks passed
oguyon added a commit that referenced this pull request May 21, 2026
* feat: add CLI robustness test suite

Add comprehensive automated test suite for milk-cli:

- tests/cli/cli_robustness_tests.milk: 109 annotated test
  cases covering basic parsing, help/discovery, builtins,
  missing/wrong arguments, variables, arithmetic, flow
  control, user functions, command chaining, shell features
  (pipes, redirects, here-strings, command substitution),
  error conditions, set flags, readonly/declare.

- tests/cli/run_cli_robustness_tests.sh: Bash test runner
  that feeds tests one-by-one to milk-cli, captures output,
  checks for crashes/hangs/missing error messages, and
  prints a summary report.

- .agents/workflows/cli-robustness-test.md: Workflow for
  running the test suite.

Initial run: 105 pass, 4 MISSING_ERROR (no error message
printed for: cmd? with unknown command, cd to nonexistent
directory, mem.mk2Dim with no args, mem.rm with no args).

* fix: CLI error reporting for cmd? and cd with absolute paths

Fix two CLI error reporting bugs found by the robustness test suite:

1. help_command() (cmd?) now returns RETURN_FAILURE when the queried
   command is not found. Previously it always returned RETURN_SUCCESS
   even when printing "does not exist", misleading the caller.

2. Extend tokenizer raw-string bypass to treat arguments starting
   with '/' as raw strings (same as '-' prefixed arguments). This
   fixes cd /absolute/path where the '/' was misinterpreted as
   division by cli_parse(), causing a silent parse error that
   skipped command execution entirely.

Update test expectations: mem.mk2Dim and mem.rm with no arguments
correctly create a local FPS with defaults — this is expected
FPS behavior, not an error. Also add 'does not exist' to the
runner grep pattern for error detection.
oguyon added a commit that referenced this pull request May 21, 2026
* feat: add CLI robustness test suite

Add comprehensive automated test suite for milk-cli:

- tests/cli/cli_robustness_tests.milk: 109 annotated test
  cases covering basic parsing, help/discovery, builtins,
  missing/wrong arguments, variables, arithmetic, flow
  control, user functions, command chaining, shell features
  (pipes, redirects, here-strings, command substitution),
  error conditions, set flags, readonly/declare.

- tests/cli/run_cli_robustness_tests.sh: Bash test runner
  that feeds tests one-by-one to milk-cli, captures output,
  checks for crashes/hangs/missing error messages, and
  prints a summary report.

- .agents/workflows/cli-robustness-test.md: Workflow for
  running the test suite.

Initial run: 105 pass, 4 MISSING_ERROR (no error message
printed for: cmd? with unknown command, cd to nonexistent
directory, mem.mk2Dim with no args, mem.rm with no args).

* fix: CLI error reporting for cmd? and cd with absolute paths

Fix two CLI error reporting bugs found by the robustness test suite:

1. help_command() (cmd?) now returns RETURN_FAILURE when the queried
   command is not found. Previously it always returned RETURN_SUCCESS
   even when printing "does not exist", misleading the caller.

2. Extend tokenizer raw-string bypass to treat arguments starting
   with '/' as raw strings (same as '-' prefixed arguments). This
   fixes cd /absolute/path where the '/' was misinterpreted as
   division by cli_parse(), causing a silent parse error that
   skipped command execution entirely.

Update test expectations: mem.mk2Dim and mem.rm with no arguments
correctly create a local FPS with defaults — this is expected
FPS behavior, not an error. Also add 'does not exist' to the
runner grep pattern for error detection.
oguyon added a commit that referenced this pull request May 22, 2026
* feat: add CLI robustness test suite

Add comprehensive automated test suite for milk-cli:

- tests/cli/cli_robustness_tests.milk: 109 annotated test
  cases covering basic parsing, help/discovery, builtins,
  missing/wrong arguments, variables, arithmetic, flow
  control, user functions, command chaining, shell features
  (pipes, redirects, here-strings, command substitution),
  error conditions, set flags, readonly/declare.

- tests/cli/run_cli_robustness_tests.sh: Bash test runner
  that feeds tests one-by-one to milk-cli, captures output,
  checks for crashes/hangs/missing error messages, and
  prints a summary report.

- .agents/workflows/cli-robustness-test.md: Workflow for
  running the test suite.

Initial run: 105 pass, 4 MISSING_ERROR (no error message
printed for: cmd? with unknown command, cd to nonexistent
directory, mem.mk2Dim with no args, mem.rm with no args).

* fix: CLI error reporting for cmd? and cd with absolute paths

Fix two CLI error reporting bugs found by the robustness test suite:

1. help_command() (cmd?) now returns RETURN_FAILURE when the queried
   command is not found. Previously it always returned RETURN_SUCCESS
   even when printing "does not exist", misleading the caller.

2. Extend tokenizer raw-string bypass to treat arguments starting
   with '/' as raw strings (same as '-' prefixed arguments). This
   fixes cd /absolute/path where the '/' was misinterpreted as
   division by cli_parse(), causing a silent parse error that
   skipped command execution entirely.

Update test expectations: mem.mk2Dim and mem.rm with no arguments
correctly create a local FPS with defaults — this is expected
FPS behavior, not an error. Also add 'does not exist' to the
runner grep pattern for error detection.
DasVinch pushed a commit that referenced this pull request May 29, 2026
* feat: add CLI robustness test suite

Add comprehensive automated test suite for milk-cli:

- tests/cli/cli_robustness_tests.milk: 109 annotated test
  cases covering basic parsing, help/discovery, builtins,
  missing/wrong arguments, variables, arithmetic, flow
  control, user functions, command chaining, shell features
  (pipes, redirects, here-strings, command substitution),
  error conditions, set flags, readonly/declare.

- tests/cli/run_cli_robustness_tests.sh: Bash test runner
  that feeds tests one-by-one to milk-cli, captures output,
  checks for crashes/hangs/missing error messages, and
  prints a summary report.

- .agents/workflows/cli-robustness-test.md: Workflow for
  running the test suite.

Initial run: 105 pass, 4 MISSING_ERROR (no error message
printed for: cmd? with unknown command, cd to nonexistent
directory, mem.mk2Dim with no args, mem.rm with no args).

* fix: CLI error reporting for cmd? and cd with absolute paths

Fix two CLI error reporting bugs found by the robustness test suite:

1. help_command() (cmd?) now returns RETURN_FAILURE when the queried
   command is not found. Previously it always returned RETURN_SUCCESS
   even when printing "does not exist", misleading the caller.

2. Extend tokenizer raw-string bypass to treat arguments starting
   with '/' as raw strings (same as '-' prefixed arguments). This
   fixes cd /absolute/path where the '/' was misinterpreted as
   division by cli_parse(), causing a silent parse error that
   skipped command execution entirely.

Update test expectations: mem.mk2Dim and mem.rm with no arguments
correctly create a local FPS with defaults — this is expected
FPS behavior, not an error. Also add 'does not exist' to the
runner grep pattern for error detection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant