Skip to content

Commit baba429

Browse files
authored
Tests: Skip failing tests on windows (#8210)
The Pipelines do not currently test on windows platform. To get to a point where we can execute tests on windows, we will first disable the failing tests and later enable them as the pipeline is setup to ensure we do not regress in behaviour. related to #8121 rdar://139977454 ### Motivation: In preparation for #8176 , disable failing Windows tests. ### Modifications: Mark some tests as Skipped on Windows Fixes #8176
1 parent cb4ba47 commit baba429

32 files changed

+657
-66
lines changed

IntegrationTests/Tests/IntegrationTests/BasicTests.swift

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import TSCBasic
1414
import TSCTestSupport
1515
@Suite
1616
private struct BasicTests {
17-
@Test
17+
@Test(
18+
.skipHostOS(.windows, "'try!' expression unexpectedly raised an error: TSCBasic.Process.Error.missingExecutableProgram(program: \"which\")")
19+
)
1820
func testVersion() throws {
1921
#expect(try sh(swift, "--version").stdout.contains("Swift version"))
2022
}
@@ -82,13 +84,15 @@ private struct BasicTests {
8284
#expect(try #/swiftc.* -module-name tool/#.firstMatch(in: buildOutput) != nil)
8385

8486
// Verify that the tool exists and works.
85-
let toolOutput = try sh(packagePath.appending(components: ".build", "debug", "tool"))
86-
.stdout
87-
#expect(toolOutput == "HI\n")
87+
let toolOutput = try sh(packagePath.appending(components: ".build", "debug", "tool")).stdout
88+
#expect(toolOutput.contains("HI"))
89+
#expect(toolOutput.contains("\n"))
8890
}
8991
}
9092

91-
@Test
93+
@Test(
94+
.skipHostOS(.windows, "'try!' expression unexpectedly raised an error: TSCBasic.Process.Error.missingExecutableProgram(program: \"which\")"),
95+
)
9296
func testSwiftCompiler() throws {
9397
try withTemporaryDirectory { tempDir in
9498
let helloSourcePath = tempDir.appending(component: "hello.swift")
@@ -108,7 +112,9 @@ private struct BasicTests {
108112
}
109113
}
110114

111-
@Test
115+
@Test(
116+
.skipHostOS(.windows, "failed to build package")
117+
)
112118
func testSwiftPackageInitExec() throws {
113119
try withTemporaryDirectory { tempDir in
114120
// Create a new package with an executable target.
@@ -195,7 +201,9 @@ private struct BasicTests {
195201
}
196202
}
197203

198-
@Test
204+
@Test(
205+
.skipHostOS(.windows, "unexpected failure matching")
206+
)
199207
func testSwiftPackageWithSpaces() throws {
200208
try withTemporaryDirectory { tempDir in
201209
let packagePath = tempDir.appending(components: "more spaces", "special tool")
@@ -241,7 +249,9 @@ private struct BasicTests {
241249
}
242250
}
243251

244-
@Test
252+
@Test(
253+
.skipHostOS(.windows, "package fails to build")
254+
)
245255
func testSwiftRun() throws {
246256
try withTemporaryDirectory { tempDir in
247257
let packagePath = tempDir.appending(component: "secho")

IntegrationTests/Tests/IntegrationTests/SwiftPMTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ private struct SwiftPMTests {
6868
}
6969
}
7070

71-
@Test(.requireThreadSafeWorkingDirectory)
71+
@Test(
72+
.requireThreadSafeWorkingDirectory
73+
)
7274
func packageInitExecutable() throws {
7375
// Executable
7476
do {

Sources/_InternalTestSupport/misc.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import struct SPMBuildCore.BuildParameters
2929
import TSCTestSupport
3030
import Workspace
3131
import func XCTest.XCTFail
32+
import struct XCTest.XCTSkip
3233

3334
import struct TSCBasic.ByteString
3435
import struct Basics.AsyncProcessResult
@@ -276,6 +277,18 @@ public func executeSwiftBuild(
276277
return try await SwiftPM.Build.execute(args, packagePath: packagePath, env: env)
277278
}
278279

280+
public func skipOnWindowsAsTestCurrentlyFails(because reason: String? = nil) throws {
281+
#if os(Windows)
282+
let failureCause: String
283+
if let reason {
284+
failureCause = " because \(reason.description)"
285+
} else {
286+
failureCause = ""
287+
}
288+
throw XCTSkip("Test fails on windows\(failureCause)")
289+
#endif
290+
}
291+
279292
@discardableResult
280293
public func executeSwiftRun(
281294
_ packagePath: AbsolutePath?,

Tests/BasicsTests/AsyncProcessTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ import func TSCBasic.withTemporaryFile
2323
import func TSCTestSupport.withCustomEnv
2424

2525
final class AsyncProcessTests: XCTestCase {
26+
27+
override func setUp() async throws {
28+
try skipOnWindowsAsTestCurrentlyFails()
29+
}
30+
2631
func testBasics() throws {
2732
do {
2833
let process = AsyncProcess(args: "echo", "hello")

Tests/BasicsTests/ConcurrencyHelpersTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@
1414
import TSCTestSupport
1515
import XCTest
1616

17+
import _InternalTestSupport // for skipOnWindowsAsTestCurrentlyFails
18+
1719
final class ConcurrencyHelpersTest: XCTestCase {
1820
let queue = DispatchQueue(label: "ConcurrencyHelpersTest", attributes: .concurrent)
1921

22+
override func setUpWithError() throws {
23+
try skipOnWindowsAsTestCurrentlyFails()
24+
}
25+
2026
func testThreadSafeKeyValueStore() {
2127
for _ in 0 ..< 100 {
2228
let sync = DispatchGroup()

Tests/BasicsTests/Environment/EnvironmentTests.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import Basics
1616

1717
import XCTest
18+
import _InternalTestSupport // for skipOnWindowsAsTestCurrentlyFails()
1819

1920
final class EnvironmentTests: XCTestCase {
2021
func test_init() {
@@ -36,7 +37,7 @@ final class EnvironmentTests: XCTestCase {
3637
]
3738
let environment = Environment(dictionary)
3839
#if os(Windows)
39-
XCTAssertEqual(environment["TestKey"], "TestValue2") // uppercase sorts before lowercase, so the second value overwrites the first
40+
XCTAssertEqual(environment["TestKey"], "TestValue2")
4041
XCTAssertEqual(environment.count, 1)
4142
#else
4243
XCTAssertEqual(environment["TestKey"], "TestValue")
@@ -48,6 +49,7 @@ final class EnvironmentTests: XCTestCase {
4849
let dictionary = ["TestKey": "TestValue"]
4950
let environment = Environment(dictionary)
5051
XCTAssertEqual(environment["TestKey"], "TestValue")
52+
XCTAssertEqual(environment.count, 1)
5153
}
5254

5355
func path(_ components: String...) -> String {
@@ -100,10 +102,20 @@ final class EnvironmentTests: XCTestCase {
100102

101103
/// Important: This test is inherently race-prone, if it is proven to be
102104
/// flaky, it should run in a singled threaded environment/removed entirely.
103-
func test_current() {
105+
func test_current() throws {
106+
try skipOnWindowsAsTestCurrentlyFails(because: "ProcessInfo.processInfo.environment[pathEnvVarName] return nil in the docker container")
107+
108+
#if os(Windows)
109+
let pathEnvVarName = "Path"
110+
#else
111+
let pathEnvVarName = "PATH"
112+
#endif
113+
114+
104115
XCTAssertEqual(
105116
Environment.current["PATH"],
106-
ProcessInfo.processInfo.environment["PATH"])
117+
ProcessInfo.processInfo.environment[pathEnvVarName]
118+
)
107119
}
108120

109121
/// Important: This test is inherently race-prone, if it is proven to be

Tests/BasicsTests/FileSystem/PathTests.swift

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import Basics
1212
import Foundation
1313
import XCTest
1414

15+
import _InternalTestSupport // for skipOnWindowsAsTestCurrentlyFails()
16+
1517
#if os(Windows)
1618
private var windows: Bool { true }
1719
#else
@@ -54,28 +56,36 @@ class PathTests: XCTestCase {
5456
XCTAssertEqual(rel2.pathString, "~") // `~` is not special
5557
}
5658

57-
func testRepeatedPathSeparators() {
59+
func testRepeatedPathSeparators() throws {
60+
try skipOnWindowsAsTestCurrentlyFails(because: "all assertions fail")
61+
5862
XCTAssertEqual(AbsolutePath("/ab//cd//ef").pathString, windows ? #"\ab\cd\ef"# : "/ab/cd/ef")
5963
XCTAssertEqual(AbsolutePath("/ab///cd//ef").pathString, windows ? #"\ab\cd\ef"# : "/ab/cd/ef")
6064
XCTAssertEqual(RelativePath("ab//cd//ef").pathString, windows ? #"ab\cd\ef"# : "ab/cd/ef")
6165
XCTAssertEqual(RelativePath("ab//cd///ef").pathString, windows ? #"ab\cd\ef"# : "ab/cd/ef")
6266
}
6367

64-
func testTrailingPathSeparators() {
68+
func testTrailingPathSeparators() throws {
69+
try skipOnWindowsAsTestCurrentlyFails(because: "trailing path seperator is not removed from pathString")
70+
6571
XCTAssertEqual(AbsolutePath("/ab/cd/ef/").pathString, windows ? #"\ab\cd\ef"# : "/ab/cd/ef")
6672
XCTAssertEqual(AbsolutePath("/ab/cd/ef//").pathString, windows ? #"\ab\cd\ef"# : "/ab/cd/ef")
6773
XCTAssertEqual(RelativePath("ab/cd/ef/").pathString, windows ? #"ab\cd\ef"# : "ab/cd/ef")
6874
XCTAssertEqual(RelativePath("ab/cd/ef//").pathString, windows ? #"ab\cd\ef"# : "ab/cd/ef")
6975
}
7076

71-
func testDotPathComponents() {
77+
func testDotPathComponents() throws {
78+
try skipOnWindowsAsTestCurrentlyFails()
79+
7280
XCTAssertEqual(AbsolutePath("/ab/././cd//ef").pathString, "/ab/cd/ef")
7381
XCTAssertEqual(AbsolutePath("/ab/./cd//ef/.").pathString, "/ab/cd/ef")
7482
XCTAssertEqual(RelativePath("ab/./cd/././ef").pathString, "ab/cd/ef")
7583
XCTAssertEqual(RelativePath("ab/./cd/ef/.").pathString, "ab/cd/ef")
7684
}
7785

78-
func testDotDotPathComponents() {
86+
func testDotDotPathComponents() throws {
87+
try skipOnWindowsAsTestCurrentlyFails()
88+
7989
XCTAssertEqual(AbsolutePath("/..").pathString, windows ? #"\"# : "/")
8090
XCTAssertEqual(AbsolutePath("/../../../../..").pathString, windows ? #"\"# : "/")
8191
XCTAssertEqual(AbsolutePath("/abc/..").pathString, windows ? #"\"# : "/")
@@ -91,7 +101,9 @@ class PathTests: XCTestCase {
91101
XCTAssertEqual(RelativePath("abc/..").pathString, ".")
92102
}
93103

94-
func testCombinationsAndEdgeCases() {
104+
func testCombinationsAndEdgeCases() throws {
105+
try skipOnWindowsAsTestCurrentlyFails()
106+
95107
XCTAssertEqual(AbsolutePath("///").pathString, windows ? #"\"# : "/")
96108
XCTAssertEqual(AbsolutePath("/./").pathString, windows ? #"\"# : "/")
97109
XCTAssertEqual(RelativePath("").pathString, ".")
@@ -120,7 +132,9 @@ class PathTests: XCTestCase {
120132
XCTAssertEqual(RelativePath("a/../////../////./////").pathString, "..")
121133
}
122134

123-
func testDirectoryNameExtraction() {
135+
func testDirectoryNameExtraction() throws {
136+
try skipOnWindowsAsTestCurrentlyFails()
137+
124138
XCTAssertEqual(AbsolutePath("/").dirname, windows ? #"\"# : "/")
125139
XCTAssertEqual(AbsolutePath("/a").dirname, windows ? #"\"# : "/")
126140
XCTAssertEqual(AbsolutePath("/./a").dirname, windows ? #"\"# : "/")
@@ -137,7 +151,9 @@ class PathTests: XCTestCase {
137151
XCTAssertEqual(RelativePath(".").dirname, ".")
138152
}
139153

140-
func testBaseNameExtraction() {
154+
func testBaseNameExtraction() throws {
155+
try skipOnWindowsAsTestCurrentlyFails()
156+
141157
XCTAssertEqual(AbsolutePath("/").basename, windows ? #"\"# : "/")
142158
XCTAssertEqual(AbsolutePath("/a").basename, "a")
143159
XCTAssertEqual(AbsolutePath("/./a").basename, "a")
@@ -153,7 +169,9 @@ class PathTests: XCTestCase {
153169
XCTAssertEqual(RelativePath(".").basename, ".")
154170
}
155171

156-
func testBaseNameWithoutExt() {
172+
func testBaseNameWithoutExt() throws{
173+
try skipOnWindowsAsTestCurrentlyFails()
174+
157175
XCTAssertEqual(AbsolutePath("/").basenameWithoutExt, windows ? #"\"# : "/")
158176
XCTAssertEqual(AbsolutePath("/a").basenameWithoutExt, "a")
159177
XCTAssertEqual(AbsolutePath("/./a").basenameWithoutExt, "a")
@@ -176,7 +194,9 @@ class PathTests: XCTestCase {
176194
XCTAssertEqual(RelativePath("abc.xyz.123").basenameWithoutExt, "abc.xyz")
177195
}
178196

179-
func testSuffixExtraction() {
197+
func testSuffixExtraction() throws {
198+
try skipOnWindowsAsTestCurrentlyFails(because: "expected nil is not the actual")
199+
180200
XCTAssertEqual(RelativePath("a").suffix, nil)
181201
XCTAssertEqual(RelativePath("a").extension, nil)
182202
XCTAssertEqual(RelativePath("a.").suffix, nil)
@@ -201,7 +221,9 @@ class PathTests: XCTestCase {
201221
XCTAssertEqual(RelativePath(".a.foo.bar.baz").extension, "baz")
202222
}
203223

204-
func testParentDirectory() {
224+
func testParentDirectory() throws {
225+
try skipOnWindowsAsTestCurrentlyFails()
226+
205227
XCTAssertEqual(AbsolutePath("/").parentDirectory, AbsolutePath("/"))
206228
XCTAssertEqual(AbsolutePath("/").parentDirectory.parentDirectory, AbsolutePath("/"))
207229
XCTAssertEqual(AbsolutePath("/bar").parentDirectory, AbsolutePath("/"))
@@ -210,7 +232,9 @@ class PathTests: XCTestCase {
210232
}
211233

212234
@available(*, deprecated)
213-
func testConcatenation() {
235+
func testConcatenation() throws {
236+
try skipOnWindowsAsTestCurrentlyFails()
237+
214238
XCTAssertEqual(AbsolutePath(AbsolutePath("/"), RelativePath("")).pathString, windows ? #"\"# : "/")
215239
XCTAssertEqual(AbsolutePath(AbsolutePath("/"), RelativePath(".")).pathString, windows ? #"\"# : "/")
216240
XCTAssertEqual(AbsolutePath(AbsolutePath("/"), RelativePath("..")).pathString, windows ? #"\"# : "/")
@@ -247,7 +271,9 @@ class PathTests: XCTestCase {
247271
XCTAssertEqual(RelativePath("hello").appending(RelativePath("a/b/../c/d")).pathString, windows ? #"hello\a\c\d"# : "hello/a/c/d")
248272
}
249273

250-
func testPathComponents() {
274+
func testPathComponents() throws {
275+
try skipOnWindowsAsTestCurrentlyFails()
276+
251277
XCTAssertEqual(AbsolutePath("/").components, ["/"])
252278
XCTAssertEqual(AbsolutePath("/.").components, ["/"])
253279
XCTAssertEqual(AbsolutePath("/..").components, ["/"])
@@ -275,7 +301,9 @@ class PathTests: XCTestCase {
275301
XCTAssertEqual(RelativePath("abc").components, ["abc"])
276302
}
277303

278-
func testRelativePathFromAbsolutePaths() {
304+
func testRelativePathFromAbsolutePaths() throws {
305+
try skipOnWindowsAsTestCurrentlyFails()
306+
279307
XCTAssertEqual(AbsolutePath("/").relative(to: AbsolutePath("/")), RelativePath("."));
280308
XCTAssertEqual(AbsolutePath("/a/b/c/d").relative(to: AbsolutePath("/")), RelativePath("a/b/c/d"));
281309
XCTAssertEqual(AbsolutePath("/").relative(to: AbsolutePath("/a/b/c")), RelativePath("../../.."));
@@ -316,7 +344,9 @@ class PathTests: XCTestCase {
316344
XCTAssertTrue(AbsolutePath("/foo").isAncestor(of: AbsolutePath("/foo/bar")))
317345
}
318346

319-
func testAbsolutePathValidation() {
347+
func testAbsolutePathValidation() throws {
348+
try skipOnWindowsAsTestCurrentlyFails()
349+
320350
XCTAssertNoThrow(try AbsolutePath(validating: "/a/b/c/d"))
321351

322352
XCTAssertThrowsError(try AbsolutePath(validating: "~/a/b/d")) { error in
@@ -328,7 +358,9 @@ class PathTests: XCTestCase {
328358
}
329359
}
330360

331-
func testRelativePathValidation() {
361+
func testRelativePathValidation() throws {
362+
try skipOnWindowsAsTestCurrentlyFails()
363+
332364
XCTAssertNoThrow(try RelativePath(validating: "a/b/c/d"))
333365

334366
XCTAssertThrowsError(try RelativePath(validating: "/a/b/d")) { error in
@@ -342,6 +374,8 @@ class PathTests: XCTestCase {
342374
}
343375

344376
func testCodable() throws {
377+
try skipOnWindowsAsTestCurrentlyFails()
378+
345379
struct Foo: Codable, Equatable {
346380
var path: AbsolutePath
347381
}

Tests/BasicsTests/FileSystem/VFSTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import XCTest
1616

1717
import struct TSCBasic.ByteString
1818

19+
import _InternalTestSupport // for skipOnWindowsAsTestCurrentlyFails
20+
1921
func testWithTemporaryDirectory(
2022
function: StaticString = #function,
2123
body: @escaping (AbsolutePath) async throws -> Void
@@ -36,6 +38,8 @@ func testWithTemporaryDirectory(
3638

3739
class VFSTests: XCTestCase {
3840
func testLocalBasics() throws {
41+
try skipOnWindowsAsTestCurrentlyFails()
42+
3943
// tiny PE binary from: https://archive.is/w01DO
4044
let contents: [UInt8] = [
4145
0x4d, 0x5a, 0x00, 0x00, 0x50, 0x45, 0x00, 0x00, 0x4c, 0x01, 0x01, 0x00,

Tests/BasicsTests/HTTPClientTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ final class HTTPClientTests: XCTestCase {
226226
}
227227

228228
func testExponentialBackoff() async throws {
229+
try skipOnWindowsAsTestCurrentlyFails()
230+
229231
let counter = SendableBox(0)
230232
let lastCall = SendableBox<Date>()
231233
let maxAttempts = 5

Tests/BasicsTests/LegacyHTTPClientTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,9 @@ final class LegacyHTTPClientTests: XCTestCase {
349349
wait(for: [promise], timeout: 1)
350350
}
351351

352-
func testExponentialBackoff() {
352+
func testExponentialBackoff() throws {
353+
try skipOnWindowsAsTestCurrentlyFails()
354+
353355
let count = ThreadSafeBox<Int>(0)
354356
let lastCall = ThreadSafeBox<Date>()
355357
let maxAttempts = 5

0 commit comments

Comments
 (0)