test: push crypto + fsutil coverage to portable ceiling#1
Merged
Conversation
crypto: 92.0% -> 96.0%
fsutil: 58.1% -> 61.3%
total : 79.0% -> 82.7%
New test files (zz_coverage_test.go in each package) cover:
- LoadIdentity loose-permissions warn branch (chmod 0644 + capture
slog default handler output)
- LoadIdentity os.ReadFile non-NotExist error path (point at a
directory; EISDIR is not IsNotExist)
- LoadIdentity 0o600 negative case (no warning emitted)
- Sign/Verify empty + 1MiB messages
- Decode{Public,Private}Key on empty string (size check)
- Concurrent LoadIdentity readers and SaveIdentity overwrite
- AppendSync empty/nil/large payload, error-wrap message,
100-append ordering, open-against-directory
- AtomicWrite rename-onto-non-empty-dir (open+write+sync+close
all succeed, rename fails), empty/nil/large payload, mode 0600
preservation when overwriting 0o644, concurrent writers to
distinct paths
Also includes zz_save_test.go and zz_fsutil_test.go that were
sitting untracked in the worktree -- they were already counted in
the prior baseline and removing them would have regressed it.
Unreachable in portable tests (~17% of fsutil, ~4% of crypto):
- ed25519.GenerateKey error path: crypto/rand.Reader cannot fail
- json.MarshalIndent of {string, string} struct: cannot fail
- AppendSync / AtomicWrite f.Write / f.Sync / f.Close error
branches after a successful open: no portable trigger on a
healthy filesystem. macOS lacks /dev/full, opening a directory
or socket fails at the open call (not at write), FIFO O_NONBLOCK
isn't portable in Go's os package. Would require either a
package-level injection point (out of scope: no source edits) or
a synthetic ramdisk (overkill for a unit test).
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
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
Only new
*_test.gofiles; no production code touched.go test -race -count=1 -timeout 180s ./...passes.What's new
crypto/zz_coverage_test.gofsutil/zz_coverage_test.gozz_save_test.go+zz_fsutil_test.gothat were sitting untracked in the worktree (already counted in the prior baseline; tracking them prevents regression)Honest ceiling
The remaining ~17% of fsutil and ~4% of crypto are defensive error-handling branches with no portable trigger:
ed25519.GenerateKey(rand.Reader)—crypto/randdoes not fail on a sane systemjson.MarshalIndentof{string, string}cannot fail/dev/full(Linux-only) or a full filesystem; not portableReaching 100% would need either a source-level injection seam (out of scope: rules forbid editing non-test files) or a ramdisk fixture.
Test plan
go test -race -count=1 -timeout 180s ./...passes (1.2s crypto, 1.8s fsutil)go tool cover -funcconfirms LoadIdentity 90.5% -> 100.0%, total 79.0% -> 82.7%