Repository navigation
test(cli): assert on what the CLI owns, not on what the OS says - #555
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_ConfigPathThe 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 andthe test encoded a Unix assumption.
It now asserts
xdg.ConfigPath("devlore", "config.yaml").Asking
xdgrather thancli.SharedConfigPath()is deliberate:SharedConfigPathis the very function thecommand calls, so asserting against it would agree with itself however wrong it became.
xdgis one leveldown and states the claim independently.
TestCLI_RunMissingFileThe runner wraps
os.ReadFilewith%w:so the tail of that message is the OS speaking --
no such file or directoryon 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 scriptprefix, 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.ErrNotExistinto our own phrasing -- buys uniform text at the cost of aprecise one, and works against the
%widiom.Verified
make check-- cleandevelopbefore mergeRefs #373.