-
-
Notifications
You must be signed in to change notification settings - Fork 911
Fix XCTest override error on SPM/Swift4 #755
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
Generated by 🚫 danger |
if let superclass = class_getSuperclass(subclass), superclass === klass { | ||
block(subclass as! T.Type) // swiftlint:disable:this force_cast | ||
} | ||
guard let superclass = class_getSuperclass(subclass), superclass == klass else { continue } |
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'll need some help here. When using ===
, there is still a runtime crash (EXC_BAD_ACCESS). For now I did ==
and it doesn't crash, but we probably need to find a real problem 🤔
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.
Looks like using ==
is valid 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.
Sorry for the delay!
if let superclass = class_getSuperclass(subclass), superclass === klass { | ||
block(subclass as! T.Type) // swiftlint:disable:this force_cast | ||
} | ||
guard let superclass = class_getSuperclass(subclass), superclass == klass else { continue } |
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.
Looks like using ==
is valid here:
Sources/Quick/QuickSpec.swift
Outdated
@@ -37,7 +37,21 @@ open class QuickSpec: QuickSpecBase { | |||
/// SwiftPM on macOS does not have the mechanism (test cases are automatically | |||
/// discovered powered by Objective-C runtime), so we needed the alternative | |||
/// way. | |||
#if swift(>=4) | |||
override open static var defaultTestSuite: XCTestSuite { |
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.
This should be class
instead of static
.
https://developer.apple.com/documentation/xctest/xctestcase/1496289-defaulttestsuite#
Thanks for the review @ikesyo! I've changed |
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.
LGTM 👍 Thanks for the PR!
Hey guys!
Here with another SPM fix. This time for Swift 4 specifically. Seems like last time I was using Swift 3.2 for Quick, even though I've built it in with SPM/Swift4. This time, when switching to Swift 4.0 on Quick, I've seen an error due to
XCTest.defaultTestSuite()
change. Basically in Swift 3.*XCTest.defaultTestSuite()
is a method and in Swift 4.* it is a variable, making the build fail.I've fixed this one using
if swift(>=4)
, but I'm all ears if you have another fix in mind.Also, this could appear everywhere with Swift 4, not only SPM, but SPM was the only one I’ve tested.
Cheers!