Skip to content

Commit ff15d54

Browse files
committed
Only test debug build configuration on Windows
With the recent changes to the automated test, which augmented the Tests to run against the Native and Swift Build build system, in addition to the debug and release build configuraiton, and with `swift test` buffer the output on Windows (#8928), the theory is the Windows self hosted pipeline is failing due to the number of automated test, which causes Jenkins to hit the "Build Timeout" algorithim, causing Jenkins to abort the build as there is no output to the console. I norer to unblock development, a change was made to run test against the Debug build configuration on Windows until a proper solution is availabe. Related to #9159 Issue: rdar://160936699
1 parent 7046c68 commit ff15d54

File tree

4 files changed

+140
-2
lines changed

4 files changed

+140
-2
lines changed

Sources/_InternalTestSupport/BuildSystemProvider+Supported.swift

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import struct SPMBuildCore.BuildSystemProvider
1414
import enum PackageModel.BuildConfiguration
15+
import struct Basics.Environment
16+
import struct Basics.EnvironmentKey
1517

1618
public var SupportedBuildSystemOnAllPlatforms: [BuildSystemProvider.Kind] = BuildSystemProvider.Kind.allCases.filter { $0 != .xcode }
1719

@@ -28,10 +30,29 @@ public struct BuildData {
2830
public let config: BuildConfiguration
2931
}
3032

33+
package let TEST_ONLY_DEBUG_ENV_VAR = EnvironmentKey("SWIFTPM_TEST_ONLY_DEBUG_BUILD_CONFIGURTION")
3134
public func getBuildData(for buildSystems: [BuildSystemProvider.Kind]) -> [BuildData] {
32-
buildSystems.flatMap { buildSystem in
33-
BuildConfiguration.allCases.compactMap { config in
35+
let buildConfigurations: [BuildConfiguration]
36+
if let value = Environment.current[TEST_ONLY_DEBUG_ENV_VAR], value.isTruthy {
37+
buildConfigurations = [.debug]
38+
} else {
39+
buildConfigurations = BuildConfiguration.allCases
40+
}
41+
return buildSystems.flatMap { buildSystem in
42+
buildConfigurations.compactMap { config in
3443
return BuildData(buildSystem: buildSystem, config: config)
3544
}
3645
}
3746
}
47+
48+
49+
extension String {
50+
package var isTruthy: Bool {
51+
switch self.lowercased() {
52+
case "true", "1", "yes":
53+
return true
54+
default:
55+
return false
56+
}
57+
}
58+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift open source project
4+
//
5+
// Copyright (c) 2024-2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import _InternalTestSupport
14+
import Testing
15+
import struct SPMBuildCore.BuildSystemProvider
16+
import enum PackageModel.BuildConfiguration
17+
import struct Basics.Environment
18+
19+
@Suite(
20+
.tags(
21+
.TestSize.small,
22+
)
23+
)
24+
struct BuildSystemProviderSupportedTests {
25+
26+
@Test(
27+
.serialized,
28+
arguments: [
29+
[BuildSystemProvider.Kind.native],
30+
[BuildSystemProvider.Kind.native, .xcode],
31+
[BuildSystemProvider.Kind.native, .xcode, .swiftbuild],
32+
], [true, false],
33+
)
34+
func getBuildDataReturnsExpectedTests(
35+
buildSystemsUT: [BuildSystemProvider.Kind],
36+
setEnvironmantVariable: Bool,
37+
) async throws {
38+
let expectedCount: Int
39+
let customEnv: Environment
40+
41+
if setEnvironmantVariable {
42+
expectedCount = buildSystemsUT.count
43+
customEnv = [TEST_ONLY_DEBUG_ENV_VAR : "true"]
44+
} else {
45+
expectedCount = buildSystemsUT.count * BuildConfiguration.allCases.count
46+
customEnv = [:]
47+
}
48+
49+
try Environment.makeCustom(customEnv) {
50+
let actual = getBuildData(for: buildSystemsUT)
51+
52+
#expect(actual.count == expectedCount)
53+
}
54+
55+
}
56+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift open source project
4+
//
5+
// Copyright (c) 2024-2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import _InternalTestSupport
14+
import Testing
15+
16+
@Suite(
17+
.tags(
18+
.TestSize.small,
19+
)
20+
)
21+
struct StringExtensionTests {
22+
23+
@Test(
24+
arguments: [
25+
(value: "", expected: false),
26+
(value: " ", expected: false),
27+
(value: "0", expected: false),
28+
(value: "1", expected: true),
29+
(value: "true", expected: true),
30+
(value: "True", expected: true),
31+
(value: "TrUe", expected: true),
32+
(value: "ftrue", expected: false),
33+
(value: "truef", expected: false),
34+
(value: "ftruef", expected: false),
35+
(value: "YES", expected: true),
36+
(value: "YEs", expected: true),
37+
(value: "yEs", expected: true),
38+
(value: "yes", expected: true),
39+
(value: "fyes", expected: false),
40+
(value: "yesf", expected: false),
41+
(value: "fyesf", expected: false),
42+
(value: "11", expected: false),
43+
],
44+
)
45+
func isTruthyReturnsCorrectValue(
46+
valueUT: String,
47+
expected: Bool,
48+
) async throws {
49+
let actual = valueUT.isTruthy
50+
51+
#expect(actual == expected, "Value \(valueUT) should be \(expected)")
52+
}
53+
}

Utilities/build-using-self

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ def is_on_darwin() -> bool:
136136
return platform.system() == "Darwin"
137137

138138

139+
def is_on_windows() -> bool:
140+
return platform.system() == "Windows"
141+
142+
139143
def set_environment(
140144
*,
141145
swiftpm_bin_dir: pathlib.Path,
@@ -147,6 +151,10 @@ def set_environment(
147151
sdk_root = call_output(shlex.split("xcrun --show-sdk-path --sdk macosx"))
148152
logging.debug("macos sdk root = %r", sdk_root)
149153
os.environ["SDKROOT"] = sdk_root
154+
155+
if is_on_windows():
156+
# GH #9159: Temprorarily set this environment until we figure out why the Windows internal CI is hanging
157+
os.environ["SWIFTPM_TEST_ONLY_DEBUG_BUILD_CONFIGURTION"] = "true"
150158
log_environment()
151159

152160

0 commit comments

Comments
 (0)