-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Adding baseline methods for verification of findAllRefs, GoTo*, Occurrences, highlights and rename deprecating the corresponding verification methods from fourslash tests #52576
Conversation
e90b033
to
e64855c
Compare
tests/baselines/reference/findAllRefsClassWithStaticThisAccess.baseline.jsonc
Outdated
Show resolved
Hide resolved
tests/baselines/reference/goToDefinitionShadowVariable.baseline.jsonc
Outdated
Show resolved
Hide resolved
The baselines before were seemingly entirely jsonc and now they are some other format; can we just keep it as jsonc so the file extension and highlighting are consistent? |
tests/baselines/reference/documentHighlightAtInheritedProperties3.baseline.jsonc
Show resolved
Hide resolved
Done now |
So to be clear, this PR is actually mainly removing the ad-hoc verification methods and turning all of the fourslash tests into baselines, correct? (If so, we should retitle the PR to say that just for the git history.) |
I will list, methods that we are retiring and adding baselines for. (anyThing that has contextSpan (findAllRefs, goTo*, rename, occurences and highlights) |
// containerName: "" | ||
// kind: "alias" | ||
// name: "(alias) module \"jquery\"\nimport x" | ||
// displayParts: [ |
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.
One thing I'm grappling with here is that it seems like all of this info here is a duplicate of the information that's already in these baslines beforehand; is it possible to only add the new info instead of duplicating the display parts and such instead? It seems like that's a lot of the source of the huge amount of added lines.
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.
It’s Some of the info that tests were checking as part of range additional data .. now I feel like it’s one blob if it’s json and so hard to decipher so I added it here to make easier to read .. contemplated removing json part all together but we would miss additional data properties when added so I let it be .. not sure what’s better approach here
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.
Eg there are some tests that check display parts , most check write acces in references etc
My main objection is the sheer quantity of additional text this brings. I find it really hard to look through the new format and understand what’s being presented. If the primary goal is just to show context spans, we could try an underlining scheme instead of using
to
But repeating the whole file text (or even slices of it) seems pretty undesirable. |
This becomes pretty tricky with overlapping spans and context only for partial range. Eg.
We definitely need readable context as its completely lost. I can change it do the suggested change in contextSpan higlight to remove one additional text slice. Also was thinking of removing the JSON dump since that is not readable at all. Instead asserting that the result doesnt contain anything other than properties part of readable baseline. |
Another option would be to report the context span in an abbreviated way, noting the line range and first and last characters:
|
This comment was marked as outdated.
This comment was marked as outdated.
Here is compact way the baseline is working now: The additions are that it inlines contextSpan with Find all refs is special because it returns definitions and references so definition index is coded as part of reference and definition and they are not mixed because it just gets so confusing. The Definitions list is printed separately just like references grouped by file names so its not writing file contents again and again if two definition fall in same file. All the baselines have same format so hopefullu that should make it consistent and easier to understand between different types of commands.
Before this PR, rename baselines would rewrite file text with content between textSpan start and end with
|
This isn’t human-readable, so I don’t really think making it a baseline gains anything over the (also non-human-readable) old fourslash tests. If I generated one of these baselines when working on a new feature, I would have no idea if it was correct and would probably just test my changes in VS Code and then assume the baselines are right without really reading them. The text-based baselines tend to be incomplete, which is why they’re usually paired with JSON. The text should provide you with a high-level correctness check at a glance, while the JSON protects against regressions that wouldn’t manifest in the text. If the text can be cleverly improved to show more, I think that’s great, but if it becomes less readable by duplicating information in the JSON, that’s purely a loss. If there are text baselines without JSON included, it seems reasonable to add it. We can also manipulate the JSON to make it a bit more readable too, like substituting text spans with actual string slices and concatenating |
The part that’s not relatable with json is that it’s so hard to figure out what span it’s talking about .. not all tests are easy to check with vscode esp dealing with big changes .. the part that’s not readable is because of huge display parts rather than anything else .. eg look at document highlights baselines they are much more readable now in my opinion .. find all references is a tricky business and there were tests that tested display parts that were not better than current .. having said that we can experiment with json substitution for the display parts but I would like to keep context span thing as is .. that was well tested and covered when added but lost when we converted these tests to baselines making it not comprehensible at all .. |
...s/baselines/reference/declarationMapsGoToDefinitionSameNameDifferentDirectory.baseline.jsonc
Show resolved
Hide resolved
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.
Is there any hope of splitting this PR up? It seems that every command’s baseline is subtly different, and I’ve only made it into the ones that start with d
, but GitHub keeps going non-responsive and crashing as I try to review.
tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping3.baseline.jsonc
Outdated
Show resolved
Hide resolved
tests/baselines/reference/ambientShorthandFindAllRefs.baseline.jsonc
Outdated
Show resolved
Hide resolved
tests/baselines/reference/ambientShorthandFindAllRefs.baseline.jsonc
Outdated
Show resolved
Hide resolved
tests/baselines/reference/cancellationWhenfindingAllRefsOnDefinition.baseline.jsonc
Outdated
Show resolved
Hide resolved
tests/baselines/reference/definitionNameOnEnumMember.baseline.jsonc
Outdated
Show resolved
Hide resolved
tests/baselines/reference/documentHighlightAtInheritedProperties1.baseline.jsonc
Outdated
Show resolved
Hide resolved
5e848bf
to
100712e
Compare
@andrewbranch I had to force push since I used my WIP branch instead and ran tests on each commit. Hopefully this helps. It took a while to run the tests on all these commits. |
@typescript-bot cherry-pick this to release 5.0 because another cherry-picked PR depends on it |
Heya @andrewbranch, I've started to run the task to cherry-pick this into |
Hey @andrewbranch, I couldn't open a PR with the cherry-pick. (You can check the log here). You may need to squash and pick this PR into release manually. |
This baselines all the tests that have context span, working on top of existing baseline infra for findAllRefs, just making it easier to reason about context spans and results.
Consolidated all the baseline tests so they can be worked together to create single baseline..
Most of this was find and replace with minor manual consolidation.
With this change for testing purposes use:
Deprecated:
Deprecated:
Deprecated:
Deprecated:
Deprecated:
Deprecated:
Deprecated:
Deprecated:
Deprecated: