-
Notifications
You must be signed in to change notification settings - Fork 130
Propagate method async
-ness during test discovery
#258
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
af13696
Sync with main to pick up the Swift async symbol property definition.
briancroom abd0ecf
Extend `IndexStore.TestCaseClass` to include information about `async…
briancroom 31a8d9f
Model as a struct instead of enum for easier future expansion.
briancroom bfa0465
Take isAsync into account when comparing.
briancroom da1348f
Tweak argument name for clarity.
briancroom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,19 @@ import TSCBasic | |
public final class IndexStore { | ||
|
||
public struct TestCaseClass { | ||
public struct TestMethod: Hashable, Comparable { | ||
public let name: String | ||
public let isAsync: Bool | ||
|
||
public static func < (lhs: IndexStore.TestCaseClass.TestMethod, rhs: IndexStore.TestCaseClass.TestMethod) -> Bool { | ||
return (lhs.name, (lhs.isAsync ? 1 : 0)) < (rhs.name, (rhs.isAsync ? 1 : 0)) | ||
} | ||
} | ||
|
||
public var name: String | ||
public var module: String | ||
public var methods: [String] | ||
public var testMethods: [TestMethod] | ||
@available(*, deprecated, message: "use testMethods instead") public var methods: [String] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not too sure what the source compatibility requirement on this is. Let me know if this should be different! |
||
} | ||
|
||
fileprivate var impl: IndexStoreImpl { _impl as! IndexStoreImpl } | ||
|
@@ -90,15 +100,16 @@ private final class IndexStoreImpl { | |
let recordReader = try api.call{ fn.record_reader_create(store, record, &$0) } | ||
|
||
class TestCaseBuilder { | ||
var classToMethods: [String: Set<String>] = [:] | ||
var classToMethods: [String: Set<TestCaseClass.TestMethod>] = [:] | ||
|
||
func add(klass: String, method: String) { | ||
classToMethods[klass, default: []].insert(method) | ||
func add(className: String, method: TestCaseClass.TestMethod) { | ||
classToMethods[className, default: []].insert(method) | ||
} | ||
|
||
func build() -> [TestCaseClass] { | ||
return classToMethods.map { | ||
TestCaseClass(name: $0.key, module: "", methods: $0.value.sorted()) | ||
let testMethods = Array($0.value).sorted() | ||
return TestCaseClass(name: $0.key, module: "", testMethods: testMethods, methods: testMethods.map(\.name)) | ||
} | ||
} | ||
} | ||
|
@@ -112,9 +123,9 @@ private final class IndexStoreImpl { | |
|
||
// Get the symbol. | ||
let sym = fn.occurrence_get_symbol(occ) | ||
|
||
let symbolProperties = fn.symbol_get_properties(sym) | ||
// We only care about symbols that are marked unit tests and are instance methods. | ||
if fn.symbol_get_properties(sym) != UInt64(INDEXSTORE_SYMBOL_PROPERTY_UNITTEST.rawValue) { | ||
if symbolProperties & UInt64(INDEXSTORE_SYMBOL_PROPERTY_UNITTEST.rawValue) == 0 { | ||
return true | ||
} | ||
if fn.symbol_get_kind(sym) != INDEXSTORE_SYMBOL_KIND_INSTANCEMETHOD { | ||
|
@@ -140,8 +151,9 @@ private final class IndexStoreImpl { | |
} | ||
|
||
if !className.instance.isEmpty { | ||
let testMethod = fn.symbol_get_name(sym).str | ||
builder.instance.add(klass: className.instance, method: testMethod) | ||
let methodName = fn.symbol_get_name(sym).str | ||
let isAsync = symbolProperties & UInt64(INDEXSTORE_SYMBOL_PROPERTY_SWIFT_ASYNC.rawValue) != 0 | ||
builder.instance.add(className: className.instance, method: TestCaseClass.TestMethod(name: methodName, isAsync: isAsync)) | ||
} | ||
|
||
return true | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do you need full
Comparable
or justEquatable
?Equatable
should be fully synthesized.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.
Lower down, we
sort
these, so I think we do actually needComparable
.