Skip to content

Commit 8775a45

Browse files
committed
Do not measure perform performance in CI
When executing in Swift CI, run the block to make sure it doesn't hit any assertions because we don't look at performance numbers in CI and CI nodes can have variable performance characteristics if they are not bare-metal. Anywhere else, run XCTest's `measure` function to measure the performance of the block. Fixes #939 rdar://145139964
1 parent 6e1b407 commit 8775a45

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Tests/SwiftFormatPerformanceTests/WhitespaceLinterPerformanceTests.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@ import XCTest
55
@_spi(Testing) import _SwiftFormatTestSupport
66

77
final class WhitespaceLinterPerformanceTests: DiagnosingTestCase {
8+
/// When executing in Swift CI, run the block to make sure it doesn't hit any assertions because we don't look at
9+
/// performance numbers in CI and CI nodes can have variable performance characteristics if they are not bare-metal.
10+
///
11+
/// Anywhere else, run XCTest's `measure` function to measure the performance of the block.
12+
private func measureIfNotInCI(_ block: () -> Void) {
13+
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] != nil {
14+
block()
15+
} else {
16+
measure { block() }
17+
}
18+
}
19+
820
func testWhitespaceLinterPerformance() throws {
9-
#if os(Windows)
10-
// https://github.com/swiftlang/swift-format/issues/939
11-
throw XCTSkip("This test is flaky on Windows")
12-
#endif
1321
let input = String(
1422
repeating: """
1523
import SomeModule
@@ -50,7 +58,7 @@ final class WhitespaceLinterPerformanceTests: DiagnosingTestCase {
5058
count: 20
5159
)
5260

53-
measure { performWhitespaceLint(input: input, expected: expected) }
61+
measureIfNotInCI { performWhitespaceLint(input: input, expected: expected) }
5462
}
5563

5664
/// Perform whitespace linting by comparing the input text from the user with the expected

0 commit comments

Comments
 (0)