test: maximize cmd/go-rcp and tsn coverage - #70
Merged
Conversation
Make the CLI commands testable (inject io.Writer / return exit codes instead of writing to os.Stdout and calling os.Exit/log.Fatalf) and cover the previously-untested command and registry surface. No behaviour change — 'relay conform --strict' still passes. - cmd/go-rcp 26.6% -> 71.7%: unit tests for the §11.1 mandatory commands (version/capabilities/status, JSON + text), flagFormat, and the RCP commands (discover, send success/unknown-zone, monitor). cmdVersion/ cmdCapabilities/cmdStatus/cmdDiscover now take an io.Writer; cmdSend returns an exit code; cmdMonitor takes a context + writer. - tsn 28.8% -> 97.5%: the gap was untested registry/accessor surface, not truly platform-gated. Added tests for Subscribe, Send-after-close, NewController bad-addr, and the full Registry (Dial, Register dup/foreign, Deregister, Lookup, Controllers, Close, closed-registry errors). Only the Linux SO_PRIORITY syscall (sockprio_linux.go) remains uncovered on darwin; it is exercised on the Linux CI runner. - .gitignore: ignore the /go-rcp and /rcptool CLI build artifacts. All gates green: gofusa check, golangci-lint v2, go vet, go test -race ./..., relay conform --strict. Signed-off-by: SoundMatt <47545907+SoundMatt@users.noreply.github.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
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.
Summary
Makes the CLI commands testable and covers the previously-untested command and registry surface. No behaviour change —
relay conform --strictstill passes, and the capabilities/version/status documents are byte-for-byte unchanged.cmd/go-rcptsncmd/go-rcpcmdVersion/cmdCapabilities/cmdStatus/cmdDiscovernow take anio.Writer;cmdSendreturns an exit code (wasos.Exit/log.Fatalf);cmdMonitortakes acontext+ writer.main()wiring unchanged in behaviour.flagFormat, and the RCP commands (discover, send success + unknown-zone, monitor). The remaining gap ismain()'s arg dispatch.tsnThe 28.8% was untested registry/accessor surface, not truly platform-gated. Added tests for Subscribe, Send-after-close,
NewControllerbad-addr, and the full Registry (Dial, Register dup/foreign, Deregister, Lookup, Controllers, Close, closed-registry errors).Only the Linux
SO_PRIORITYsyscall (sockprio_linux.go) remains uncovered on darwin — exercised on the Linux CI runner..gitignore: ignore the/go-rcpand/rcptoolCLI build artifacts.Verification
gofusa check,golangci-lintv2,go vet ./...,go test -race ./...,relay conform --strict— all PASS.