From 34b0e7d827ced71cb0dde8eb7cfea0aa938bd5a8 Mon Sep 17 00:00:00 2001 From: Robert Widmann Date: Wed, 27 Jul 2016 15:36:17 -0700 Subject: [PATCH] Updates for SE-0089 --- Sources/XCTest/Private/PerformanceMeter.swift | 4 ++-- Sources/XCTest/Private/TestListing.swift | 2 +- Sources/XCTest/Private/XCTestCaseSuite.swift | 2 +- Sources/XCTest/Public/XCTAssert.swift | 2 +- Sources/XCTest/Public/XCTestCase+Asynchronous.swift | 6 +++--- Sources/XCTest/Public/XCTestCase+Performance.swift | 4 ++-- Sources/XCTest/Public/XCTestExpectation.swift | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Sources/XCTest/Private/PerformanceMeter.swift b/Sources/XCTest/Private/PerformanceMeter.swift index 8d68ce0b3..40c404e10 100644 --- a/Sources/XCTest/Private/PerformanceMeter.swift +++ b/Sources/XCTest/Private/PerformanceMeter.swift @@ -118,7 +118,7 @@ public final class PerformanceMeter { let meter = PerformanceMeter(metrics: metrics, delegate: delegate, file: file, line: line) meter.measure(block) } catch let e { - delegate.recordAPIViolation(description: String(e), file: file, line: line) + delegate.recordAPIViolation(description: String(describing: e), file: file, line: line) } } @@ -204,6 +204,6 @@ public final class PerformanceMeter { private func recordAPIViolation(_ error: Error, file: StaticString, line: UInt) { state = .measurementAborted - delegate.recordAPIViolation(description: String(error), file: file, line: line) + delegate.recordAPIViolation(description: String(describing: error), file: file, line: line) } } diff --git a/Sources/XCTest/Private/TestListing.swift b/Sources/XCTest/Private/TestListing.swift index f131c5264..a3dfe9ba1 100644 --- a/Sources/XCTest/Private/TestListing.swift +++ b/Sources/XCTest/Private/TestListing.swift @@ -63,7 +63,7 @@ extension XCTestSuite: Listable { } private var listingName: String { - if let childTestCase = tests.first as? XCTestCase, name == String(childTestCase.dynamicType) { + if let childTestCase = tests.first as? XCTestCase, name == String(describing: childTestCase.dynamicType) { return "\(moduleName(value: childTestCase)).\(name)" } else { return name diff --git a/Sources/XCTest/Private/XCTestCaseSuite.swift b/Sources/XCTest/Private/XCTestCaseSuite.swift index dcf051c82..aee2c21bd 100644 --- a/Sources/XCTest/Private/XCTestCaseSuite.swift +++ b/Sources/XCTest/Private/XCTestCaseSuite.swift @@ -26,7 +26,7 @@ internal class XCTestCaseSuite: XCTestSuite { init(testCaseEntry: XCTestCaseEntry) { let testCaseClass = testCaseEntry.testCaseClass self.testCaseClass = testCaseClass - super.init(name: String(testCaseClass)) + super.init(name: String(describing: testCaseClass)) for (testName, testClosure) in testCaseEntry.allTests { let testCase = testCaseClass.init(name: testName, testClosure: testClosure) diff --git a/Sources/XCTest/Public/XCTAssert.swift b/Sources/XCTest/Public/XCTAssert.swift index e9e853c0c..d31b7b3d2 100644 --- a/Sources/XCTest/Public/XCTAssert.swift +++ b/Sources/XCTest/Public/XCTAssert.swift @@ -90,7 +90,7 @@ private func _XCTEvaluateAssertion(_ assertion: _XCTAssertion, message: @autoclo if let currentTestCase = XCTCurrentTestCase { currentTestCase.recordFailure( withDescription: "\(result.failureDescription(assertion)) - \(message())", - inFile: String(file), + inFile: String(describing: file), atLine: line, expected: result.isExpected) } diff --git a/Sources/XCTest/Public/XCTestCase+Asynchronous.swift b/Sources/XCTest/Public/XCTestCase+Asynchronous.swift index 2d68f862c..38f443635 100644 --- a/Sources/XCTest/Public/XCTestCase+Asynchronous.swift +++ b/Sources/XCTest/Public/XCTestCase+Asynchronous.swift @@ -85,7 +85,7 @@ public extension XCTestCase { if _allExpectations.count == 0 { recordFailure( withDescription: "API violation - call made to wait without any expectations having been set.", - inFile: String(file), + inFile: String(describing: file), atLine: line, expected: false) return @@ -129,7 +129,7 @@ public extension XCTestCase { let descriptions = unfulfilledDescriptions.joined(separator: ", ") recordFailure( withDescription: "Asynchronous wait failed - Exceeded timeout of \(timeout) seconds, with unfulfilled expectations: \(descriptions)", - inFile: String(file), + inFile: String(describing: file), atLine: line, expected: true) } @@ -248,7 +248,7 @@ internal extension XCTestCase { if expectations.count > 0 { recordFailure( withDescription: "Failed due to unwaited expectations.", - inFile: String(expectations.last!.file), + inFile: String(describing: expectations.last!.file), atLine: expectations.last!.line, expected: false) } diff --git a/Sources/XCTest/Public/XCTestCase+Performance.swift b/Sources/XCTest/Public/XCTestCase+Performance.swift index fde3d63ac..de36ec9d3 100644 --- a/Sources/XCTest/Public/XCTestCase+Performance.swift +++ b/Sources/XCTest/Public/XCTestCase+Performance.swift @@ -151,7 +151,7 @@ public extension XCTestCase { extension XCTestCase: PerformanceMeterDelegate { internal func recordAPIViolation(description: String, file: StaticString, line: UInt) { recordFailure(withDescription: "API violation - \(description)", - inFile: String(file), + inFile: String(describing: file), atLine: line, expected: false) } @@ -161,6 +161,6 @@ extension XCTestCase: PerformanceMeterDelegate { } internal func recordFailure(description: String, file: StaticString, line: UInt) { - recordFailure(withDescription: "failed: " + description, inFile: String(file), atLine: line, expected: true) + recordFailure(withDescription: "failed: " + description, inFile: String(describing: file), atLine: line, expected: true) } } diff --git a/Sources/XCTest/Public/XCTestExpectation.swift b/Sources/XCTest/Public/XCTestExpectation.swift index 5a9631fd4..e5900f212 100644 --- a/Sources/XCTest/Public/XCTestExpectation.swift +++ b/Sources/XCTest/Public/XCTestExpectation.swift @@ -58,7 +58,7 @@ public class XCTestExpectation { if let testCase = XCTCurrentTestCase { testCase.recordFailure( withDescription: "API violation - multiple calls made to XCTestExpectation.fulfill() for \(description).", - inFile: String(file), + inFile: String(describing: file), atLine: line, expected: false) }