Skip to content

Commit a089692

Browse files
committed
Tests: Update expectation
Update test expectation for executing SwiftPM tests using the build.ps1 script found in swiftlang/swift/utils/build.ps1. Relates to: swiftlang/swift#80405
1 parent adf14cf commit a089692

File tree

5 files changed

+36
-54
lines changed

5 files changed

+36
-54
lines changed

Tests/CommandsTests/BuildCommandTests.swift

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -489,18 +489,14 @@ struct BuildCommandTestCases {
489489
return
490490
}
491491

492-
try withKnownIssue {
493-
if .native == buildSystem {
494-
#expect(stderr.contains("error: no product named '\(productName)'"))
495-
} else {
496-
let expectedErrorMessageRegex = try Regex("error: Could not find target named '\(productName).*'")
497-
#expect(
498-
stderr.contains(expectedErrorMessageRegex),
499-
"expect log not emitted.\nstdout: '\(stdout)'\n\nstderr: '\(stderr)'",
500-
)
501-
}
502-
} when: {
503-
buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .windows && CiEnvironment.runningInSmokeTestPipeline
492+
if .native == buildSystem {
493+
#expect(stderr.contains("error: no product named '\(productName)'"))
494+
} else {
495+
let expectedErrorMessageRegex = try Regex("error: Could not find target named '\(productName).*'")
496+
#expect(
497+
stderr.contains(expectedErrorMessageRegex),
498+
"expect log not emitted.\nstdout: '\(stdout)'\n\nstderr: '\(stderr)'",
499+
)
504500
}
505501
}
506502
}
@@ -530,14 +526,10 @@ struct BuildCommandTestCases {
530526
} else {
531527
expectedErrorMessage = "error: Could not find target named '\(targetName)'"
532528
}
533-
withKnownIssue{
534-
#expect(
535-
stderr.contains(expectedErrorMessage),
536-
"expect log not emitted.\nstdout: '\(stdout)'\n\nstderr: '\(stderr)'",
537-
)
538-
} when: {
539-
buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .windows && CiEnvironment.runningInSmokeTestPipeline
540-
}
529+
#expect(
530+
stderr.contains(expectedErrorMessage),
531+
"expect log not emitted.\nstdout: '\(stdout)'\n\nstderr: '\(stderr)'",
532+
)
541533
}
542534
}
543535

@@ -748,7 +740,7 @@ struct BuildCommandTestCases {
748740
result.stdout.contains("Building for \(expectedString)"),
749741
"expect log not emitted. got stdout: '\(result.stdout)'\n\nstderr '\(result.stderr)'")
750742
} when: {
751-
buildSystem == .xcode || (buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .windows && CiEnvironment.runningInSmokeTestPipeline)
743+
buildSystem == .xcode
752744
}
753745
}
754746
}

Tests/CommandsTests/RunCommandTests.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ struct RunCommandTests {
129129
}
130130
}
131131
} when: {
132-
.swiftbuild == buildSystem && ProcessInfo.hostOperatingSystem == .windows
132+
(.swiftbuild == buildSystem && ProcessInfo.hostOperatingSystem == .windows)
133+
|| (.native == buildSystem && ProcessInfo.hostOperatingSystem == .windows && CiEnvironment.runningInSmokeTestPipeline)
133134
}
134135
}
135136

@@ -168,6 +169,7 @@ struct RunCommandTests {
168169
}
169170
} when: {
170171
(.windows == ProcessInfo.hostOperatingSystem && buildSystem == .swiftbuild)
172+
|| (.windows == ProcessInfo.hostOperatingSystem && buildSystem == .native && CiEnvironment.runningInSmokeTestPipeline)
171173
|| (.linux == ProcessInfo.hostOperatingSystem && buildSystem == .swiftbuild && CiEnvironment.runningInSelfHostedPipeline)
172174
}
173175
}
@@ -229,7 +231,8 @@ struct RunCommandTests {
229231
#expect(runOutput.contains("2"))
230232
}
231233
} when: {
232-
[.windows, .linux].contains(ProcessInfo.hostOperatingSystem) && buildSystem == .swiftbuild && CiEnvironment.runningInSelfHostedPipeline
234+
([.windows, .linux].contains(ProcessInfo.hostOperatingSystem) && buildSystem == .swiftbuild && CiEnvironment.runningInSelfHostedPipeline)
235+
|| (.windows == ProcessInfo.hostOperatingSystem && [.native, .swiftbuild].contains(buildSystem) && CiEnvironment.runningInSmokeTestPipeline)
233236
}
234237
}
235238

@@ -249,7 +252,7 @@ struct RunCommandTests {
249252
#expect(String(outputLines[0]).contains("BTarget2"))
250253
}
251254
} when: {
252-
(ProcessInfo.hostOperatingSystem == .windows && CiEnvironment.runningInSmokeTestPipeline && buildSystem == .native)
255+
(ProcessInfo.hostOperatingSystem == .windows && CiEnvironment.runningInSmokeTestPipeline && [.native, .swiftbuild].contains(buildSystem))
253256
|| (ProcessInfo.hostOperatingSystem == .linux && buildSystem == .swiftbuild && CiEnvironment.runningInSelfHostedPipeline)
254257
}
255258
}

Tests/FunctionalTests/PluginTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ final class PluginTests {
6464
#expect(stderr.contains("file(s) which are unhandled; explicitly declare them as resources or exclude from the target"), "expected warning not emitted")
6565
}
6666
} when: {
67-
ProcessInfo.hostOperatingSystem == .windows
67+
ProcessInfo.hostOperatingSystem == .windows && CiEnvironment.runningInSelfHostedPipeline
6868
}
6969

7070
// Try again with the Swift Build build system

Tests/FunctionalTests/TraitTests.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,7 @@ struct TraitTests {
494494
#expect(stdout.contains(expectedOut))
495495
}
496496
} when: {
497-
ProcessInfo.hostOperatingSystem == .windows && CiEnvironment.runningInSmokeTestPipeline
498-
|| (buildSystem == .swiftbuild && [.windows].contains(ProcessInfo.hostOperatingSystem))
497+
(buildSystem == .swiftbuild && [.windows].contains(ProcessInfo.hostOperatingSystem))
499498
}
500499
}
501500

Tests/PackageLoadingTests/PD_6_2_LoadingTests.swift

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,33 +68,21 @@ struct PackageDescription6_2LoadingTests {
6868
"""
6969

7070
let observability = ObservabilitySystem.makeForTesting()
71-
try await withKnownIssue("https://github.com/swiftlang/swift-package-manager/issues/8543: there are compilation errors on Windows") {
72-
let (_, validationDiagnostics) = try await PackageDescriptionLoadingTests
73-
.loadAndValidateManifest(
74-
content,
75-
toolsVersion: .v6_2,
76-
packageKind: .fileSystem(.root),
77-
manifestLoader: ManifestLoader(
78-
toolchain: try! UserToolchain.default
79-
),
80-
observabilityScope: observability.topScope
81-
)
82-
try expectDiagnostics(validationDiagnostics) { results in
83-
results.checkIsEmpty()
84-
}
85-
try expectDiagnostics(observability.diagnostics) { results in
86-
results.checkIsEmpty()
87-
}
88-
} when: {
89-
isWindows
71+
let (_, validationDiagnostics) = try await PackageDescriptionLoadingTests
72+
.loadAndValidateManifest(
73+
content,
74+
toolsVersion: .v6_2,
75+
packageKind: .fileSystem(.root),
76+
manifestLoader: ManifestLoader(
77+
toolchain: try! UserToolchain.default
78+
),
79+
observabilityScope: observability.topScope
80+
)
81+
try expectDiagnostics(validationDiagnostics) { results in
82+
results.checkIsEmpty()
83+
}
84+
try expectDiagnostics(observability.diagnostics) { results in
85+
results.checkIsEmpty()
9086
}
9187
}
9288
}
93-
94-
private var isWindows: Bool {
95-
#if os(Windows)
96-
true
97-
#else
98-
false
99-
#endif
100-
}

0 commit comments

Comments
 (0)