Skip to content

Commit eeb2850

Browse files
authoredFeb 19, 2025
Merge pull request swiftlang#941 from ahoppen/no-measure-in-ci
Do not measure perform performance in CI
2 parents 6e1b407 + 8775a45 commit eeb2850

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed
 

Diff for: ‎Tests/SwiftFormatPerformanceTests/WhitespaceLinterPerformanceTests.swift

+13-5
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)