8000 Fix XCTest override error on SPM/Swift4 by sunshinejr · Pull Request #755 · Quick/Quick · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 3 commits into from
Nov 25, 2017
Merged

Fix XCTest override error on SPM/Swift4 #755

merged 3 commits into from
Nov 25, 2017

Conversation

sunshinejr
Copy link
Contributor
@sunshinejr sunshinejr commented Oct 11, 2017

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!

@QuickBot
Copy link
QuickBot commented Oct 11, 2017
1 Warning
⚠️ Need to add an unit test if you’re modifying swift source

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 }
Copy link
Contributor Author
@sunshinejr sunshinejr Oct 12, 2017

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 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member
@ikesyo ikesyo left a 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 }
Copy link
Member

Choose a reason for hiding this comment

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

@@ -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 {
Copy link
Member

Choose a reason for hiding this comment

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

@sunshinejr
Copy link
Contributor Author

Thanks for the review @ikesyo! I've changed static to class, let me know if there is anything more to do in this PR.

Copy link
Member
@ikesyo ikesyo left a 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!

@ikesyo ikesyo merged commit f031ff0 into Quick:master Nov 25, 2017
@sunshinejr sunshinejr deleted the fix/spm_swift4 branch February 5, 2018 13:20
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.

3 participants
0