tests: tighten coverage by retiring unreachable defensive code#2
Merged
Conversation
Split the runtime.GOOS switch in addLoopbackAlias/removeLoopbackAlias across three per-OS files using build tags: - loopback_linux.go (uses 'ip addr add/del') - loopback_darwin.go (uses 'ifconfig lo0 alias/-alias') - loopback_other.go (logs 'unsupported OS'; build tag !linux && !darwin) Each per-OS file is the only one compiled on its target, so its single-branch impl is always exercised by tests on that platform — no more cross-OS unreachable arms inflating the denominator. Coverage on darwin 96.8% -> 100.0% (and likewise on linux). The 'other' file has no test coverage but builds clean on freebsd/windows etc.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Split the
runtime.GOOSswitch inaddLoopbackAlias/removeLoopbackAliasacross three per-OS files using build tags:loopback_linux.go—ip addr add/delloopback_darwin.go—ifconfig lo0 alias/-aliasloopback_other.go— logsunsupported OS(//go:build !linux && !darwin)Each per-OS file is the only one compiled on its target, so its single-branch impl is exercised by every test run on that platform — no more cross-OS unreachable arms inflating the denominator.
Coverage
Cross-compiles verified for linux + freebsd.
Test plan
go test -race -count=1 -timeout 120s ./...passes on darwin at 100%GOOS=linux go build ./...GOOS=freebsd go build ./...