@@ -127,14 +127,6 @@ extension XCTestCase {
127
127
}
128
128
}
129
129
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
-
138
130
func tryOrFailTest< R> ( _ expression: @autoclosure ( ) throws -> R ? , message: String ) -> R ? {
139
131
do {
140
132
return try expression ( )
@@ -147,7 +139,7 @@ extension XCTestCase {
147
139
/// Run `body()` `iterations`, gathering timing stats, and print them.
148
140
/// In between runs, coax for the machine into an arbitrary but consistent thermal state by either sleeping or doing
149
141
/// 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: ( ) -> ( ) ) {
151
143
let logFD = tryOrFailTest ( try Self . openPerformanceLog ( ) , message: " Failed to open performance log " )
152
144
var timings = Timings ( )
153
145
for iteration in 0 ..< iterations {
@@ -173,7 +165,7 @@ extension XCTestCase {
173
165
confidence:± \( confidencePercentOfAverage. format ( " %0.2f " ) ) % \
174
166
thermal: \( thermalLevel)
175
167
"""
176
- let logMessage = " \( testDisplayName ) , \( duration. format ( " %0.4f " ) ) , \( thermalLevel) "
168
+ let logMessage = " \( testName . prefix ( while : \ . isLetter ) ) , \( duration. format ( " %0.4f " ) ) , \( thermalLevel) "
177
169
print ( consoleMessage)
178
170
tryOrFailTest ( try logFD? . print ( logMessage) , message: " Failed to write to log " )
179
171
}
0 commit comments