Skip to content

Port go-to-definition baseline tests #1437

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

Merged
merged 20 commits into from
Jul 24, 2025
Merged

Conversation

DanielRosenwasser
Copy link
Member

A few noteworthy things:

  • goToDefinition and getDefinitionAtPosition are slightly distinct in Strada, but we have no such distinction around "bound spans" in LSP that I'm aware of. I'm not sure if this is something "missing" in LSP that we should revisit.
  • Baselines for find-all-references would previously drop files that contained the originating request. Now they are preserved.
  • I noticed that baselines for fourslash are slightly different due to file ordering. Might need to look into that.

Copy link
Contributor

@Copilot 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

This pull request ports go-to-definition baseline tests from TypeScript's Strada testing framework to the Go language implementation. The primary purpose is to ensure that go-to-definition functionality works consistently with TypeScript by providing comprehensive test coverage for this critical language service feature.

Key changes include:

  • Addition of 173 new generated test files for go-to-definition functionality covering various TypeScript language features
  • Addition of 54 new findAllRef baseline test files with updated content that preserves files containing the originating request
  • Implementation of VerifyBaselineGoToDefinition test method in the fourslash testing framework

Reviewed Changes

Copilot reviewed 299 out of 492 changed files in this pull request and generated no comments.

File Description
testdata/baselines/reference/fourslash/findAllRef/*.baseline.jsonc Updated baseline files that now include file headers and preserve originating request files
internal/fourslash/tests/gen/*_test.go Generated test files covering comprehensive go-to-definition scenarios including JSX, TypeScript features, and edge cases


f.baseline.addResult("goToDefinition", f.getBaselineForLocationsWithFileContents(resultAsLocations, baselineFourslashLocationsOptions{
marker: markerOrRange.GetMarker(),
markerName: "/*GO TO DEFINITION*/",
Copy link
Member Author

Choose a reason for hiding this comment

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

This marker is different from both of the ones we have in Strada. Open to adopting one over the other.

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

The code seems fine but I don't know how reasonable it will be to actually review all half a million lines of baselines... Would be interesting to try and diff them or something

@DanielRosenwasser
Copy link
Member Author

A few things that I want to look into tomorrow:

  1. Some of these tests are incorrectly generated because they can't support ...test.markerNames()
  2. The test suite isn't resilient to a nil result right now. The same might be true of find-all-references.
  3. I think the old code specifically adds the triggering file at the end if it was never encountered.

I think that causes more tests to be considered failing than is really necessary.

@gabritto
Copy link
Member

A few things that I want to look into tomorrow:

  1. Some of these tests are incorrectly generated because they can't support ...test.markerNames()
  2. The test suite isn't resilient to a nil result right now. The same might be true of find-all-references.
  3. I think the old code specifically adds the triggering file at the end if it was never encountered.

I think that causes more tests to be considered failing than is really necessary.

  1. I think we shouldn't have the script convert tests that we know cannot yet be converted properly. If tests that have ...test.markerNames() won't work for now, we should just skip porting them, otherwise it's hard to keep track of what has been successfully ported and what hasn't.
  2. This is just me being curious, but will we be able to compare baselines between Strada and Corsa in any way, or are the spans always too different?

@DanielRosenwasser
Copy link
Member Author

The code seems fine but I don't know how reasonable it will be to actually review all half a million lines of baselines...

Yeah, for now, I would say don't really. Just eyeball the accepted baselines at each commit. Knowing what is currently failing will be a little bit helpful though.

This is just me being curious, but will we be able to compare baselines between Strada and Corsa in any way, or are the spans always too different?

I don't know, but I would still like to see if diffing could help later.

I think we shouldn't have the script convert tests that we know cannot yet be converted properly.

Probably something to try later. Right now they're incorrectly converted and skipped.

@DanielRosenwasser
Copy link
Member Author

The same might be true of find-all-references.

Apparently not because it just comes back as a nil slice.

Copy link
Member

@iisaduan iisaduan left a comment

Choose a reason for hiding this comment

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

Looks good, and good catch on the trigger locations not being printed if references to the location aren't returned!

@iisaduan
Copy link
Member

Some comments on things mentioned above:

...test.markerNames()

can be translated to

...core.MapNonNil(f.Markers(), func(m *fourslash.Marker) *string {return m.Name})

which will return a slice of all markers in test f with a name (skipping unnamed object and range markers, just like in strada)

  1. This is just me being curious, but will we be able to compare baselines between Strada and Corsa in any way, or are the spans always too different?

I thought about this a lot and tried some different methods of comparing when I was writing the FAR baseline, but besides the different data being returned, other things like whitespace, lines skipped, file and per-marker-result ordering in the baseline weren't the same, so it made an overall string comparison hard.
I have some more ideas that I think would work, but in the interest of time for the original PR, I wasn't able to fully try them (and it would probably require something slightly different for every fourslash baseline function)

  1. The test suite isn't resilient to a nil result right now. The same might be true of find-all-references.

It would be nice to have better error handling in the LS (and fourslash) in general. The error handling in baselineFAR was pretty much added on as I ran into them, and doesn't really do anything to report why the error happened

@DanielRosenwasser DanielRosenwasser added this pull request to the merge queue Jul 24, 2025
Merged via the queue into main with commit f0484dd Jul 24, 2025
22 checks passed
@DanielRosenwasser DanielRosenwasser deleted the supportGoToDefBaselines branch July 24, 2025 00:48
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.

4 participants