Repository navigation
test: give pkg/archive tests of its own and sdks/c a floor (#360, #361) - #372
Merged
Merged
Conversation
pkg/archive had no tests. Its 48.6% was measured through internal/archive under -coverpkg, which is a number about a consumer, and the code no consumer touches was invisible in it. metadata_test.go takes the package to 100.0%. #360 offered testing directly or folding into the consumer, and the premise had moved since it was filed: internal/archive now builds an index and reads it back, so the genuinely unreached code was ListDirectory and its two helpers, which no consumer calls at all. Only the first option covers them. Reaching 100% found a branch that is unreachable from the only producer here, and it is covered with that written down rather than deleted. ListDirectory's second disjunct needs an entry whose Path ends in '/', and BuildIndexFromBytes runs every tar name through path.Clean, which strips exactly that. ArchiveIndex is exported, so an outside caller may build an index using tar's own convention where a directory keeps its slash; the test says which convention each half serves, so removing the branch stays a decision about the exported surface. Two behaviors are pinned rather than assumed: TotalFiles counts directories and TotalSize does not, and a repeated path replaces the entry without rolling either counter back. For #361 the coverage job now states CGO_ENABLED: 1. It set nothing, so it took the runner default, and sdks/c is the one package whose coverage depends on it — a floor read off an inherited value is a claim about a configuration no workflow states. On rather than off: main.go carries `import "C"`, so with cgo off the package does not fall back to a tag-excluded variant, it fails to compile, because main_test.go references codeFromErr, fillCStr, maxPutLength and more. CGO_ENABLED=0 would turn a coverage question into a compile failure in the job whose output is a coverage number. The sdks/c floor is 12, not the 11 this file claimed while arguing the package was unfloorable. That number was stale when written: #355 added the tests taking it to 12.1%, and the note was authored on a branch cut before #355 merged, so it recorded a measurement its own commit had invalidated. Verified rather than reasoned — no commit has touched sdks/c since, and it measures 11.0% at f6f2ae5^ and 12.1% at HEAD. The floor is a ratchet on the Go-testable half; the rest is //export entry points taking C pointers, which the C suite exercises and go test cannot. Also: the gate stops measuring Go files vendored inside npm dependencies. Two copies of flatted ship a Go port, so after npm install `go list ./...` reports two more packages and the gate named them unfloored at 0.0%. Gitignored, absent from a fresh checkout, never installed by the coverage job — so visible only on a developer machine, and the fix is neither a floor nor a test because the code is not ours. TestUnfloorablePackagesAreExplained used to filter them out of its own synthetic profile, which passed the test and left the noise in the output a person reads; that filter is gone, so the profile names them and the gate's exclusion is what the assertion tests. Verified by mutation, both new gates: dropping the node_modules skip fails TestUnfloorablePackagesAreExplained naming both packages, and a floor of 13 fails sdks/c at 12.1%.
This was referenced Aug 6, 2026
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.
Closes #360. Closes #361.
pkg/archive— 0 own-tests → 100.0%, with a floor (#360)The package had no tests of its own. Its 48.6% was measured through
internal/archiveunder-coverpkg, which is a number about a consumer rather than about this package — and the code no consumer touches was invisible inside it.#360 offered two options, and the premise had moved since it was filed:
internal/archivenow builds an index and reads it back, so the genuinely unreached code wasListDirectoryand its two helpers, which no consumer calls at all. Testing directly is the only option that covers them.pkg/archive/metadata_test.gotakes it to 100.0% in three measured steps (94.6% → 97.3% → 100.0%), and the floor is set there.The branch that is unreachable from the only producer
Reaching 100% surfaced this, and it is covered with the reason written down rather than deleted:
The right-hand side needs an entry whose own
Pathends in/.internal/archive.BuildIndexFromBytesruns every tar name throughpath.Clean, which strips exactly that — so no index built in this repository can reach it, and neither cancontainsSlashExceptLast, which only that branch calls.Covered rather than removed because
ArchiveIndexis exported, and a caller outside this repository may build an index by hand using tar's own convention, where a directory name does keep its slash. The test states which convention each half serves, so a future decision to drop the branch is a decision about the exported surface instead of a coverage cleanup.Two behaviors are now pinned rather than assumed:
TotalFilescounts directories;TotalSizedoes not. A directory's tar-reported size is not content, and that asymmetry is the kind of thing that gets "cleaned up" into one rule.TotalFiles=2,TotalSize=30for one replaced path. That is the current contract; the test exists so a change to it is visible.sdks/c— an explicit cgo posture, then a floor (#361)Step 1. The coverage job set no
CGO_ENABLED, so it took the runner's default.sdks/cis the one package whose coverage depends on that, so its number came from an inherited value no workflow stated. The job now setsCGO_ENABLED: 1.The direction matters.
sdks/c/main.gocarriesimport "C", so with cgo off the package does not fall back to a build-tag-excluded variant — it fails to compile:CGO_ENABLED=0here would turn a coverage question into a compile failure in the job whose output is a coverage number. The cross-build matrix and the release build set0deliberately, because there the point is a static binary; here the point is measuring every package.Step 2 — the floor is 12, and the stale number is the finding.
.coverage-floorsclaimed 11.0% while arguing the package was unfloorable, and that number was already stale when it was written: #355 added the tests that took it from 11.0% to 12.1%, and the note was authored on a branch cut before #355 merged, so it recorded a measurement its own commit had invalidated.Verified rather than reasoned:
f6f2ae5^(before #355)HEADsdks/csince the note12.1% is stable across three runs and identical under
set,countandatomic. The floor is a ratchet on the Go-testable half —codeFromErr,fillCStr,bytesToCacheString, the length and limit error builders — not a coverage target for the SDK. The rest is//exportcgo entry points whose parameters are C pointers, which the C suite undersdks/c/testsexercises by linking the shared library andgo testcannot reach.The gate stops measuring npm-vendored Go
Two copies of the
flattednpm package ship a Go port under their package directory, so once anything has runnpm installindocs-platformorsdks/javascript,go list ./...reports two more packages and the gate named them as unfloored at 0.0%. They are gitignored, absent from a fresh checkout, and never installed by the coverage job — so they appeared only on a developer machine, which is the worst place for a gate to grow noise, and neither a floor nor a test is the fix, because the code is not this repository's.TestUnfloorablePackagesAreExplainedpreviously filtered them out of its own synthetic profile. That passed the test and left the noise in the output a person actually reads — the wrong half to fix. The filter is gone: the synthetic profile now names those packages, and the assertion that the gate does not report them is what tests the exclusion.Verification
Both new gates verified by mutation, per the standing rule:
node_modulesskip fromcoverage-gate.sh→TestUnfloorablePackagesAreExplainedfails, naming bothflattedpackages with the "add a# no-floor:entry" message.sdks/cfloor to 13 →FAIL sdks/c — 12.1%, below its floor of 13%.Full-repo gate against a fresh
CGO_ENABLED=1profile:Four unfloored packages, down from six — and all four are the "no tests, deliberately; every statement runs under a floored consumer" case, where a floor would have to be 0 to pass and 0 is not a gate.
.coverage-floors' header count is updated from five to four, its 80%-target sentence recounted from the file (23 of 35), and theno-floor: sdks/cblock replaced with a per-floor note.