@@ -127,14 +127,6 @@ extension XCTestCase {
127127 }
128128 }
129129
130- private var testName : String ? {
131- self . invocation? . selector. description. dropPrefix ( " test " ) . dropSuffix ( " AndReturnError: " )
132- }
133-
134- private var testDisplayName : String {
135- return testName ?? " (Unnamed Test) "
136- }
137-
138130 func tryOrFailTest< R> ( _ expression: @autoclosure ( ) throws -> R ? , message: String ) -> R ? {
139131 do {
140132 return try expression ( )
@@ -147,7 +139,7 @@ extension XCTestCase {
147139 /// Run `body()` `iterations`, gathering timing stats, and print them.
148140 /// In between runs, coax for the machine into an arbitrary but consistent thermal state by either sleeping or doing
149141 /// pointless work so that results are more comparable run to run, no matter else is happening on the machine.
150- package func gaugeTiming( iterations: Int = 1 , _ body: ( ) -> ( ) ) {
142+ package func gaugeTiming( iterations: Int = 1 , testName : String = #function , _ body: ( ) -> ( ) ) {
151143 let logFD = tryOrFailTest ( try Self . openPerformanceLog ( ) , message: " Failed to open performance log " )
152144 var timings = Timings ( )
153145 for iteration in 0 ..< iterations {
@@ -173,7 +165,7 @@ extension XCTestCase {
173165 confidence:± \( confidencePercentOfAverage. format ( " %0.2f " ) ) % \
174166 thermal: \( thermalLevel)
175167 """
176- let logMessage = " \( testDisplayName ) , \( duration. format ( " %0.4f " ) ) , \( thermalLevel) "
168+ let logMessage = " \( testName . prefix ( while : \ . isLetter ) ) , \( duration. format ( " %0.4f " ) ) , \( thermalLevel) "
177169 print ( consoleMessage)
178170 tryOrFailTest ( try logFD? . print ( logMessage) , message: " Failed to write to log " )
179171 }
0 commit comments