Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

modocache
Copy link
Collaborator

@modocache modocache commented May 23, 2016

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 as XCTest.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:

  • Test pull request on Swift continuous integration.

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

Platform Comment
All supported platforms @swift-ci Please smoke test
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
OS X platform @swift-ci Please test OS X platform
Linux platform @swift-ci Please test Linux platform

Note: Only members of the Apple organization can trigger swift-ci.

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.
@modocache
Copy link
Collaborator Author

@swift-ci please test

@modocache
Copy link
Collaborator Author

OS X passes, the Linux TestNSJSONSerialization.test_serialize_number failure is unrelated (and irrelevant to these changes).

Also, /cc @mike-ferris-apple and @briancroom. Does this look good to merge?

@mike-ferris
Copy link
Contributor

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.

@modocache
Copy link
Collaborator Author

modocache commented May 23, 2016

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 XCTest.run() method. As is, though, I think that will fail -- I made the following changes:

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:

/Users/bgesiak/GitHub/apple/swift/validation-test/stdlib/XCTest.swift:31:3: error: ambiguous use of 'run()'
  testCase.run()
  ^

I wonder which version of Xcode CI uses...?

@mike-ferris
Copy link
Contributor

Yeah, the Xcode which fixes this is not quite available yet... CI is certainly not yet using this Xcode either.

@modocache
Copy link
Collaborator Author

Confirmed -- thanks, @mike-ferris-apple, and congratulations on another XCTest release! 🎉

screen shot 2016-06-13 at 4 08 20 pm

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.

None yet

2 participants