Skip to content

Added BATS coverage for verbose flag positions and arg passthru.#169

Merged
ocean merged 1 commit into
ahoy-cli:v3-candidatefrom
AlexSkrypnyk:feature/v-flag-tests
May 12, 2026
Merged

Added BATS coverage for verbose flag positions and arg passthru.#169
ocean merged 1 commit into
ahoy-cli:v3-candidatefrom
AlexSkrypnyk:feature/v-flag-tests

Conversation

@AlexSkrypnyk
Copy link
Copy Markdown
Collaborator

@AlexSkrypnyk AlexSkrypnyk commented May 12, 2026

Summary

  • Added tests/verbose-flag.bats with 10 new BATS tests covering verbose flag positioning and positional argument passthrough.
  • Tests pin the contract that Cobra's persistent flag handler accepts -v / --verbose anywhere relative to the subcommand and its arguments (before the command, after the command, interspersed with positional args), and that the legacy single-dash pre-parser in flag.go handles the case where -v appears before the subcommand name.
  • Tests also verify that positional arguments reach the underlying command without requiring a -- separator, and that a literal -- correctly passes flag-like strings (e.g. -v, --verbose) through as plain arguments rather than activating verbose mode.

Test plan

  • go build -o ./ahoy . completes without errors.
  • go vet ./... reports no issues.
  • go test -v -race ./... passes all unit tests.
  • bats tests runs all BATS tests (125 total, including the 10 new ones) and all pass.
  • Spot-check: run ./ahoy -f tests/testdata/simple.ahoy.yml echo -v hello and confirm the ===> Ahoy echo header appears.
  • Spot-check: run ./ahoy -f tests/testdata/simple.ahoy.yml echo -- -v and confirm output is literally -v with no debug header.

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for verbose flag functionality, including support for different flag positions, argument forwarding, and environment variable configuration.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c098da18-f794-458e-a3c7-8d4c5e056209

📥 Commits

Reviewing files that changed from the base of the PR and between 74d156d and ef689b6.

📒 Files selected for processing (1)
  • tests/verbose-flag.bats

Walkthrough

This pull request adds a comprehensive Bats test suite that validates verbose flag (-v / --verbose) behaviour across multiple placements, argument forwarding semantics with and without the -- separator, and environment variable activation via AHOY_VERBOSE=true.

Changes

Verbose flag test coverage

Layer / File(s) Summary
Verbose flag test cases
tests/verbose-flag.bats
New Bats test file with 10 test cases covering verbose flag activation before/after subcommand, interspersed between positional arguments, literal passthrough with -- separator, multiple argument forwarding, and AHOY_VERBOSE environment variable activation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

A verbose hare hops through test cases with glee,
Flags before, flags after, all working perfectly!
Arguments dance freely without -- delay,
Environment variables light the debug way. 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarises the main change: adding BATS test coverage for verbose flag positioning and argument pass-through behaviour.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ocean
Copy link
Copy Markdown
Member

ocean commented May 12, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ocean ocean merged commit aa7f6e7 into ahoy-cli:v3-candidate May 12, 2026
10 checks passed
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.

2 participants