Skip to content

Tests: Skip failing tests on windows #8210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b7b9cd4
Tests: Skip failing tests on windows
bkhouri Jan 10, 2025
9df2963
Update skipped reason string to more idiomatic code
bkhouri Jan 12, 2025
7669801
Update EnBasicsTests.EnvironmentTests.test_current to support Windows
bkhouri Jan 23, 2025
09a6835
Skip more tests on Windows
bkhouri Jan 23, 2025
2bcc38c
remove accidentally committed XML file
bkhouri Feb 11, 2025
889e57d
Update WorkspaceTest setup to only execute passing tests on wndows, w…
bkhouri Feb 13, 2025
fab90af
some changes
bkhouri Feb 17, 2025
dcf82c8
Disable more tests on Windows
bkhouri Feb 27, 2025
d2c0d1b
Merge branch 'main' into t/main/gh8121_radar139977454_swift_test_on_w…
bkhouri Mar 17, 2025
b111099
Add missing import
bkhouri Mar 17, 2025
b3a2e58
Skip more tests on Windows, and fix SourceKitLSPAPITests.SourceKitLSP…
bkhouri Mar 17, 2025
562eb67
Update build-using-self to properly convert Windows paths
bkhouri Mar 17, 2025
293fc93
some changes, including executing tests sequentially
bkhouri Mar 18, 2025
5d45f31
Merge branch 'main' into t/main/gh8121_radar139977454_swift_test_on_w…
bkhouri Mar 18, 2025
409fd59
properly import XCTest.XCTSkip in misc.swift
bkhouri Mar 18, 2025
ff6f573
Skip some IntegrationTests on Windows and fix one to work on Windows
bkhouri Mar 19, 2025
d44947c
Run all tests in parallel
bkhouri Mar 19, 2025
35650b9
emit a log message at the end indicating we are done and move the is_…
bkhouri Mar 19, 2025
cac0645
Skip test that might hang in CI
bkhouri Mar 19, 2025
9c7bba5
Merge remote-tracking branch 'upstream/main' into t/main/gh8121_radar…
bkhouri Mar 19, 2025
7701fa4
Merge branch 'main' into t/main/gh8121_radar139977454_swift_test_on_w…
bkhouri Mar 24, 2025
9e67e58
fix compilation error
bkhouri Mar 24, 2025
cb2efe0
Merge remote-tracking branch 'upstream/main' into t/main/gh8121_radar…
bkhouri Mar 27, 2025
64a73e7
disable more tests on windows
bkhouri Mar 27, 2025
9e8b423
fix compilation error
bkhouri Mar 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions IntegrationTests/Tests/IntegrationTests/BasicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import TSCBasic
import TSCTestSupport
@Suite
private struct BasicTests {
@Test
@Test(
.skipHostOS(.windows, "'try!' expression unexpectedly raised an error: TSCBasic.Process.Error.missingExecutableProgram(program: \"which\")")
)
func testVersion() throws {
#expect(try sh(swift, "--version").stdout.contains("Swift version"))
}
Expand Down Expand Up @@ -82,13 +84,15 @@ private struct BasicTests {
#expect(try #/swiftc.* -module-name tool/#.firstMatch(in: buildOutput) != nil)

// Verify that the tool exists and works.
let toolOutput = try sh(packagePath.appending(components: ".build", "debug", "tool"))
.stdout
#expect(toolOutput == "HI\n")
let toolOutput = try sh(packagePath.appending(components: ".build", "debug", "tool")).stdout
#expect(toolOutput.contains("HI"))
#expect(toolOutput.contains("\n"))
}
}

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

@Test
@Test(
.skipHostOS(.windows, "failed to build package")
)
func testSwiftPackageInitExec() throws {
try withTemporaryDirectory { tempDir in
// Create a new package with an executable target.
Expand Down Expand Up @@ -195,7 +201,9 @@ private struct BasicTests {
}
}

@Test
@Test(
.skipHostOS(.windows, "unexpected failure matching")
)
func testSwiftPackageWithSpaces() throws {
try withTemporaryDirectory { tempDir in
let packagePath = tempDir.appending(components: "more spaces", "special tool")
Expand Down Expand Up @@ -241,7 +249,9 @@ private struct BasicTests {
}
}

@Test
@Test(
.skipHostOS(.windows, "package fails to build")
)
func testSwiftRun() throws {
try withTemporaryDirectory { tempDir in
let packagePath = tempDir.appending(component: "secho")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ private struct SwiftPMTests {
}
}

@Test(.requireThreadSafeWorkingDirectory)
@Test(
.requireThreadSafeWorkingDirectory
)
func packageInitExecutable() throws {
// Executable
do {
Expand Down
13 changes: 13 additions & 0 deletions Sources/_InternalTestSupport/misc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import struct SPMBuildCore.BuildParameters
import TSCTestSupport
import Workspace
import func XCTest.XCTFail
import struct XCTest.XCTSkip

import struct TSCBasic.ByteString
import struct Basics.AsyncProcessResult
Expand Down Expand Up @@ -276,6 +277,18 @@ public func executeSwiftBuild(
return try await SwiftPM.Build.execute(args, packagePath: packagePath, env: env)
}

public func skipOnWindowsAsTestCurrentlyFails(because reason: String? = nil) throws {
#if os(Windows)
let failureCause: String
if let reason {
failureCause = " because \(reason.description)"
} else {
failureCause = ""
}
throw XCTSkip("Test fails on windows\(failureCause)")
#endif
}

@discardableResult
public func executeSwiftRun(
_ packagePath: AbsolutePath?,
Expand Down
5 changes: 5 additions & 0 deletions Tests/BasicsTests/AsyncProcessTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ import func TSCBasic.withTemporaryFile
import func TSCTestSupport.withCustomEnv

final class AsyncProcessTests: XCTestCase {

override func setUp() async throws {
try skipOnWindowsAsTestCurrentlyFails()
}

func testBasics() throws {
do {
let process = AsyncProcess(args: "echo", "hello")
Expand Down
6 changes: 6 additions & 0 deletions Tests/BasicsTests/ConcurrencyHelpersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@
import TSCTestSupport
import XCTest

import _InternalTestSupport // for skipOnWindowsAsTestCurrentlyFails

final class ConcurrencyHelpersTest: XCTestCase {
let queue = DispatchQueue(label: "ConcurrencyHelpersTest", attributes: .concurrent)

override func setUpWithError() throws {
try skipOnWindowsAsTestCurrentlyFails()
}

func testThreadSafeKeyValueStore() {
for _ in 0 ..< 100 {
let sync = DispatchGroup()
Expand Down
18 changes: 15 additions & 3 deletions Tests/BasicsTests/Environment/EnvironmentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import Basics

import XCTest
import _InternalTestSupport // for skipOnWindowsAsTestCurrentlyFails()

final class EnvironmentTests: XCTestCase {
func test_init() {
Expand All @@ -36,7 +37,7 @@ final class EnvironmentTests: XCTestCase {
]
let environment = Environment(dictionary)
#if os(Windows)
XCTAssertEqual(environment["TestKey"], "TestValue2") // uppercase sorts before lowercase, so the second value overwrites the first
XCTAssertEqual(environment["TestKey"], "TestValue2")
XCTAssertEqual(environment.count, 1)
#else
XCTAssertEqual(environment["TestKey"], "TestValue")
Expand All @@ -48,6 +49,7 @@ final class EnvironmentTests: XCTestCase {
let dictionary = ["TestKey": "TestValue"]
let environment = Environment(dictionary)
XCTAssertEqual(environment["TestKey"], "TestValue")
XCTAssertEqual(environment.count, 1)
}

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

/// Important: This test is inherently race-prone, if it is proven to be
/// flaky, it should run in a singled threaded environment/removed entirely.
func test_current() {
func test_current() throws {
try skipOnWindowsAsTestCurrentlyFails(because: "ProcessInfo.processInfo.environment[pathEnvVarName] return nil in the docker container")

#if os(Windows)
let pathEnvVarName = "Path"
#else
let pathEnvVarName = "PATH"
#endif


XCTAssertEqual(
Environment.current["PATH"],
ProcessInfo.processInfo.environment["PATH"])
ProcessInfo.processInfo.environment[pathEnvVarName]
)
}

/// Important: This test is inherently race-prone, if it is proven to be
Expand Down
64 changes: 49 additions & 15 deletions Tests/BasicsTests/FileSystem/PathTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import Basics
import Foundation
import XCTest

import _InternalTestSupport // for skipOnWindowsAsTestCurrentlyFails()

#if os(Windows)
private var windows: Bool { true }
#else
Expand Down Expand Up @@ -54,28 +56,36 @@ class PathTests: XCTestCase {
XCTAssertEqual(rel2.pathString, "~") // `~` is not special
}

func testRepeatedPathSeparators() {
func testRepeatedPathSeparators() throws {
try skipOnWindowsAsTestCurrentlyFails(because: "all assertions fail")

XCTAssertEqual(AbsolutePath("/ab//cd//ef").pathString, windows ? #"\ab\cd\ef"# : "/ab/cd/ef")
XCTAssertEqual(AbsolutePath("/ab///cd//ef").pathString, windows ? #"\ab\cd\ef"# : "/ab/cd/ef")
XCTAssertEqual(RelativePath("ab//cd//ef").pathString, windows ? #"ab\cd\ef"# : "ab/cd/ef")
XCTAssertEqual(RelativePath("ab//cd///ef").pathString, windows ? #"ab\cd\ef"# : "ab/cd/ef")
}

func testTrailingPathSeparators() {
func testTrailingPathSeparators() throws {
try skipOnWindowsAsTestCurrentlyFails(because: "trailing path seperator is not removed from pathString")

XCTAssertEqual(AbsolutePath("/ab/cd/ef/").pathString, windows ? #"\ab\cd\ef"# : "/ab/cd/ef")
XCTAssertEqual(AbsolutePath("/ab/cd/ef//").pathString, windows ? #"\ab\cd\ef"# : "/ab/cd/ef")
XCTAssertEqual(RelativePath("ab/cd/ef/").pathString, windows ? #"ab\cd\ef"# : "ab/cd/ef")
XCTAssertEqual(RelativePath("ab/cd/ef//").pathString, windows ? #"ab\cd\ef"# : "ab/cd/ef")
}

func testDotPathComponents() {
func testDotPathComponents() throws {
try skipOnWindowsAsTestCurrentlyFails()

XCTAssertEqual(AbsolutePath("/ab/././cd//ef").pathString, "/ab/cd/ef")
XCTAssertEqual(AbsolutePath("/ab/./cd//ef/.").pathString, "/ab/cd/ef")
XCTAssertEqual(RelativePath("ab/./cd/././ef").pathString, "ab/cd/ef")
XCTAssertEqual(RelativePath("ab/./cd/ef/.").pathString, "ab/cd/ef")
}

func testDotDotPathComponents() {
func testDotDotPathComponents() throws {
try skipOnWindowsAsTestCurrentlyFails()

XCTAssertEqual(AbsolutePath("/..").pathString, windows ? #"\"# : "/")
XCTAssertEqual(AbsolutePath("/../../../../..").pathString, windows ? #"\"# : "/")
XCTAssertEqual(AbsolutePath("/abc/..").pathString, windows ? #"\"# : "/")
Expand All @@ -91,7 +101,9 @@ class PathTests: XCTestCase {
XCTAssertEqual(RelativePath("abc/..").pathString, ".")
}

func testCombinationsAndEdgeCases() {
func testCombinationsAndEdgeCases() throws {
try skipOnWindowsAsTestCurrentlyFails()

XCTAssertEqual(AbsolutePath("///").pathString, windows ? #"\"# : "/")
XCTAssertEqual(AbsolutePath("/./").pathString, windows ? #"\"# : "/")
XCTAssertEqual(RelativePath("").pathString, ".")
Expand Down Expand Up @@ -120,7 +132,9 @@ class PathTests: XCTestCase {
XCTAssertEqual(RelativePath("a/../////../////./////").pathString, "..")
}

func testDirectoryNameExtraction() {
func testDirectoryNameExtraction() throws {
try skipOnWindowsAsTestCurrentlyFails()

XCTAssertEqual(AbsolutePath("/").dirname, windows ? #"\"# : "/")
XCTAssertEqual(AbsolutePath("/a").dirname, windows ? #"\"# : "/")
XCTAssertEqual(AbsolutePath("/./a").dirname, windows ? #"\"# : "/")
Expand All @@ -137,7 +151,9 @@ class PathTests: XCTestCase {
XCTAssertEqual(RelativePath(".").dirname, ".")
}

func testBaseNameExtraction() {
func testBaseNameExtraction() throws {
try skipOnWindowsAsTestCurrentlyFails()

XCTAssertEqual(AbsolutePath("/").basename, windows ? #"\"# : "/")
XCTAssertEqual(AbsolutePath("/a").basename, "a")
XCTAssertEqual(AbsolutePath("/./a").basename, "a")
Expand All @@ -153,7 +169,9 @@ class PathTests: XCTestCase {
XCTAssertEqual(RelativePath(".").basename, ".")
}

func testBaseNameWithoutExt() {
func testBaseNameWithoutExt() throws{
try skipOnWindowsAsTestCurrentlyFails()

XCTAssertEqual(AbsolutePath("/").basenameWithoutExt, windows ? #"\"# : "/")
XCTAssertEqual(AbsolutePath("/a").basenameWithoutExt, "a")
XCTAssertEqual(AbsolutePath("/./a").basenameWithoutExt, "a")
Expand All @@ -176,7 +194,9 @@ class PathTests: XCTestCase {
XCTAssertEqual(RelativePath("abc.xyz.123").basenameWithoutExt, "abc.xyz")
}

func testSuffixExtraction() {
func testSuffixExtraction() throws {
try skipOnWindowsAsTestCurrentlyFails(because: "expected nil is not the actual")

XCTAssertEqual(RelativePath("a").suffix, nil)
XCTAssertEqual(RelativePath("a").extension, nil)
XCTAssertEqual(RelativePath("a.").suffix, nil)
Expand All @@ -201,7 +221,9 @@ class PathTests: XCTestCase {
XCTAssertEqual(RelativePath(".a.foo.bar.baz").extension, "baz")
}

func testParentDirectory() {
func testParentDirectory() throws {
try skipOnWindowsAsTestCurrentlyFails()

XCTAssertEqual(AbsolutePath("/").parentDirectory, AbsolutePath("/"))
XCTAssertEqual(AbsolutePath("/").parentDirectory.parentDirectory, AbsolutePath("/"))
XCTAssertEqual(AbsolutePath("/bar").parentDirectory, AbsolutePath("/"))
Expand All @@ -210,7 +232,9 @@ class PathTests: XCTestCase {
}

@available(*, deprecated)
func testConcatenation() {
func testConcatenation() throws {
try skipOnWindowsAsTestCurrentlyFails()

XCTAssertEqual(AbsolutePath(AbsolutePath("/"), RelativePath("")).pathString, windows ? #"\"# : "/")
XCTAssertEqual(AbsolutePath(AbsolutePath("/"), RelativePath(".")).pathString, windows ? #"\"# : "/")
XCTAssertEqual(AbsolutePath(AbsolutePath("/"), RelativePath("..")).pathString, windows ? #"\"# : "/")
Expand Down Expand Up @@ -247,7 +271,9 @@ class PathTests: XCTestCase {
XCTAssertEqual(RelativePath("hello").appending(RelativePath("a/b/../c/d")).pathString, windows ? #"hello\a\c\d"# : "hello/a/c/d")
}

func testPathComponents() {
func testPathComponents() throws {
try skipOnWindowsAsTestCurrentlyFails()

XCTAssertEqual(AbsolutePath("/").components, ["/"])
XCTAssertEqual(AbsolutePath("/.").components, ["/"])
XCTAssertEqual(AbsolutePath("/..").components, ["/"])
Expand Down Expand Up @@ -275,7 +301,9 @@ class PathTests: XCTestCase {
XCTAssertEqual(RelativePath("abc").components, ["abc"])
}

func testRelativePathFromAbsolutePaths() {
func testRelativePathFromAbsolutePaths() throws {
try skipOnWindowsAsTestCurrentlyFails()

XCTAssertEqual(AbsolutePath("/").relative(to: AbsolutePath("/")), RelativePath("."));
XCTAssertEqual(AbsolutePath("/a/b/c/d").relative(to: AbsolutePath("/")), RelativePath("a/b/c/d"));
XCTAssertEqual(AbsolutePath("/").relative(to: AbsolutePath("/a/b/c")), RelativePath("../../.."));
Expand Down Expand Up @@ -316,7 +344,9 @@ class PathTests: XCTestCase {
XCTAssertTrue(AbsolutePath("/foo").isAncestor(of: AbsolutePath("/foo/bar")))
}

func testAbsolutePathValidation() {
func testAbsolutePathValidation() throws {
try skipOnWindowsAsTestCurrentlyFails()

XCTAssertNoThrow(try AbsolutePath(validating: "/a/b/c/d"))

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

func testRelativePathValidation() {
func testRelativePathValidation() throws {
try skipOnWindowsAsTestCurrentlyFails()

XCTAssertNoThrow(try RelativePath(validating: "a/b/c/d"))

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

func testCodable() throws {
try skipOnWindowsAsTestCurrentlyFails()

struct Foo: Codable, Equatable {
var path: AbsolutePath
}
Expand Down
4 changes: 4 additions & 0 deletions Tests/BasicsTests/FileSystem/VFSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import XCTest

import struct TSCBasic.ByteString

import _InternalTestSupport // for skipOnWindowsAsTestCurrentlyFails

func testWithTemporaryDirectory(
function: StaticString = #function,
body: @escaping (AbsolutePath) async throws -> Void
Expand All @@ -36,6 +38,8 @@ func testWithTemporaryDirectory(

class VFSTests: XCTestCase {
func testLocalBasics() throws {
try skipOnWindowsAsTestCurrentlyFails()

// tiny PE binary from: https://archive.is/w01DO
let contents: [UInt8] = [
0x4d, 0x5a, 0x00, 0x00, 0x50, 0x45, 0x00, 0x00, 0x4c, 0x01, 0x01, 0x00,
Expand Down
2 changes: 2 additions & 0 deletions Tests/BasicsTests/HTTPClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ final class HTTPClientTests: XCTestCase {
}

func testExponentialBackoff() async throws {
try skipOnWindowsAsTestCurrentlyFails()

let counter = SendableBox(0)
let lastCall = SendableBox<Date>()
let maxAttempts = 5
Expand Down
4 changes: 3 additions & 1 deletion Tests/BasicsTests/LegacyHTTPClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ final class LegacyHTTPClientTests: XCTestCase {
wait(for: [promise], timeout: 1)
}

func testExponentialBackoff() {
func testExponentialBackoff() throws {
try skipOnWindowsAsTestCurrentlyFails()

let count = ThreadSafeBox<Int>(0)
let lastCall = ThreadSafeBox<Date>()
let maxAttempts = 5
Expand Down
Loading