test: pin validate package public API contract#331
Merged
Conversation
The validate/ package is mache's public API surface for AST syntax validation — external consumers (CI scripts, pre-commit hooks, x-ray-style tools) import it instead of internal/writeback. It had zero direct test coverage; the find_smells untested_function rule has been flagging Content / ContentErrors / File / FileErrors / SupportedExtension since the package landed. Adds 9 focused contract tests: - Content: valid Go → nil; invalid Go → error; unknown extension pass-through (.xyz) → nil - ContentErrors: valid Go → empty slice; invalid Go → ≥1 entry (not asserting an exact count — tree-sitter recovery can split one logical error across multiple AST nodes) - File: valid Go → nil; invalid Go → error; nonexistent path → error (the read-error contract) - FileErrors: nonexistent path → nil (the diagnostic-flavor contract — read errors get swallowed because the structured- error type has no slot for them; callers that care use File()) - SupportedExtension: parameterized table over .go/.py/.ts/.tf (true) and .json/.md/no-ext (false-or-true with the registry as ground truth) — pin behavior to whatever lang.Registry contains rather than hard-coding language names Test-only — no behavior change. The underlying tree-sitter parsing is exercised by internal/writeback's existing suite; we don't re-test it here, just the re-export integrity.
find_smells (advisory)Scoped to files changed in this PR. Rules below run on the standalone (no-LLO) cross-ref tables; No structural smells in changed files. ✓ Rules: see |
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
The `validate/` package is mache's public API surface for AST syntax validation — external consumers (CI scripts, pre-commit hooks, x-ray-style tools) import it instead of `internal/writeback`. It had zero direct test coverage; the `find_smells --rule untested_function` scan has been flagging `Content` / `ContentErrors` / `File` / `FileErrors` / `SupportedExtension` since the package landed.
What's tested
Test-only — no behavior change. The underlying tree-sitter parsing is exercised by `internal/writeback`'s existing suite; we don't re-test it here, just the re-export integrity.
Test plan