Skip to content

Enhance syntactic test discovery with information from the semantic index #1195

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

ahoppen
Copy link
Member

@ahoppen ahoppen commented Apr 20, 2024

When the semantic index is out-of-date, we currently purely rely on the syntactic index to discover tests and completely ignore data from the semantic index. This may lead to confusing behavior. For example if you have

class MightInheritFromXCTestCaseOrNot {}

class MyClass: MightInheritFromXCTestCaseOrNot {
  func testStuff() {}
}

Then we don’t return any tests when the semantic index is up-to-date. But once the file is modified (either on disk or in-memory), we purely rely on the syntactic index, which reports testStuff as a test method. After a build / background indexing finishes, the test method disappears again.

We can mitigate this problem as follows: If we have stale semantic index data for the test file, for every test method found by the syntactic index, check if we have an entry for this method in the semantic index. If we do, but that entry is not marked as a test class/method, we know that the semantic index knows about this method but decided that it’s not a test method for some reason. So we should ignore it.

rdar://126492948

@ahoppen ahoppen requested a review from benlangmuir as a code owner April 20, 2024 23:11
@ahoppen ahoppen changed the title Enhance syntactic test discovery with information from the semantic index Enhance syntactic test discovery with information from the semantic index 🚥#1194 Apr 21, 2024
@ahoppen ahoppen force-pushed the ahoppen/filter-syntactic-tests-based-on-outdated-index branch from d1cf231 to 08d9537 Compare April 24, 2024 15:52
@ahoppen ahoppen force-pushed the ahoppen/filter-syntactic-tests-based-on-outdated-index branch from 08d9537 to 2ff2fb0 Compare May 2, 2024 14:58
@ahoppen ahoppen changed the title Enhance syntactic test discovery with information from the semantic index 🚥#1194 Enhance syntactic test discovery with information from the semantic index May 2, 2024
@ahoppen
Copy link
Member Author

ahoppen commented May 2, 2024

@swift-ci Please test

…ndex

When the semantic index is out-of-date, we currently purely rely on the syntactic index to discover tests and completely ignore data from the semantic index. This may lead to confusing behavior. For example if you have

```
class MightInheritFromXCTestCaseOrNot {}

class MyClass: MightInheritFromXCTestCaseOrNot {
  func testStuff() {}
}
```

Then we don’t return any tests when the semantic index is up-to-date. But once the file is modified (either on disk or in-memory), we purely rely on the syntactic index, which reports `testStuff` as a test method. After a build / background indexing finishes, the test method disappears again.

We can mitigate this problem as follows: If we have stale semantic index data for the test file, for every test method found by the syntactic index, check if we have an entry for this method in the semantic index. If we do, but that entry is not marked as a test class/method, we know that the semantic index knows about this method but decided that it’s not a test method for some reason. So we should ignore it.

rdar://126492948
@ahoppen ahoppen force-pushed the ahoppen/filter-syntactic-tests-based-on-outdated-index branch from 2ff2fb0 to 0685ee7 Compare May 3, 2024 04:10
@ahoppen
Copy link
Member Author

ahoppen commented May 3, 2024

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented May 3, 2024

@swift-ci Please test Windows

@ahoppen ahoppen merged commit 3fb3a99 into swiftlang:main May 3, 2024
3 checks passed
@ahoppen ahoppen deleted the ahoppen/filter-syntactic-tests-based-on-outdated-index branch May 3, 2024 14:21
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