Skip to content

Commit 620cbb9

Browse files
authored
Tests: Enable some BuildTests/**/*.swift tests on Windows (#8512)
- Enable the BuildPlanTests on Windows - Split a PrepareForIndexTests tests into two withthe passing, and failing on Windows - update/add a message on some skipped windows tests, with a reference to GitHub Issue Related to: #8433 Depends on: #8569 rdar://148248105
1 parent c5582fb commit 620cbb9

File tree

5 files changed

+67
-28
lines changed

5 files changed

+67
-28
lines changed

Fixtures/Miscellaneous/Plugins/MyBinaryToolPlugin/Binaries/MyVendedSourceGenBuildTool.artifactbundle/info.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
{
1313
"path": "mytool-linux/mytool",
1414
"supportedTriples": ["x86_64-unknown-linux-gnu"]
15+
},
16+
{
17+
"path": "mytool-windows/mytool.bat",
18+
"supportedTriples": ["x86_64-unknown-windows-msvc", "aarch64-unknown-windows-msvc"]
1519
}
1620
]
1721
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@echo off
2+
3+
set verbose=false
4+
IF NOT "%1"=="" (
5+
IF "%1"=="--verbose" (
6+
SET verbose=true
7+
SHIFT
8+
)
9+
)
10+
11+
set input=%1
12+
set output=%2
13+
shift
14+
shift
15+
16+
17+
if "%verbose%" == "true" (
18+
echo "[mytool-windows] '%input%' '%output%'"
19+
)
20+
@echo on
21+
echo f | xcopy.exe /f "%input%" "%output%"

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,8 +2045,6 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
20452045
}
20462046

20472047
func test_symbolGraphExtract_arguments() async throws {
2048-
try XCTSkipOnWindows()
2049-
20502048
// ModuleGraph:
20512049
// .
20522050
// ├── A (Swift)
@@ -2115,41 +2113,46 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
21152113

21162114
// A
21172115
do {
2116+
let expectedModuleMap = AbsolutePath("/path/to/build/\(triple)/debug/C.build/module.modulemap").pathString
21182117
try XCTAssertMatchesSubSequences(
21192118
result.moduleBuildDescription(for: "A").symbolGraphExtractArguments(),
21202119
// Swift Module dependencies
2121-
["-I", "/path/to/build/\(triple)/debug/Modules"],
2120+
["-I", .equal(AbsolutePath("/path/to/build/\(triple)/debug/Modules").pathString)],
21222121
// C Module dependencies
2123-
["-Xcc", "-I", "-Xcc", "/Pkg/Sources/C/include"],
2124-
["-Xcc", "-fmodule-map-file=/path/to/build/\(triple)/debug/C.build/module.modulemap"]
2122+
["-Xcc", "-I", "-Xcc", .equal(AbsolutePath("/Pkg/Sources/C/include").pathString)],
2123+
["-Xcc", "-fmodule-map-file=\(expectedModuleMap)"]
21252124
)
21262125
}
21272126

21282127
// D
21292128
do {
2129+
let expectedBModuleMap = AbsolutePath("/path/to/build/\(triple)/debug/B.build/module.modulemap").pathString
2130+
let expectedCModuleMap = AbsolutePath("/path/to/build/\(triple)/debug/C.build/module.modulemap").pathString
2131+
let expectedDModuleMap = AbsolutePath("/path/to/build/\(triple)/debug/D.build/module.modulemap").pathString
2132+
let expectedModuleCache = AbsolutePath("/path/to/build/\(triple)/debug/ModuleCache").pathString
21302133
try XCTAssertMatchesSubSequences(
21312134
result.moduleBuildDescription(for: "D").symbolGraphExtractArguments(),
21322135
// Self Module
2133-
["-I", "/Pkg/Sources/D/include"],
2134-
["-Xcc", "-fmodule-map-file=/path/to/build/\(triple)/debug/D.build/module.modulemap"],
2136+
["-I", .equal(AbsolutePath("/Pkg/Sources/D/include").pathString)],
2137+
["-Xcc", "-fmodule-map-file=\(expectedDModuleMap)"],
21352138

21362139
// C Module dependencies
2137-
["-Xcc", "-I", "-Xcc", "/Pkg/Sources/C/include"],
2138-
["-Xcc", "-fmodule-map-file=/path/to/build/\(triple)/debug/C.build/module.modulemap"],
2140+
["-Xcc", "-I", "-Xcc", .equal(AbsolutePath("/Pkg/Sources/C/include").pathString)],
2141+
["-Xcc", "-fmodule-map-file=\(expectedCModuleMap)"],
21392142

21402143
// General Args
21412144
[
21422145
"-Xcc", "-fmodules",
21432146
"-Xcc", "-fmodule-name=D",
2144-
"-Xcc", "-fmodules-cache-path=/path/to/build/\(triple)/debug/ModuleCache",
2147+
"-Xcc", "-fmodules-cache-path=\(expectedModuleCache)",
21452148
]
21462149
)
21472150

21482151
#if os(macOS)
21492152
try XCTAssertMatchesSubSequences(
21502153
result.moduleBuildDescription(for: "D").symbolGraphExtractArguments(),
21512154
// Swift Module dependencies
2152-
["-Xcc", "-fmodule-map-file=/path/to/build/\(triple)/debug/B.build/module.modulemap"]
2155+
["-Xcc", "-fmodule-map-file=\(expectedBModuleMap)"]
21532156
)
21542157
#endif
21552158
}
@@ -4712,8 +4715,6 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
47124715
}
47134716

47144717
func testUserToolchainCompileFlags() async throws {
4715-
try XCTSkipOnWindows()
4716-
47174718
let fs = InMemoryFileSystem(
47184719
emptyFiles:
47194720
"/Pkg/Sources/exe/main.swift",
@@ -4966,8 +4967,6 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
49664967
}
49674968

49684969
func testUserToolchainWithToolsetCompileFlags() async throws {
4969-
try XCTSkipOnWindows(because: "Path delimiters donw's work well on Windows")
4970-
49714970
let fileSystem = InMemoryFileSystem(
49724971
emptyFiles:
49734972
"/Pkg/Sources/exe/main.swift",
@@ -5094,7 +5093,7 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
50945093
let exeCompileArguments = try result.moduleBuildDescription(for: "exe").swift().compileArguments()
50955094
let exeCompileArgumentsPattern: [StringPattern] = [
50965095
jsonFlag(tool: .swiftCompiler),
5097-
"-ld-path=/fake/toolchain/usr/bin/linker",
5096+
"-ld-path=\(AbsolutePath("/fake/toolchain/usr/bin/linker").pathString)",
50985097
"-g", cliFlag(tool: .swiftCompiler),
50995098
.anySequence,
51005099
"-Xcc", jsonFlag(tool: .cCompiler), "-Xcc", "-g", "-Xcc", cliFlag(tool: .cCompiler),
@@ -5119,7 +5118,7 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
51195118
let exeLinkArguments = try result.buildProduct(for: "exe").linkArguments()
51205119
let exeLinkArgumentsPattern: [StringPattern] = [
51215120
jsonFlag(tool: .swiftCompiler),
5122-
"-ld-path=/fake/toolchain/usr/bin/linker",
5121+
"-ld-path=\(AbsolutePath("/fake/toolchain/usr/bin/linker").pathString)",
51235122
"-g", cliFlag(tool: .swiftCompiler),
51245123
.anySequence,
51255124
"-Xlinker", jsonFlag(tool: .linker), "-Xlinker", cliFlag(tool: .linker),
@@ -5136,8 +5135,6 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
51365135
}
51375136

51385137
func testUserToolchainWithSDKSearchPaths() async throws {
5139-
try XCTSkipOnWindows()
5140-
51415138
let fileSystem = InMemoryFileSystem(
51425139
emptyFiles:
51435140
"/Pkg/Sources/exe/main.swift",
@@ -7080,6 +7077,7 @@ class BuildPlanNativeTests: BuildPlanTestCase {
70807077
override func testDuplicateProductNamesWithNonDefaultLibsThrowError() async throws {
70817078
try await super.testDuplicateProductNamesWithNonDefaultLibsThrowError()
70827079
}
7080+
70837081
}
70847082

70857083
class BuildPlanSwiftBuildTests: BuildPlanTestCase {

Tests/BuildTests/PluginsBuildPlanTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import PackageModel
1818

1919
final class PluginsBuildPlanTests: XCTestCase {
2020
func testBuildToolsDatabasePath() async throws {
21-
try XCTSkipOnWindows()
21+
try XCTSkipOnWindows(because: "Fails to build the project to due to incorrect Path handling. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511")
2222

2323
try await fixture(name: "Miscellaneous/Plugins/MySourceGenPlugin") { fixturePath in
2424
let (stdout, _) = try await executeSwiftBuild(fixturePath)

Tests/BuildTests/PrepareForIndexTests.swift

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ import class Basics.ObservabilitySystem
2222
@_spi(DontAdoptOutsideOfSwiftPMExposedForBenchmarksAndTestsOnly)
2323
import func PackageGraph.loadModulesGraph
2424
import class PackageModel.Manifest
25+
import struct PackageGraph.ModulesGraph
2526
import struct PackageModel.TargetDescription
2627

2728
class PrepareForIndexTests: XCTestCase {
2829
func testPrepare() async throws {
29-
try XCTSkipOnWindows()
30+
try XCTSkipOnWindows(because: "coreCommands.count = 0 instead of 1. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511")
3031

3132
let (graph, fs, scope) = try macrosPackageGraph()
3233

@@ -94,18 +95,14 @@ class PrepareForIndexTests: XCTestCase {
9495
XCTAssertTrue(manifest.targets.keys.contains(name))
9596
}
9697

97-
// enable-testing requires the non-exportable-decls, make sure they aren't skipped.
98-
func testEnableTesting() async throws {
99-
try XCTSkipOnWindows()
100-
98+
func testEnableTestingSetup() throws-> (fs: InMemoryFileSystem, observability: TestingObservability, graph: ModulesGraph) {
10199
let fs = InMemoryFileSystem(
102100
emptyFiles:
103101
"/Pkg/Sources/lib/lib.swift",
104102
"/Pkg/Tests/test/TestCase.swift"
105103
)
106104

107105
let observability = ObservabilitySystem.makeForTesting()
108-
let scope = observability.topScope
109106

110107
let graph = try loadModulesGraph(
111108
fileSystem: fs,
@@ -119,8 +116,16 @@ class PrepareForIndexTests: XCTestCase {
119116
]
120117
),
121118
],
122-
observabilityScope: scope
119+
observabilityScope: observability.topScope
123120
)
121+
return (fs, observability, graph)
122+
}
123+
124+
func testEnableTestingDebugConfiguration() async throws {
125+
// enable-testing requires the non-exportable-decls, make sure they aren't skipped.
126+
let (fs, observability, graph) = try self.testEnableTestingSetup()
127+
let scope = observability.topScope
128+
124129
XCTAssertNoDiagnostics(observability.diagnostics)
125130

126131
// Under debug, enable-testing is turned on by default. Make sure the flag is not added.
@@ -143,6 +148,17 @@ class PrepareForIndexTests: XCTestCase {
143148
return swiftCommand.otherArguments.contains("-experimental-skip-non-exportable-decls")
144149
&& !swiftCommand.otherArguments.contains("-enable-testing")
145150
}))
151+
}
152+
153+
func testEnableTestingReleaseConfiguration() async throws {
154+
try XCTSkipOnWindows(because: """
155+
Assertion failure. ("0") is not equal to ("1"). Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511
156+
""")
157+
158+
let (fs, observability, graph) = try self.testEnableTestingSetup()
159+
let scope = observability.topScope
160+
161+
XCTAssertNoDiagnostics(observability.diagnostics)
146162

147163
// Under release, enable-testing is turned off by default so we should see our flag
148164
let releasePlan = try await BuildPlan(
@@ -167,7 +183,7 @@ class PrepareForIndexTests: XCTestCase {
167183
}
168184

169185
func testPrepareNoLazy() async throws {
170-
try XCTSkipOnWindows()
186+
try XCTSkipOnWindows(because: "coreCommands.count = 0 instead of 1. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511")
171187

172188
let (graph, fs, scope) = try macrosPackageGraph()
173189

0 commit comments

Comments
 (0)