-
Notifications
You must be signed in to change notification settings - Fork 737
Port baseline diagnostics tests #2097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ports baseline diagnostics tests from Strada fourslash to Corsa fourslash. To enable reusing compiler test baseline functions for LSP diagnostics, it refactors diagnostic formatting code to work with a common interface rather than concrete ast.Diagnostic types.
Key changes:
- Introduces
DiagnosticandFileLikeinterfaces to abstract diagnostic formatting - Wraps
ast.Diagnosticin an adapter type to implement the new interface - Implements fourslash LSP diagnostic baseline testing via
VerifyBaselineNonSuggestionDiagnostics
Reviewed Changes
Copilot reviewed 62 out of 62 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
internal/diagnosticwriter/diagnosticwriter.go |
Adds Diagnostic and FileLike interfaces; wraps ast.Diagnostic to implement these interfaces; updates formatting functions to accept interface types |
internal/fourslash/fourslash.go |
Implements Diagnostic and DiagnosticFile types for LSP diagnostics; adds VerifyBaselineNonSuggestionDiagnostics method |
internal/fourslash/baselineutil.go |
Adds "Syntax and Semantic Diagnostics" to baseline extension mapping |
internal/testutil/tsbaseline/error_baseline.go |
Makes error baseline functions generic over the Diagnostic interface |
internal/testutil/tsbaseline/js_emit_baseline.go |
Updates calls to use wrapped diagnostics |
internal/scanner/scanner.go |
Changes GetECMAPositionOfLineAndCharacter to accept ast.SourceFileLike interface |
internal/ls/diagnostics.go |
Updates to use new WriteFlattenedASTDiagnosticMessage function |
internal/execute/tsc/diagnostics.go |
Wraps ast.Diagnostic instances before passing to formatting functions |
| Multiple test/baseline files | Adds new fourslash tests and baseline files for JavaScript syntactic diagnostics |
internal/fourslash/_scripts/convertFourslash.mts |
Adds support for converting baseline diagnostic test commands |
internal/tsoptions/*_test.go |
Updates to use FromASTDiagnostics wrapper |
internal/testutil/parsetestutil/parsetestutil.go |
Updates to use FromASTDiagnostics wrapper |
Follow up to #2079.
In Strada fourslash, we obtained compiler diagnostics directly and reused the compiler test harness functions for producing a baseline file for diagnostics. In Corsa fourslash, we get LSP diagnostics instead of
ast.Diagnostic, and so to reuse the existing diagnostic baseline functions I had to refactor them to accept an interface with common methods for both the LSP and internal diagnostic types.