Add tests for PHP runnable queries#129
Open
roxblnfk wants to merge 1 commit into
Open
Conversation
Exercise languages/php/runnables.scm and tasks.json the same way zed-extensions/java does: run the shipped queries with the native tree-sitter engine over the pinned grammar (5b5627f == tree-sitter-php 0.24.2), under Zed's 64-match limit. The org-wide extension_tests workflow already runs `cargo nextest` on pull requests, so these are picked up automatically — no extra CI needed. - tests/support: run_query helper, mirroring the match limit that QueryCursorHandle::new() applies in crates/language/src/syntax_map.rs - tests/runnables.rs: PHPUnit (naming convention, @test, #[Test], abstract) and Pest - tests/tasks.rs: every runnable tag has a task; tags map to the right runner Two #[ignore]d tests document cases main over-tags as PHPUnit (a *Test class with no inheritance, and a bare #[Test] in such a class). They assert the intended behaviour, so they fail today and are skipped in CI; run them with `cargo test -- --ignored`.
85f0ad4 to
1b7fca3
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.
What
Adds a
cargo testsuite that exerciseslanguages/php/runnables.scmandlanguages/php/tasks.json, so the runnable/gutter queries have coverage and regressions get caught before release. There are no tests for the runnable queries today, so it's easy to break gutter detection (or the tag ↔ task wiring) without noticing until it ships.How
Mirrors the approach already used by
zed-extensions/java: runs the shipped.scmwith the nativetree-sitterengine over the pinned grammar, as dev-dependencies. The grammar commit inextension.toml(5b5627f) is thetree-sitter-php0.24.2 release, so the crate parses identically to the editor.One deliberate detail: the helper calls
cursor.set_match_limit(64)to mirrorQueryCursorHandle::new()incrates/language/src/syntax_map.rs, so tests see the same match-limit behaviour Zed applies at runtime.tests/support/mod.rs—run_queryhelper (parse → query → collect@runcaptures with their tag and row).tests/runnables.rs— PHPUnit (naming convention,@test,#[Test], abstract) and Pest.tests/tasks.rs— every(#set! tag …)in the query has a matching task intasks.json, and tags map to the expected runner.No workflow is added: the org-wide
extension_testsworkflow already runscargo nexteston pull requests, so these tests are picked up automatically.Documented gaps (
#[ignore]d)Two
#[ignore]d tests pin behaviour the current query gets wrong — it tags things as PHPUnit that most likely aren't:*Testclass with noextends(PHPUnit test cases always inherit fromTestCase; a class with no base class is far more likely a non-PHPUnit test);#[Test]method in such a class (#[Test]is ambiguous betweenPHPUnit\Framework\Attributes\Testand other frameworks).They assert the intended behaviour, so they fail today and are skipped in CI. Run them with
cargo test -- --ignoredto see the gaps.While writing these I also noticed the
(#not-any-eq? @_modifier "abstract")guard on the PHPUnit patterns never fires with the pinned grammar — abstract*Testclasses are still tagged. That's pinned as-is byabstract_test_class_is_tagged(the gutter is harmless — PHPUnit just won't run an abstract class), but worth flagging.Running