Skip to content
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

Suffix location matching (Match test locations where test name and code structure differ) #1922

Merged
merged 4 commits into from
Sep 6, 2023

Conversation

farlee2121
Copy link
Contributor

@farlee2121 farlee2121 commented Sep 3, 2023

WHAT

More tests have locations

Improve matching of test explorer items to code locations.
Specifically, detect tests that are logically grouped by a testList, but not directly located under that same testList in the code.

Example

Before, these tests didn't have features based on code location
suffix-match-before

After
suffix-match-after

Mislocated tests don't pollute the explorer

Also prevent mislocated tests from showing in the test explorer.
The production version already prevented these on initial discovery, but they would still show up if the tests were renamed.
Now the incorrect test items shouldn't show at all.

For example, the Not Directly in Parent test should be nested under Composed test lists? and Composed test lists - 2 and is not a root level test.

Before
top-level-clutter

After
top-level-clutter-solved

HOW

If an explorer test can't be located in code, check if any of the code test ids are a suffix of the explorer test id.

Known Issues

  1. It still has issues locating tests under parents that can't be matched. For example, if the parent test name contains a separator character like + or ..
  2. Test located by this new approach do not get live updates, which could be confusing for users.

Alternative Approaches

I hoped to solve this within the FSAC testDetected endpoint.
This would have made it simple to support live explorer updates, and the code analysis results would have been more aligned with the logical structure of the tests.

The basic idea was to try resolving any referenced values within an expecto testList.
However, it doesn't look like this can be done with the untyped expression used for detecting tests.
Using the typed expressions seemed like a heavy update that could cause performance issues with how frequently this analysis is run.

I didn't measure the performance of using the typed expressions though. It may still be viable.
I also may have missed options for resolving symbols in the untyped AST.

Performance

I tested this on large numbers of tests in several repos, since it runs every time the code updates.
I didn't observe any slowdowns, but I'm 100% confident this can't cause performance issues.

Improves code location matching for some tests,
like where expecto testList groupings are composed into another testList.
Enables location-based features (like gutter status) for those tests.
I used suffix matching to locate tests in code where the code and
result structure don't match. This adds recursively matching the children
of those matched fragments so they also show locations
after initial location matchin, but we don't have to do more suffix
matching than neccessary.
@farlee2121 farlee2121 changed the title Suffix location matching Suffix location matching (Match test locations where test name and code structure differ) Sep 4, 2023
Copy link
Member

@TheAngryByrd TheAngryByrd left a comment

Choose a reason for hiding this comment

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

🎸 Thanks!!!

@TheAngryByrd TheAngryByrd merged commit c6bc775 into ionide:main Sep 6, 2023
1 of 2 checks passed
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.

2 participants