Skip to content

tests: tighten coverage by retiring unreachable defensive code#2

Merged
TeoSlayer merged 1 commit into
mainfrom
coverage-housekeeping
May 28, 2026
Merged

tests: tighten coverage by retiring unreachable defensive code#2
TeoSlayer merged 1 commit into
mainfrom
coverage-housekeeping

Conversation

@TeoSlayer
Copy link
Copy Markdown
Contributor

Summary

Split the runtime.GOOS switch in addLoopbackAlias / removeLoopbackAlias across three per-OS files using build tags:

  • loopback_linux.goip addr add/del
  • loopback_darwin.goifconfig lo0 alias/-alias
  • loopback_other.go — logs unsupported 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

  • Before (darwin): 96.8%
  • After (darwin): 100.0%

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 ./...

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
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@TeoSlayer TeoSlayer merged commit 8c2ca81 into main May 28, 2026
2 checks passed
@TeoSlayer TeoSlayer deleted the coverage-housekeeping branch May 28, 2026 02:22
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.

2 participants