Repository navigation
feat: make TEST headers, test modes and trailing SELECT 1 optional - #978
Merged
Merged
Conversation
kvlonge
enabled auto-merge (squash)
October 6, 2026 13:59
… SQL tests A single-test file under tests/unit may omit its TEST header, a TEST block infers its mode from __macro_actual__, __udf_actual__ or __table_fn_actual__, and tests and scenarios may end after their last CTE. Explicit headers, modes and the ceremonial SELECT 1 keep working, and an explicit mode that contradicts the CTEs is still rejected. Compile, Rules and the formatter complete the omitted SELECT 1 internally so each body stays one statement.
Bodies that already end with a ceremonial SELECT 1 now return after a constant-time tail check, and bodies that omit it are scanned between quote, comment and parenthesis boundaries instead of character by character. The duplicate CTE-scan cache is removed. A megabyte-body guard bounds both paths.
kvlonge
force-pushed
the
feat/test-file-ceremony
branch
from
October 7, 2026 06:23
7295a24 to
2dea3bd
Compare
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.
Why
SQL test files needed ceremony the compiler could work out: a
TEST();header in every file, an explicitmodethat the CTE names already determine, and a trailingSELECT 1that is ignored.Changes
tests/unitmay omit itsTEST();header; files with several blocks still need one per block.TESTmode is inferred from a top-level__macro_actual__,__udf_actual__or__table_fn_actual__CTE; an explicit mode is never overridden, and a contradicting one is still an error.SELECT 1internally through one shared helper; the formatter never writes it back.SELECT 1check returns early for bodies that end inSELECT 1and only scans quote, comment and bracket positions otherwise, with a time-limited guard test.Verification
SELECT 1, formatter and Rules handling; a native extraction test for the optionalSELECT 1.fensu checkandmake check-ci.