Skip to content

test(cli): assert on what the CLI owns, not on what the OS says - #555

Merged
David-Noble-at-work merged 1 commit into
developfrom
windows-cli-test-assertions
Aug 19, 2026
Merged

David-Noble-at-work merged 1 commit into
developfrom
windows-cli-test-assertions

Conversation

@David-Noble-at-work

Copy link
Copy Markdown
Contributor

Two of the eighteen known windows failures were tests asserting text that was never ours to depend on.
Neither is a product defect: the CLI behaves correctly on windows in both cases.

TestCLI_ConfigPath

cli_test.go:324: output missing "devlore/config.yaml" (len=73)

The printed path is OS-native, so the literal only ever matched on Unix -- windows prints
devlore\config.yaml. Under the identity/access rule a config path is access, so the CLI is right and
the test encoded a Unix assumption.

It now asserts xdg.ConfigPath("devlore", "config.yaml").

Asking xdg rather than cli.SharedConfigPath() is deliberate: SharedConfigPath is the very function the
command calls, so asserting against it would agree with itself however wrong it became. xdg is one level
down and states the claim independently.

TestCLI_RunMissingFile

cli_test.go:132: output missing "no such file" (len=1091)

The runner wraps os.ReadFile with %w:

return nil, fmt.Errorf("reading script %s: %w", r.script, err)

so the tail of that message is the OS speaking -- no such file or directory on Unix, The system cannot find the file specified. on windows. The test was asserting which platform it ran on.

It now asserts the two substrings we produce: the reading script prefix, and the path the caller passed.

Accepted trade: the assertion can no longer distinguish a missing file from an unreadable one. This is a
CLI smoke test, and the wrapped error still carries the OS's specific diagnosis for anyone reading it. The
alternative -- normalizing fs.ErrNotExist into our own phrasing -- buys uniform text at the cost of a
precise one, and works against the %w idiom.

Verified

  • make check -- clean
  • Windows baseline expected to move 18 -> 16, verified name-for-name against develop before merge

Refs #373.

Two of the eighteen known windows failures were tests asserting text that was never ours to depend on.

TestCLI_ConfigPath asserted the output contained "devlore/config.yaml". The printed path is OS-native, so
that literal only ever matched on Unix; windows prints devlore\config.yaml and the assertion read it as a
missing substring. It now asks xdg.ConfigPath("devlore", "config.yaml") -- the helper that defines the
location -- rather than restating its shape by hand.

Asking xdg rather than cli.SharedConfigPath is deliberate. SharedConfigPath is the function the command
itself calls, so asserting against it would agree with itself no matter how wrong it got; xdg is one level
down and states the claim independently.

TestCLI_RunMissingFile asserted "no such file". The runner wraps os.ReadFile with %w, so the tail of that
message is the OS speaking: "no such file or directory" on Unix, "The system cannot find the file
specified." on windows. The test was checking which platform it was running on. It now asserts the two
substrings we actually produce -- the "reading script" prefix and the path the caller passed.

That leaves the assertion unable to tell a missing file from an unreadable one. Accepted: this is a CLI
smoke test, and the wrapped error still carries the specific diagnosis for anyone reading it. Restating the
OS's message in our own words was the alternative, and it trades a precise diagnosis for a uniform one.

Baseline moves 18 -> 16. Verified name-for-name against develop.

Refs #373.
@David-Noble-at-work David-Noble-at-work self-assigned this Aug 19, 2026
@David-Noble-at-work
David-Noble-at-work merged commit 43921e5 into develop Aug 19, 2026
7 of 8 checks passed
@David-Noble-at-work
David-Noble-at-work deleted the windows-cli-test-assertions branch August 19, 2026 00:21
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