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
[SR-1165][apinotes] Avoid duplicate XCTest.run()
#2645
Conversation
The abstract base class XCTest declares a (deprecated) method `-[XCTest run]`. If left to the standard name conversion rules, this conflicts with `-[XCTest runTest]`. Here we explicitly convert `-runTest` as `XCTest.runTest()`. See https://bugs.swift.org/browse/SR-1165 for details. This also removes the `execute()` function used by the validation tests, introduced in 55fde4c. Fixes https://bugs.swift.org/browse/SR-1165.
aaa7479
to
edad315
Compare
@swift-ci please test |
OS X passes, the Linux Also, /cc @mike-ferris-apple and @briancroom. Does this look good to merge? |
This has been addressed in Xcode's XCTest via rdar://problem/25780530. We will be removing the deprecated method (it was deprecated a long time ago.) SO I don't think we should mess with it in the overlay. |
Oh, awesome! Thanks, @mike-ferris-apple. Which version of Xcode introduced the change? I don't think I have the version you describe yet. If we're removing the old method, I could update these tests to simply use the diff --git a/validation-test/stdlib/XCTest.swift b/validation-test/stdlib/XCTest.swift
index be1213e..790bbb6 100644
--- a/validation-test/stdlib/XCTest.swift
+++ b/validation-test/stdlib/XCTest.swift
@@ -20,11 +20,6 @@ var XCTestTestSuite = TestSuite("XCTest")
// as dynamic. Objective-C XCTest uses runtime introspection to
// instantiate an NSInvocation with the given selector.
-
-func execute(_ run: () -> ()) {
- run()
-}
-
XCTestTestSuite.test("exceptions") {
class ExceptionTestCase: XCTestCase {
dynamic func test_raises() {
@@ -33,7 +28,7 @@ XCTestTestSuite.test("exceptions") {
}
let testCase = ExceptionTestCase(selector: #selector(ExceptionTestCase.test_raises))
- execute(testCase.run)
+ testCase.run()
let testRun = testCase.testRun!
expectEqual(1, testRun.testCaseCount)
@@ -58,7 +53,7 @@ XCTestTestSuite.test("XCTAssertEqual/Array<T>") {
}
let passingTestCase = AssertEqualArrayTestCase(selector: #selector(AssertEqualArrayTestCase.test_whenArraysAreEqual_passes))
- execute(passingTestCase.run)
+ passingTestCase.run()
let passingTestRun = passingTestCase.testRun!
expectEqual(1, passingTestRun.testCaseCount)
expectEqual(1, passingTestRun.executionCount)
@@ -68,7 +63,7 @@ XCTestTestSuite.test("XCTAssertEqual/Array<T>") {
expectTrue(passingTestRun.hasSucceeded)
let failingTestCase = AssertEqualArrayTestCase(selector: #selector(AssertEqualArrayTestCase.test_whenArraysAreNotEqual_fails))
- execute(failingTestCase.run)
+ failingTestCase.run()
let failingTestRun = failingTestCase.testRun!
expectEqual(1, failingTestRun.testCaseCount)
expectEqual(1, failingTestRun.executionCount)
@@ -92,7 +87,7 @@ XCTestTestSuite.test("XCTAssertEqual/Dictionary<T, U>") {
}
let passingTestCase = AssertEqualDictionaryTestCase(selector: #selector(AssertEqualDictionaryTestCase.test_whenDictionariesAreEqual_passes))
- execute(passingTestCase.run)
+ passingTestCase.run()
let passingTestRun = passingTestCase.testRun!
expectEqual(1, passingTestRun.testCaseCount)
expectEqual(1, passingTestRun.executionCount)
@@ -102,7 +97,7 @@ XCTestTestSuite.test("XCTAssertEqual/Dictionary<T, U>") {
expectTrue(passingTestRun.hasSucceeded)
let failingTestCase = AssertEqualDictionaryTestCase(selector: #selector(AssertEqualDictionaryTestCase.test_whenDictionariesAreNotEqual_fails))
- execute(failingTestCase.run)
+ failingTestCase.run()
let failingTestRun = failingTestCase.testRun!
expectEqual(1, failingTestRun.testCaseCount)
expectEqual(1, failingTestRun.executionCount)
@@ -136,7 +131,7 @@ XCTestTestSuite.test("XCTAssertThrowsError") {
// Try success case
do {
let testCase = ErrorTestCase(selector: #selector(ErrorTestCase.test_throws))
- execute(testCase.run)
+ testCase.run()
let testRun = testCase.testRun!
expectEqual(1, testRun.testCaseCount)
@@ -151,7 +146,7 @@ XCTestTestSuite.test("XCTAssertThrowsError") {
do {
let testCase = ErrorTestCase(selector: #selector(ErrorTestCase.test_throws))
testCase.doThrow = false
- execute(testCase.run)
+ testCase.run()
let testRun = testCase.testRun!
expectEqual(1, testRun.testCaseCount)
@@ -167,7 +162,7 @@ XCTestTestSuite.test("XCTAssertThrowsError") {
do {
let testCase = ErrorTestCase(selector: #selector(ErrorTestCase.test_throws))
testCase.errorCode = 23
- execute(testCase.run)
+ testCase.run()
let testRun = testCase.testRun!
expectEqual(1, testRun.testCaseCount)
@@ -201,7 +196,7 @@ XCTestTestSuite.test("XCTAsserts with throwing expressions") {
do {
let testCase = ErrorTestCase(selector: #selector(ErrorTestCase.test_withThrowing))
testCase.doThrow = false
- execute(testCase.run)
+ testCase.run()
let testRun = testCase.testRun!
expectEqual(1, testRun.testCaseCount)
@@ -215,7 +210,7 @@ XCTestTestSuite.test("XCTAsserts with throwing expressions") {
// Now try when the expression throws
do {
let testCase = ErrorTestCase(selector: #selector(ErrorTestCase.test_withThrowing))
- execute(testCase.run)
+ testCase.run()
let testRun = testCase.testRun!
expectEqual(1, testRun.testCaseCount)
@@ -248,7 +243,7 @@ XCTestTestSuite.test("Test methods that wind up throwing") {
do {
let testCase = ErrorTestCase(selector: #selector(ErrorTestCase.test_withThrowing))
testCase.doThrow = false
- execute(testCase.run)
+ testCase.run()
let testRun = testCase.testRun!
expectEqual(1, testRun.testCaseCount)
@@ -262,7 +257,7 @@ XCTestTestSuite.test("Test methods that wind up throwing") {
// Now try when the expression throws
do {
let testCase = ErrorTestCase(selector: #selector(ErrorTestCase.test_withThrowing))
- execute(testCase.run)
+ testCase.run()
let testRun = testCase.testRun!
expectEqual(1, testRun.testCaseCount) But those led to test failures such as the following:
I wonder which version of Xcode CI uses...? |
Yeah, the Xcode which fixes this is not quite available yet... CI is certainly not yet using this Xcode either. |
Confirmed -- thanks, @mike-ferris-apple, and congratulations on another XCTest release! 🎉 |
What's in this pull request?
The abstract base class XCTest declares a (deprecated) method
-[XCTest run]
. If left to the standard name conversion rules, this conflicts with-[XCTest runTest]
. Here we explicitly convert-runTest
asXCTest.runTest()
. See https://bugs.swift.org/browse/SR-1165 for details./cc @milseman
Resolved bug number: (SR-1165)
Before merging this pull request to apple/swift repository:
Triggering Swift CI
The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:
Smoke Testing
Validation Testing
Note: Only members of the Apple organization can trigger swift-ci.