Skip to content

Commit f21d2a2

Browse files
committed
Mark new test as withKnownIssue on some linux distro
A new test was added in swiftlang#7239, however this test failed in the Amazon Linux 2 and Debian 12 OSS Toolchain CI builds. Mark this test as `withKnownIssue` on these platforms until we can investigate the rooot cause. Also, include tag information on the test. Relates to: swiftlang#7239 Issue: rdar://164634849
1 parent 2cd79dc commit f21d2a2

File tree

4 files changed

+87
-28
lines changed

4 files changed

+87
-28
lines changed

Sources/_InternalTestSupport/ProcessInfo+hostutils.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import Foundation
1111

1212
extension ProcessInfo {
13-
public static func isHostAmazonLinux2(_ content: String? = nil) -> Bool {
13+
package static func isHostOs(prettyName: String, content: String? = nil) -> Bool {
1414
let contentString: String
1515
if let content {
1616
contentString = content
@@ -22,8 +22,16 @@ extension ProcessInfo {
2222
return false
2323
}
2424
}
25-
let al2_name = "PRETTY_NAME=\"Amazon Linux 2\""
26-
return contentString.contains(al2_name)
25+
let name = "PRETTY_NAME=\"\(prettyName)\""
26+
return contentString.contains(name)
27+
28+
}
29+
public static func isHostAmazonLinux2() -> Bool {
30+
return Self.isHostOs(prettyName: "Amazon Linux 2")
31+
}
32+
33+
public static func isHostDebian12() -> Bool {
34+
return Self.isHostOs(prettyName: "Debian GNU/Linux 12 (bookworm)")
2735
}
2836

29-
}
37+
}

Sources/_InternalTestSupport/SwiftTesting+Tags.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ extension Tag.Feature {
4040
@Tag public static var CodeCoverage: Tag
4141
@Tag public static var CTargets: Tag
4242
@Tag public static var DependencyResolution: Tag
43+
@Tag public static var LibraryEvolution: Tag
4344
@Tag public static var ModuleAliasing: Tag
4445
@Tag public static var Mirror: Tag
4546
@Tag public static var NetRc: Tag

Tests/BasicsTests/ProcessInfoTests.swift

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import Testing
1515
@testable import struct _InternalTestSupport.CombinationsWithRepetition
1616

1717
fileprivate let d = [
18-
[],
19-
[""],
20-
["line1"],
21-
["line1", "line2"],
22-
["line1", "line2", "line3"],
23-
]
18+
[],
19+
[""],
20+
["line1"],
21+
["line1", "line2"],
22+
["line1", "line2", "line3"],
23+
]
2424
fileprivate let prefixAndSuffixData = CombinationsWithRepetition(of: d, length: 2).map( {data in
2525
// Content(prefix: data.0, suffix: data.1)
2626
Content(prefix: data[0], suffix: data[1])
@@ -46,18 +46,20 @@ fileprivate struct Content {
4646
struct ProcessInfoExtensionTests {
4747

4848
@Suite
49-
struct isAmazonLinux2 {
49+
struct isHostOsTests {
5050
@Test(
5151
arguments: [
52-
(contentUT: "", expected: false),
53-
(contentUT: "PRETTY_NAME=", expected: false),
54-
(contentUT: "PRETTY_NAME=foo", expected: false),
55-
(contentUT: "PRETTY_NAME=amzn", expected: false),
56-
(contentUT: "PRETTY_NAME=Amazon Linux 2", expected: false),
57-
(contentUT: "PRETTY_NAME=Amazon Linux 2023.6.20250107", expected: false),
58-
(contentUT: " PRETTY_NAME=amzn", expected: false),
59-
(contentUT: "PRETTY_NAME=\"Amazon Linux 2\"", expected: true),
60-
(contentUT: "PRETTY_NAME=\"Amazon Linux 2 (something else)\"", expected: false),
52+
(contentUT: "", nameUT: "Amazon Linux 2", expected: false),
53+
(contentUT: "PRETTY_NAME=", nameUT: "Amazon Linux 2", expected: false),
54+
(contentUT: "PRETTY_NAME=foo", nameUT: "Amazon Linux 2", expected: false),
55+
(contentUT: "PRETTY_NAME=amzn", nameUT: "Amazon Linux 2", expected: false),
56+
(contentUT: "PRETTY_NAME=Amazon Linux 2", nameUT: "Amazon Linux 2", expected: false),
57+
(contentUT: "PRETTY_NAME=Amazon Linux 2", nameUT: "Amazon Linux 2", expected: false),
58+
(contentUT: "PRETTY_NAME=Amazon Linux 2023.6.20250107", nameUT: "Amazon Linux 2", expected: false),
59+
(contentUT: " PRETTY_NAME=amzn", nameUT: "Amazon Linux 2", expected: false),
60+
(contentUT: "PRETTY_NAME=\"Amazon Linux 2\"", nameUT: "Amazon Linux 2", expected: true),
61+
(contentUT: " PRETTY_NAME=\"Amazon Linux 2\"", nameUT: "Amazon Linux 2", expected: true),
62+
(contentUT: "PRETTY_NAME=\"Amazon Linux 2 (something else)\"", nameUT: "Amazon Linux 2", expected: false),
6163
(
6264
contentUT: """
6365
NAME="Amazon Linux"
@@ -71,6 +73,7 @@ struct ProcessInfoExtensionTests {
7173
HOME_URL="https://amazonlinux.com/"
7274
SUPPORT_END="2026-06-30"
7375
""",
76+
nameUT: "Amazon Linux 2",
7477
expected: true
7578
),
7679
(
@@ -86,6 +89,7 @@ struct ProcessInfoExtensionTests {
8689
HOME_URL="https://amazonlinux.com/"
8790
SUPPORT_END="2026-06-30"
8891
""",
92+
nameUT: "Amazon Linux 2",
8993
expected: false
9094
),
9195
(
@@ -101,6 +105,7 @@ struct ProcessInfoExtensionTests {
101105
HOME_URL="https://amazonlinux.com/"
102106
SUPPORT_END="2026-06-30"
103107
""",
108+
nameUT: "Amazon Linux 2",
104109
expected: false
105110
),
106111
(
@@ -116,6 +121,7 @@ struct ProcessInfoExtensionTests {
116121
HOME_URL="https://amazonlinux.com/"
117122
SUPPORT_END="2026-06-30"
118123
""",
124+
nameUT: "Amazon Linux 2",
119125
expected: false
120126
),
121127
(
@@ -137,30 +143,62 @@ struct ProcessInfoExtensionTests {
137143
VENDOR_URL="https://aws.amazon.com/"
138144
SUPPORT_END="2028-03-15"
139145
""",
146+
nameUT: "Amazon Linux 2",
147+
expected: false,
148+
),
149+
(
150+
contentUT: """
151+
NAME="Amazon Linux"
152+
PLATFORM_ID="platform:al2023"
153+
PRETTY_NAME="myFoo"
154+
ANSI_COLOR="0;33"
155+
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
156+
""",
157+
nameUT: "myfoo",
140158
expected: false,
141159
)
142160
], prefixAndSuffixData,
143161
)
144-
fileprivate func isAmazonLinux2ReturnsExpectedValue(
145-
data: (contentUT: String, expected: Bool),
162+
fileprivate func isHostOsReturnsExpectedValue(
163+
data: (contentUT: String, nameUT: String, expected: Bool),
146164
content: Content,
165+
147166
) async throws {
148167
let content = content.getContent(data.contentUT)
149168

150-
let actual = ProcessInfo.isHostAmazonLinux2(content)
169+
let actual = ProcessInfo.isHostOs(prettyName: data.nameUT, content: content)
151170

152171
#expect(actual == data.expected, "Content is: '\(content)'")
153172
}
154173

174+
@Test(
175+
.requireHostOS(.windows),
176+
.requireHostOS(.macOS),
177+
)
178+
func isHostOsReturnsFalseIfTheOSFileContentsCannotBeRead() async throws {
179+
let actual = ProcessInfo.isHostOs(prettyName: "Amazon Linux 2")
180+
#expect(actual == false)
181+
}
182+
155183
@Test(
156184
"isHostAmazonLinux2 returns false when not executed on Linux",
157-
.skipHostOS(.linux),
158-
.tags(Tag.TestSize.medium),
185+
.skipHostOS(.linux, "Test cannot run on AmazonLinux2, but we can't distinguish linux distributions, so skipping",),
186+
.tags(Tag.TestSize.small),
159187
)
160188
func isAmazonLinux2ReturnsFalseWhenNotRunOnLinux() {
161189
let actual = ProcessInfo.isHostAmazonLinux2()
162190

191+
#expect(actual == false)
192+
}
193+
@Test(
194+
"isHostDebian12 returns false when not executed on Linux",
195+
.skipHostOS(.linux, "Test cannot run on Debian 12, but we can't distinguish linux distributions, so skipping",),
196+
.tags(Tag.TestSize.small),
197+
)
198+
func isHostDebian12ReturnsFalseWhenNotRunOnLinux() {
199+
let actual = ProcessInfo.isHostDebian12()
200+
163201
#expect(actual == false)
164202
}
165203
}
166-
}
204+
}

Tests/FunctionalTests/LibraryEvolutionXCFLinuxTests.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,25 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
import Foundation
1314
import _InternalTestSupport
1415
import Basics
1516
import Testing
17+
import PackageLoading
1618

1719
private struct SwiftPMTests {
1820
@Test(
1921
.requireSwift6_2,
20-
.requireHostOS(.linux)
22+
.requireHostOS(.linux),
23+
.tags(
24+
.TestSize.large,
25+
.Feature.Command.Run,
26+
.Feature.LibraryEvolution,
27+
),
28+
.issue("https://github.com/swiftlang/swift-package-manager/issues/9372", relationship: .defect),
2129
)
2230
func libraryEvolutionLinuxXCFramework() async throws {
31+
try await withKnownIssue {
2332
try await fixture(name: "Miscellaneous/LibraryEvolutionLinuxXCF") { fixturePath in
2433
let swiftFramework = "SwiftFramework"
2534
try await withTemporaryDirectory(removeTreeOnDeinit: false) { tmpDir in
@@ -105,5 +114,8 @@ private struct SwiftPMTests {
105114
#expect(!runOutput.stderr.contains("error:"))
106115
#expect(runOutput.stdout.contains("Latest Framework with LibraryEvolution version: v2"))
107116
}
117+
} when: {
118+
ProcessInfo.isHostAmazonLinux2() || ProcessInfo.isHostDebian12()
119+
}
108120
}
109-
}
121+
}

0 commit comments

Comments
 (0)