Skip to content

sqlmesh test should treat model file paths as test selectors #6023

Description

@cmgoffena13

Summary

sqlmesh test already takes multiple positional args, but they are test YAML paths only. Passing a model file looks that path up in the test-file index, matches nothing, and exits 0. A pre-commit hook that passes staged model files would silently run no tests.

--select-model takes names, not paths. tests= and model_names= are unioned, so you cannot pass a model file and a test YAML together and get both.

Current behavior

  • sqlmesh test tests/test_a.yaml runs that file
  • sqlmesh test models/a.sql runs zero tests and succeeds
  • sqlmesh test tests/test_b.yaml --select-model a runs only tests that are in that file and target model a

Proposed CLI

sqlmesh test --local models/a.sql tests/test_b.yaml

Each positional arg is either:

  • a test YAML (or file.yaml::test_name) → those tests, or
  • a model file → unit tests for that model.

The two sets are a union. Staging models/a.sql and tests/test_b.yaml runs a’s tests and everything in b’s file.

Acceptance

  • Model .sql / .py paths select that model’s tests even if the YAML path did not change
  • Test YAML paths still work
  • Mixed args are unioned, not intersected
  • A path that is neither a known model file nor a known test file errors (no silent pass)
  • --select-model name selectors keep current behavior

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions