Skip to content

Cover the remaining audit gaps in the test suite - #25

Merged
baijum merged 2 commits into
mainfrom
test-coverage
Sep 12, 2026
Merged

baijum merged 2 commits into
mainfrom
test-coverage

Conversation

@baijum

@baijum baijum commented Sep 12, 2026

Copy link
Copy Markdown
Member

Closes #16.

The audit listed eleven untested behaviours. Six were covered by the PRs that fixed the related issues (#18, #20, #22, #23, #24); this PR adds the rest, plus the cosmetic fix the issue asked for.

Gaps, by the issue's numbering

# behaviour status
1 --flag=value on a flag covered in #18
2 malformed specs covered in #23
3 parsed-ref on an unknown name; parsed-flag? on unset and non-#t values added
4 missing positional binds (("input" . #f)) added, at both levels, plus the README's (or ... "World") idiom
5 missing option value; extra positionals covered in #20
6 coercion fallbacks --count=abc covered in #18; --count= and --output= giving "" added
7 three-argument option form (no default) added: #f when absent, uncoerced string when given, no (default: ...) in help
8 run-cli dispatch error paths covered in #20 (exit codes verified by subprocess there, since exit cannot run in-process)
9 generate-help with an unknown subcommand covered in #24
10 user option named --help covered in #22
11 help short-circuit result shape added: positionals before --help are dropped, no command, no sub result, no errors

Help dumps

The suite ended by printing both generated help pages to stdout. Those are replaced by exact row assertions on the app and build pages: title line, usage line, each option row with its padding and default, the built-in help row, and the Arguments and Commands sections in order. That pins the column alignment and section order the README samples rely on, which no test did before. Every remaining line of suite output is a PASS: line or a section header.

Suite: 238 passed, 0 failed on Kaappi v0.27.1. Procedure coverage of (kaappi cli) was already 14/14.

No library or doc changes.

🤖 Generated with Claude Code

The audit in #16 listed eleven untested behaviours. Six were covered by
the fix PRs that closed the related issues; this adds the five that were
not: parsed-ref on an undeclared name and parsed-flag? on unset,
non-boolean and undeclared values; a missing positional binding #f at
both levels, which the README's or-default idiom depends on; the empty
attached value giving ""; the three-argument option form with no
default, absent, given, and in help; and the shape of the result after
--help short-circuits the parse.

The suite used to end by dumping both generated help pages to stdout,
so a non-verbose run still printed two pages. Those dumps are now exact
row assertions on the help layout, which also pins column alignment and
section order the way the README samples rely on.

Closes #16

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Baiju Muthukadan <baiju.m.mail@gmail.com>

@baijum baijum left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally on the branch: the suite passes 238/0 (exit 0), procedure coverage of (kaappi cli) stays 14/14, and the suite's stdout is now nothing but PASS: lines and section headers — the cosmetic ask in #16 is done. I also checked each new assertion against the library and the README contract ("No default → string" matches the --config=42 test, and the exact-row padding matches pad's 28-column target). The gap table in the description checks out against #16, and the commit carries the DCO sign-off.

Three non-blocking comments inline.

Comment thread tests/test-cli.scm Outdated
(check "help short" #t (parsed-ref r "help")))

;; help short-circuits the parse: what came before it is not returned
(let ((r (run-cli-parse app '("data.csv" "-n" "3" "--help"))))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"help short-circuits the parse: what came before it is not returned" slightly overclaims. The short-circuit keeps option values parsed before --help: lib/kaappi/cli.sld:287 builds the help result from the accumulated opts, so myapp data.csv -n 3 -v --help yields count = 3 and verbose = #t while parsed-args is '(). Only positionals/command/sub/errors are dropped.

Since this block exists to pin the result shape, consider asserting the kept half too:

(check "help keeps options parsed before it" 3 (parsed-ref r "count"))

so a future change to either half can't land silently. If not, the comment could still say "positionals and the command are not returned; options parsed before it are kept".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both halves pinned in 456470a: the argv now includes -v as well, and two checks assert count = 3 and verbose = #t are kept while positionals, command, sub and errors are dropped. The comment says exactly that.

Comment thread tests/test-cli.scm
(parsed-args (parsed-sub r))))

;; option with no default: #f when absent, an uncoerced string when given
(define dapp

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These four checks cover the no-default option form (item 7 of #16) rather than accessors. Since the === ... === headers are the suite's only navigation, this block might deserve its own header (e.g. === No-default options ===) before === Commands ===.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split out in 456470a under its own === No-default options === header, before Commands.

Comment thread tests/test-cli.scm
(check "app help usage line" #t
(string-contains? out "Usage: myapp [options] <command> <input>\n\nOptions:\n"))
(check "app help flag row" #t
(string-contains? out " -v, --verbose Verbose output\n"))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These exact rows deliberately hardcode pad's 28-column target as literal space runs — fine, since the alignment stays readable in the source — just noting the maintenance cost: if the target ever changes, all ~12 strings need respacing by hand, and the tempting shortcut is pasting actual output over expected. If that ever bites, a small helper computing the gap (make-string (- 28 n) #\space) would turn a deliberate alignment change into a one-line edit. Not asking for it now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on the trade-off, leaving the literal rows as they are for now. If the 28-column target ever moves, a (row short long desc) helper built on make-string is the change to make in the same PR, and this thread is the pointer.

Review follow-ups. The help short-circuit block only asserted what is
dropped, and its comment claimed nothing before --help is returned,
which overstates it: option values and flags parsed before --help are
kept. Both halves are asserted now so neither can change silently. The
no-default option checks were filed under the accessor header; they get
their own, since the headers are the suite's only navigation.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Baiju Muthukadan <baiju.m.mail@gmail.com>
@baijum

baijum commented Sep 12, 2026

Copy link
Copy Markdown
Member Author

Review addressed in 456470a:

  • Help short-circuit: kept half now asserted too (count and verbose survive --help), comment reworded.
  • No-default option tests: own === No-default options === header.
  • Literal padding rows: left as is per the comment; a helper is the move if the column target ever changes.

Suite: 240 passed, 0 failed.

@baijum
baijum merged commit 264362b into main Sep 12, 2026
2 checks passed
@baijum
baijum deleted the test-coverage branch September 12, 2026 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Test suite: error and edge paths have zero coverage

1 participant