Conversation
…util Adds spec_test.go files for three packages derived from their README.md specifications, covering public API contracts, type structures, and documented design decisions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
Specification Test Enforcement
This PR adds specification-driven tests for the following packages, all derived from their README.md documentation (not from implementation source code).
consoleenvutilstringutilTest Derivation
All tests are derived from README.md specifications. Each test cites the spec section it validates via Go doc comments. All test functions use the
TestSpec_prefix for easy identification.Coverage Highlights
console (
pkg/console/spec_test.go):TestSpec_PublicAPI_FormatFileSize— validates documented examples (0 B,1.5 KB,2.0 MB)TestSpec_Types_CompilerError— validates struct fields and documentedTypevalues ("error","warning","info")TestSpec_Types_TableConfig— validatesShowTotal,TotalRowfieldsTestSpec_Types_FormField— validates documentedTypevalues ("input","password","confirm","select")TestSpec_Types_TreeNode,TestSpec_Types_SelectOption— type structure complianceTestSpec_DesignDecision_RenderStruct_SkipTag— validatesconsole:"-"skips fieldsTestSpec_DesignDecision_RenderStruct_OmitEmptyTag— validatesomitemptyzero-value behaviorenvutil (
pkg/envutil/spec_test.go):GetIntFromEnvbehaviors: unset var, non-integer, below-min, above-max, in-range, inclusive min/max boundaries, nil logger safety, and the README usage examplestringutil (
pkg/stringutil/spec_test.go):stringutil.go,ansi.go,identifiers.go,sanitize.go,urls.go, andpat_validation.goSpec-Implementation Observations
NormalizeWhitespace: The README describes the function as "Collapses multiple consecutive whitespace characters (spaces, tabs, newlines) into a single space and trims leading/trailing whitespace." The actual implementation trims trailing whitespace from each line and ensures exactly one trailing newline. The code-level docstring accurately describes the behavior; the README top-level description is misleading. Spec tests cover the correct implementation behavior and note the discrepancy.Round-Robin State
console,envutil,stringutilagentdrain,constants,fileutil(indices 0, 2, 4 of eligible list)Auto-generated by Package Specification Enforcer workflow — Run §24394751965
Warning
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.