Skip to content

fix: require a TEST() header in SQL test files again - #1000

Merged
kvlonge merged 1 commit into
mainfrom
fix/require-test-header
Oct 7, 2026
Merged

kvlonge merged 1 commit into
mainfrom
fix/require-test-header

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Why

#978 made three parts of a SQL test file optional. The optional TEST() header is being reverted: every test file should again start with a TEST() header so test files are unambiguous to read, lint and format. Mode inference and the optional trailing SELECT 1 from #978 stay.

Changes

  • Discovery: a test file without a TEST() header fails with D003 again ("must start with a TEST() header as the first non-whitespace content"). The header-less parse path is removed; mode inference from __macro_actual__, __udf_actual__ and __table_fn_actual__ is kept for headers without mode.
  • Rules and formatter: files under tests/unit are no longer treated as tests without a header (LintFileRole.in_sql_test_directory removed). Omitted SELECT 1 handling for TEST and SCENARIO bodies is unchanged.
  • Tests: header-less cases now expect D003; mode-inference, formatter and E2E cases use TEST(); and still omit SELECT 1; a new E2E case checks a header-less test file is rejected with D003.
  • Docs, README, skill and waffle-shop example tests: TEST(); restored. Docs state that every test file starts with a TEST() header (fields optional; an unnamed test is named after its file), the mode is inferred, and the trailing SELECT 1 is optional. Skill references regenerated.

Verification

  • uv run pytest on discovery test_sql_tests.py, lint test_run_lint.py, compile helper test_tests.py and test_scenarios.py, and E2E test_optional_test_ceremony.py (182 passed)
  • ruff check, ruff format --check, uv run fensu check
  • make check-ci

A SQL test file must again start with a TEST() header; a file without one
fails discovery with D003. Mode inference and the optional trailing
SELECT 1 are unchanged. Docs, the skill and the example tests show the
header again.
@kvlonge
kvlonge enabled auto-merge (squash) October 7, 2026 07:37
@kvlonge
kvlonge merged commit 9742975 into main Oct 7, 2026
32 checks passed
@kvlonge
kvlonge deleted the fix/require-test-header branch October 7, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant