Skip to content

Commit 2d48848

Browse files
authored
Re-enable tests in Windows CI (#8562)
The investigation is pointing to running git commands in parallel that is causing the hang with the Windows CI. Turn them off until we can figure out how to serialize them across xctest processes. Once they completed, fixed the BuildPlanTests which were matching with backslashes. Also had backslash issues when launching the integration tests. ---------
1 parent a16474a commit 2d48848

File tree

5 files changed

+53
-15
lines changed

5 files changed

+53
-15
lines changed

Sources/_InternalTestSupport/XCTAssertHelpers.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,20 @@ public func XCTAssertEqual<T:Equatable, U:Equatable> (_ lhs:(T,U), _ rhs:(T,U),
4545
}
4646

4747
public func XCTSkipIfCI(file: StaticString = #filePath, line: UInt = #line) throws {
48+
// TODO: is this actually the right variable now?
4849
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] != nil {
4950
throw XCTSkip("Skipping because the test is being run on CI", file: file, line: line)
5051
}
5152
}
5253

54+
public func XCTSkipIfWindowsCI(file: StaticString = #filePath, line: UInt = #line) throws {
55+
#if os(Windows)
56+
if ProcessInfo.processInfo.environment["SWIFTCI_IS_SELF_HOSTED"] != nil {
57+
throw XCTSkip("Skipping because the test is being run on CI", file: file, line: line)
58+
}
59+
#endif
60+
}
61+
5362
/// An `async`-friendly replacement for `XCTAssertThrowsError`.
5463
public func XCTAssertAsyncThrowsError<T>(
5564
_ expression: @autoclosure () async throws -> T,

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7033,7 +7033,8 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
70337033
let fileMap = try String(bytes: fs.readFileContents(file.path).contents, encoding: .utf8)
70347034

70357035
for diagnosticFile in buildDescription.diagnosticFiles {
7036-
XCTAssertMatch(fileMap, .contains(diagnosticFile.pathString))
7036+
let fileName = diagnosticFile.pathString.replacingOccurrences(of: "\\", with: "\\\\")
7037+
XCTAssertMatch(fileMap, .contains(fileName))
70377038
}
70387039
}
70397040
}

Tests/SourceControlTests/GitRepositoryProviderTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import XCTest
1717

1818
class GitRepositoryProviderTests: XCTestCase {
1919
func testIsValidDirectory() throws {
20+
// Skipping all tests that call git on Windows.
21+
// We have a hang in CI when running in parallel.
22+
try XCTSkipIfWindowsCI()
2023
try testWithTemporaryDirectory { sandbox in
2124
let provider = GitRepositoryProvider()
2225

@@ -42,6 +45,7 @@ class GitRepositoryProviderTests: XCTestCase {
4245
}
4346

4447
func testIsValidDirectoryThrowsPrintableError() throws {
48+
try XCTSkipIfWindowsCI()
4549
try testWithTemporaryDirectory { temp in
4650
let provider = GitRepositoryProvider()
4751
let expectedErrorMessage = "not a git repository"
@@ -56,6 +60,7 @@ class GitRepositoryProviderTests: XCTestCase {
5660
}
5761

5862
func testGitShellErrorIsPrintable() throws {
63+
try XCTSkipIfWindowsCI()
5964
let stdOut = "An error from Git - stdout"
6065
let stdErr = "An error from Git - stderr"
6166
let arguments = ["git", "error"]
@@ -84,6 +89,7 @@ class GitRepositoryProviderTests: XCTestCase {
8489
}
8590

8691
func testGitShellErrorEmptyStdOut() throws {
92+
try XCTSkipIfWindowsCI()
8793
let stdErr = "An error from Git - stderr"
8894
let result = AsyncProcessResult(
8995
arguments: ["git", "error"],
@@ -101,6 +107,7 @@ class GitRepositoryProviderTests: XCTestCase {
101107
}
102108

103109
func testGitShellErrorEmptyStdErr() throws {
110+
try XCTSkipIfWindowsCI()
104111
let stdOut = "An error from Git - stdout"
105112
let result = AsyncProcessResult(
106113
arguments: ["git", "error"],

Tests/SourceControlTests/GitRepositoryTests.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class GitRepositoryTests: XCTestCase {
6262

6363
/// Test the basic provider functions.
6464
func testProvider() throws {
65+
// Skipping all tests that call git on Windows.
66+
// We have a hang in CI when running in parallel.
67+
try XCTSkipIfWindowsCI()
6568
try testWithTemporaryDirectory { path in
6669
let testRepoPath = path.appending("test-repo")
6770
try! makeDirectories(testRepoPath)
@@ -127,6 +130,7 @@ class GitRepositoryTests: XCTestCase {
127130
/// contained within it for more information.
128131
func testRawRepository() throws {
129132
try skipOnWindowsAsTestCurrentlyFails(because: "https://github.com/swiftlang/swift-package-manager/issues/8385: test repository has non-portable file names")
133+
try XCTSkipIfWindowsCI()
130134

131135
try testWithTemporaryDirectory { path in
132136
// Unarchive the static test repository.
@@ -186,6 +190,7 @@ class GitRepositoryTests: XCTestCase {
186190
}
187191

188192
func testSubmoduleRead() throws {
193+
try XCTSkipIfWindowsCI()
189194
try testWithTemporaryDirectory { path in
190195
let testRepoPath = path.appending("test-repo")
191196
try makeDirectories(testRepoPath)
@@ -209,6 +214,7 @@ class GitRepositoryTests: XCTestCase {
209214

210215
/// Test the Git file system view.
211216
func testGitFileView() throws {
217+
try XCTSkipIfWindowsCI()
212218
try testWithTemporaryDirectory { path in
213219
let testRepoPath = path.appending("test-repo")
214220
try makeDirectories(testRepoPath)
@@ -297,6 +303,7 @@ class GitRepositoryTests: XCTestCase {
297303

298304
/// Test the handling of local checkouts.
299305
func testCheckouts() throws {
306+
try XCTSkipIfWindowsCI()
300307
try testWithTemporaryDirectory { path in
301308
// Create a test repository.
302309
let testRepoPath = path.appending("test-repo")
@@ -343,6 +350,7 @@ class GitRepositoryTests: XCTestCase {
343350
}
344351

345352
func testFetch() throws {
353+
try XCTSkipIfWindowsCI()
346354
try testWithTemporaryDirectory { path in
347355
// Create a repo.
348356
let testRepoPath = path.appending("test-repo")
@@ -382,6 +390,7 @@ class GitRepositoryTests: XCTestCase {
382390
}
383391

384392
func testHasUnpushedCommits() throws {
393+
try XCTSkipIfWindowsCI()
385394
try testWithTemporaryDirectory { path in
386395
// Create a repo.
387396
let testRepoPath = path.appending("test-repo")
@@ -418,6 +427,7 @@ class GitRepositoryTests: XCTestCase {
418427
}
419428

420429
func testSetRemote() throws {
430+
try XCTSkipIfWindowsCI()
421431
try testWithTemporaryDirectory { path in
422432
// Create a repo.
423433
let testRepoPath = path.appending("test-repo")
@@ -448,6 +458,7 @@ class GitRepositoryTests: XCTestCase {
448458
}
449459

450460
func testUncommittedChanges() throws {
461+
try XCTSkipIfWindowsCI()
451462
try testWithTemporaryDirectory { path in
452463
// Create a repo.
453464
let testRepoPath = path.appending("test-repo")
@@ -475,6 +486,7 @@ class GitRepositoryTests: XCTestCase {
475486
}
476487

477488
func testBranchOperations() throws {
489+
try XCTSkipIfWindowsCI()
478490
try testWithTemporaryDirectory { path in
479491
// Create a repo.
480492
let testRepoPath = path.appending("test-repo")
@@ -505,6 +517,7 @@ class GitRepositoryTests: XCTestCase {
505517
}
506518

507519
func testRevisionOperations() throws {
520+
try XCTSkipIfWindowsCI()
508521
try testWithTemporaryDirectory { path in
509522
// Create a repo.
510523
let repositoryPath = path.appending("test-repo")
@@ -530,6 +543,7 @@ class GitRepositoryTests: XCTestCase {
530543
}
531544

532545
func testCheckoutRevision() throws {
546+
try XCTSkipIfWindowsCI()
533547
try testWithTemporaryDirectory { path in
534548
// Create a repo.
535549
let testRepoPath = path.appending("test-repo")
@@ -573,6 +587,7 @@ class GitRepositoryTests: XCTestCase {
573587
}
574588

575589
func testSubmodules() throws {
590+
try XCTSkipIfWindowsCI()
576591
try testWithTemporaryDirectory { path in
577592
let provider = GitRepositoryProvider()
578593

@@ -662,6 +677,7 @@ class GitRepositoryTests: XCTestCase {
662677
}
663678

664679
func testAlternativeObjectStoreValidation() throws {
680+
try XCTSkipIfWindowsCI()
665681
try testWithTemporaryDirectory { path in
666682
// Create a repo.
667683
let testRepoPath = path.appending("test-repo")
@@ -695,6 +711,7 @@ class GitRepositoryTests: XCTestCase {
695711
}
696712

697713
func testAreIgnored() throws {
714+
try XCTSkipIfWindowsCI()
698715
try testWithTemporaryDirectory { path in
699716
// Create a repo.
700717
let testRepoPath = path.appending("test_repo")
@@ -716,6 +733,7 @@ class GitRepositoryTests: XCTestCase {
716733
}
717734

718735
func testAreIgnoredWithSpaceInRepoPath() throws {
736+
try XCTSkipIfWindowsCI()
719737
try testWithTemporaryDirectory { path in
720738
// Create a repo.
721739
let testRepoPath = path.appending("test repo")
@@ -732,6 +750,7 @@ class GitRepositoryTests: XCTestCase {
732750
}
733751

734752
func testMissingDefaultBranch() throws {
753+
try XCTSkipIfWindowsCI()
735754
try testWithTemporaryDirectory { path in
736755
// Create a repository.
737756
let testRepoPath = path.appending("test-repo")
@@ -769,6 +788,7 @@ class GitRepositoryTests: XCTestCase {
769788
}
770789

771790
func testValidDirectoryLocalRelativeOrigin() async throws {
791+
try XCTSkipIfWindowsCI()
772792
try testWithTemporaryDirectory { tmpDir in
773793
// Create a repository.
774794
let packageDir = tmpDir.appending("SomePackage")
@@ -815,6 +835,7 @@ class GitRepositoryTests: XCTestCase {
815835
}
816836

817837
func testValidDirectoryLocalAbsoluteOrigin() async throws {
838+
try XCTSkipIfWindowsCI()
818839
try testWithTemporaryDirectory { tmpDir in
819840
// Create a repository.
820841
let packageDir = tmpDir.appending("SomePackage")
@@ -865,6 +886,7 @@ class GitRepositoryTests: XCTestCase {
865886
}
866887

867888
func testValidDirectoryRemoteOrigin() async throws {
889+
try XCTSkipIfWindowsCI()
868890
try testWithTemporaryDirectory { tmpDir in
869891
// Create a repository.
870892
let packageDir = tmpDir.appending("SomePackage")

Utilities/build-using-self

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,19 @@ def main() -> None:
152152
shlex.split(f"swift build --configuration {args.config} {ignore}"),
153153
)
154154

155-
if os.name != "nt": # turn off for Windows until we get the hang resolved
156-
swift_testing_arg= "--enable-swift-testing" if args.enable_swift_testing else ""
157-
xctest_arg= "--enable-xctest" if args.enable_swift_testing else ""
158-
call(
159-
shlex.split(f"swift run swift-test --configuration {args.config} --parallel {swift_testing_arg} {xctest_arg} --scratch-path .test {ignore}"),
160-
)
161-
162-
integration_test_dir = REPO_ROOT_PATH / "IntegrationTests"
163-
call(
164-
shlex.split(f"swift package --package-path {integration_test_dir} update"),
165-
)
166-
call(
167-
shlex.split(f"swift run swift-test --package-path {integration_test_dir} --parallel {ignore}"),
168-
)
155+
swift_testing_arg= "--enable-swift-testing" if args.enable_swift_testing else ""
156+
xctest_arg= "--enable-xctest" if args.enable_swift_testing else ""
157+
call(
158+
shlex.split(f"swift run swift-test --configuration {args.config} --parallel {swift_testing_arg} {xctest_arg} --scratch-path .test {ignore}"),
159+
)
160+
161+
integration_test_dir = (REPO_ROOT_PATH / "IntegrationTests").as_posix()
162+
call(
163+
shlex.split(f"swift package --package-path {integration_test_dir} update"),
164+
)
165+
call(
166+
shlex.split(f"swift run swift-test --package-path {integration_test_dir} --parallel {ignore}"),
167+
)
169168

170169
if is_on_darwin():
171170
run_bootstrap(swiftpm_bin_dir=swiftpm_bin_dir)

0 commit comments

Comments
 (0)