Repository navigation
fix(devlore-test): route output streams portably instead of via /dev paths - #380
Merged
Merged
Conversation
…paths Issue #379. devlore-test run could not execute on Windows at all: every output stream defaulted to /dev/stdout, openDest was a plain os.OpenFile, and the open failed before the command produced anything. It aborted with "opening graph output: open /dev/null: The system cannot find the path specified." Per the ruling, the two sentinels are handled differently because they are different problems. Standard output is intercepted. stdoutSentinel is matched in openDest and never reaches the filesystem, which also fixes a latent bug the Unix path was hiding: the callers defer a Close on what openDest returns, so routing to stdout was closing the process's own standard output. openDest now returns an io.WriteCloser and the stdout case is a nopWriteCloser. Discard needs no interception. os.DevNull already names each platform's device — /dev/null on Unix, NUL on Windows — and opens correctly on both. So the fix there is spelling, not mechanism: help text and examples interpolate os.DevNull rather than hardcoding /dev/null, and the same applies to the tests that route streams away. Four further sites carried the same defect and are corrected together, being the identical mistake rather than separate scope: commands_test.go routed to /dev/null directly, and scenario_integration_test.go and repo_cmd_test.go both set GIT_CONFIG_GLOBAL and GIT_CONFIG_SYSTEM to /dev/null to suppress ambient git configuration. No /dev/null literal remains in non-prototype Go code. The root command's help also advertised /tmp/receipt.yaml as its example destination; that is now a bare relative filename, which is meaningful everywhere. This is roughly 16 of the 47 remaining Windows failures — the 12 exit-code-1 cases, the 5 missing JSON summaries, the 2 missing "Hello World!" assertions, and the 2 explicit /dev/null failures. Not addressed here, and left for its own change: data/test_compensation.star forces a failure with destination_path="/dev/null/impossible/path.txt". On Windows that path is apparently creatable, so the copy succeeds where the fixture expects an error. That is a different problem — the impossible-path idiom — not the discard sentinel. The plan's corrected phase 2 triage rides in this commit: the .exe fix cleared 16 failures rather than the ~37 estimated, because 14 TestCLI cases were failing for this second reason behind the first. Verified on Darwin: make vet, make build, full make test green — zero FAIL or panic lines by count; gofmt clean; run --help renders /dev/null here, which is what os.DevNull is on this platform. CI's windows leg is the real verification. Plan: docs/plans/platform-test-matrix.md (phase 3). Issue: #379
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.
Issue #379, phase 3 of #373.
The defect
devlore-test runcould not execute on Windows at all. Every output stream defaulted to/dev/stdout,openDestwas a plainos.OpenFile, and the open failed before the command produced anything:Two sentinels, two treatments
Per the ruling, because they are genuinely different problems:
Standard output is intercepted.
stdoutSentinelis matched inopenDestand never reaches the filesystem. This also fixes a latent bug the Unix path was hiding: callersdeferaCloseon whateveropenDestreturns, so routing to stdout was closing the process's own standard output.openDestnow returns anio.WriteCloser, and the stdout case is anopWriteCloser.Discard needs no interception.
os.DevNullalready names each platform's device —/dev/nullon Unix,NULon Windows — and opens correctly on both. The fix there is spelling, not mechanism.Scope
Four further sites carried the identical mistake and are corrected together rather than split out:
commands_test.gorouted to/dev/nulldirectly, andscenario_integration_test.goandrepo_cmd_test.gosetGIT_CONFIG_GLOBAL/GIT_CONFIG_SYSTEMto/dev/nullto suppress ambient git config. No/dev/nullliteral remains in non-prototype Go code — asserted by the commit script.The root help also advertised
/tmp/receipt.yaml; now a bare relative filename, meaningful everywhere.This should clear roughly 16 of the 47 remaining Windows failures.
Deliberately not in this PR
data/test_compensation.starforces a failure viadestination_path="/dev/null/impossible/path.txt". On Windows that path is apparently creatable, so the copy succeeds where the fixture expects an error. That's the impossible-path idiom, not the discard sentinel — a different problem deserving its own change.Plan update
The corrected phase 2 triage rides along: the
.exefix cleared 16, not the ~37 I estimated, because 14TestCLI_*cases were failing for this second reason hidden behind the first.Verified on Darwin:
make vet,make build, fullmake testgreen (zero FAIL/panic by count),gofmtclean, andrun --helprenders/dev/nullhere — which is whatos.DevNullis on this platform. CI's windows leg is the real verification.