Skip to content

Do not measure perform performance in CI #941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ import XCTest
@_spi(Testing) import _SwiftFormatTestSupport

final class WhitespaceLinterPerformanceTests: DiagnosingTestCase {
/// 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.
private func measureIfNotInCI(_ block: () -> Void) {
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] != nil {
block()
} else {
measure { block() }
}
}

func testWhitespaceLinterPerformance() throws {
#if os(Windows)
// https://github.com/swiftlang/swift-format/issues/939
throw XCTSkip("This test is flaky on Windows")
#endif
let input = String(
repeating: """
import SomeModule
Expand Down Expand Up @@ -50,7 +58,7 @@ final class WhitespaceLinterPerformanceTests: DiagnosingTestCase {
count: 20
)

measure { performWhitespaceLint(input: input, expected: expected) }
measureIfNotInCI { performWhitespaceLint(input: input, expected: expected) }
}

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