-
Notifications
You must be signed in to change notification settings - Fork 304
Implement a syntactic workspace-wide test index #1175
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
788a750
to
256a524
Compare
256a524
to
4bcfd11
Compare
4bcfd11
to
c7f6e5f
Compare
@swift-ci Please test |
Is there anything specific you'd like us to look at here? |
I don’t think there’s anything in particular. Mostly wanted to make you aware of it in case anything sticks out to you. |
@swift-ci Please test Windows |
c7f6e5f
to
99824cf
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
case .changed: | ||
rescanFiles([fileEvent.uri]) | ||
case .deleted: | ||
removeFilesFromIndex([fileEvent.uri]) |
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.
Couldn't this end up cancelling a whole batch that contains this file?
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.
Oh, good catch. I didn’t think about that when changing to batch indexing.
Modified it to explicitly keep track of removed files instead of relying on task cancellation.
// - For all files that have been not been modified since they were last indexed in the semantic index, include | ||
// XCTests from the semantic index. |
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.
I just checked and the index does indeed contain a relationship from the macro reference to the attached declaration. So it seems we could pretty easily add semantic index results for swift-testing by eg. finding references to Suite
and Test
, then grabbing their contained by relationship.
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.
Oh, nice. Let’s do that in a follow-up PR. rdar://126721322 is tracking that.
// - All files that have in-memory modifications are syntactically scanned for tests here. | ||
var outOfDateChecker = IndexOutOfDateChecker(documentManager: documentManager) | ||
|
||
let filesWithInMemoryState = documentManager.documents.compactMap { (uri, document) -> DocumentURI? in |
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.
Could expose hasFileInMemoryModifications
from IndexOutOfDateChecker
and then use it instead of the check here?
Writing that out also made me notice that hasFileInMemoryModifications
reads a bit weirdly, maybe fileHasInMemoryModifications
? Or just hasInMemoryModifications
since it takes a URL parameter anyway.
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.
Good idea. That way we can re-use the cache of the check as well.
This workspace-wide syntactic test index is used for two purposes: - It is used for XCTests instead of the semantic index for files that have on-disk or in-memory modifications to files - It is uses for swift-testing tests, which are only discovered syntactically. rdar://119191037
…ning files in batches
99824cf
to
b3c519b
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
let removedFiles = Set(self.indexedTests.keys).subtracting(testFiles) | ||
removeFilesFromIndex(removedFiles) | ||
|
||
rescanFiles(testFiles) |
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.
Should rescanning reset removed files? If a file was re-added (say switching branches), seems like we'd forever ignore it right now?
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.
Oh, very good catch. Fixed it and added a test for it.
3b211b2
to
420d2bf
Compare
…ndex again after it got deleted once
420d2bf
to
ae215f9
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
1 similar comment
@swift-ci Please test Windows |
abf31a8
to
ae215f9
Compare
This workspace-wide syntactic test index is used for two purposes:
rdar://119191037