Skip to content

fix(ast-engine): restore Language::from_path regression tests#107

Merged
bashandbone merged 3 commits intofix-rule-not-found-deserialize-9177764991747379115from
copilot/sub-pr-103-again
Mar 12, 2026
Merged

fix(ast-engine): restore Language::from_path regression tests#107
bashandbone merged 3 commits intofix-rule-not-found-deserialize-9177764991747379115from
copilot/sub-pr-103-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

Tests for Language::from_path panic behavior were removed in a prior cleanup commit (a79e527) and never restored, leaving the contract untested despite the implementation being correct.

Changes

  • crates/ast-engine/src/language.rs
    • Restored NoFromPath and TsxWithFromPath test structs covering the un-overridden (panics) and overridden (returns Option) cases
    • Restored default_from_path_panics and overridden_from_path_does_not_panic tests
    • Extracted shared test helpers (tsx_kind_to_id, tsx_field_to_id, tsx_ts_language) to reduce duplication across test impls
    • Tightened from_path doc comment to explicitly document the panic-on-unimplemented contract
#[test]
#[should_panic(expected = "Language::from_path is not implemented for type")]
fn default_from_path_panics() {
    let _ = NoFromPath::from_path("some/file.rs");
}

#[test]
fn overridden_from_path_does_not_panic() {
    assert!(TsxWithFromPath::from_path("component.tsx").is_some());
    assert!(TsxWithFromPath::from_path("main.rs").is_none());
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

… commits

Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix: Return explicit error when dependent rule is not found fix(ast-engine): restore Language::from_path regression tests Mar 10, 2026
@bashandbone bashandbone marked this pull request as ready for review March 11, 2026 04:14
Copilot AI review requested due to automatic review settings March 11, 2026 04:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores regression tests and clarifies the documented contract for Language::from_path in thread-ast-engine, ensuring the default “unimplemented” (panic) behavior and an overridden (non-panicking) implementation remain verified going forward.

Changes:

  • Tightened Language::from_path rustdoc to explicitly document that the default implementation panics.
  • Reintroduced tests covering both the default (panic) and overridden (returns Option) from_path behaviors.
  • Extracted small shared TSX/tree-sitter helpers to reduce duplication across test language impls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…o copilot/sub-pr-103-again

Signed-off-by: Adam Poulemanos <89049923+bashandbone@users.noreply.github.com>
@bashandbone bashandbone merged commit c148107 into fix-rule-not-found-deserialize-9177764991747379115 Mar 12, 2026
4 of 5 checks passed
@github-actions
Copy link
Contributor

👋 Hey @copilot,

Thanks for your contribution to thread! 🧵

You need to agree to the CLA first... 🖊️

Before we can accept your contribution, you need to agree to our Contributor License Agreement (CLA).

To agree to the CLA, please comment:

I read the contributors license agreement and I agree to it.

Those exact words are important1, so please don't change them. 😉

You can read the full CLA here: Contributor License Agreement


@copilot has signed the CLA.


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Footnotes

  1. Our bot needs those exact words to recognize that you agree to the CLA.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants