From 69ff9142b9b19e3e731ea8c8117b8a12abf756f6 Mon Sep 17 00:00:00 2001 From: Sam Khouri Date: Mon, 21 Apr 2025 14:52:17 -0400 Subject: [PATCH] Tests: enabled a test and update skip reason Enabled a single test on Windows and include a GitHub issue with some tests that are skipped on Windows. --- .../Serialization/SerializedJSONTests.swift | 2 +- Tests/BuildTests/BuildSystemDelegateTests.swift | 2 +- Tests/PackageGraphTests/ModulesGraphTests.swift | 2 +- .../PackageBuilderTests.swift | 2 +- Tests/PackageModelTests/PackageModelTests.swift | 16 +++++++++------- Tests/QueryEngineTests/QueryEngineTests.swift | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Tests/BasicsTests/Serialization/SerializedJSONTests.swift b/Tests/BasicsTests/Serialization/SerializedJSONTests.swift index b499a4eb1dc..db3ab32e95d 100644 --- a/Tests/BasicsTests/Serialization/SerializedJSONTests.swift +++ b/Tests/BasicsTests/Serialization/SerializedJSONTests.swift @@ -34,7 +34,7 @@ final class SerializedJSONTests: XCTestCase { } func testPathInterpolationFailsOnWindows() throws { - try skipOnWindowsAsTestCurrentlyFails(because: "Expectations are not met") + try skipOnWindowsAsTestCurrentlyFails(because: "Expectations are not met. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511") #if os(Windows) var path = try AbsolutePath(validating: #"\\?\C:\Users"#) diff --git a/Tests/BuildTests/BuildSystemDelegateTests.swift b/Tests/BuildTests/BuildSystemDelegateTests.swift index 8e07b6a3d1a..ea844efc800 100644 --- a/Tests/BuildTests/BuildSystemDelegateTests.swift +++ b/Tests/BuildTests/BuildSystemDelegateTests.swift @@ -30,7 +30,7 @@ final class BuildSystemDelegateTests: XCTestCase { } func testFilterNonFatalCodesignMessages() async throws { - try skipOnWindowsAsTestCurrentlyFails(because: "Package fails to build when the test is being executed") + try skipOnWindowsAsTestCurrentlyFails(because: "https://github.com/swiftlang/swift-package-manager/issues/8540: Package fails to build when the test is being executed") try XCTSkipIf(!UserToolchain.default.supportsSDKDependentTests(), "skipping because test environment doesn't support this test") // Note: we can re-use the `TestableExe` fixture here since we just need an executable. diff --git a/Tests/PackageGraphTests/ModulesGraphTests.swift b/Tests/PackageGraphTests/ModulesGraphTests.swift index fa128410127..acab9029f27 100644 --- a/Tests/PackageGraphTests/ModulesGraphTests.swift +++ b/Tests/PackageGraphTests/ModulesGraphTests.swift @@ -23,7 +23,7 @@ import struct TSCBasic.ByteString final class ModulesGraphTests: XCTestCase { func testBasic() throws { - try skipOnWindowsAsTestCurrentlyFails() + try skipOnWindowsAsTestCurrentlyFails(because: "Possibly related to: https://github.com/swiftlang/swift-package-manager/issues/8511") let fs = InMemoryFileSystem( emptyFiles: "/Foo/Sources/Foo/source.swift", diff --git a/Tests/PackageLoadingTests/PackageBuilderTests.swift b/Tests/PackageLoadingTests/PackageBuilderTests.swift index c57b2da08cb..6a71f526a8c 100644 --- a/Tests/PackageLoadingTests/PackageBuilderTests.swift +++ b/Tests/PackageLoadingTests/PackageBuilderTests.swift @@ -564,7 +564,7 @@ final class PackageBuilderTests: XCTestCase { } func testTestManifestSearch() throws { - try skipOnWindowsAsTestCurrentlyFails() + try skipOnWindowsAsTestCurrentlyFails(because: "possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511") let fs = InMemoryFileSystem(emptyFiles: "/pkg/foo.swift", diff --git a/Tests/PackageModelTests/PackageModelTests.swift b/Tests/PackageModelTests/PackageModelTests.swift index 8c7f5f3b184..9d230b286d5 100644 --- a/Tests/PackageModelTests/PackageModelTests.swift +++ b/Tests/PackageModelTests/PackageModelTests.swift @@ -17,7 +17,6 @@ import Basics import func TSCBasic.withTemporaryFile import XCTest -import _InternalTestSupport // for skipOnWindowsAsTestCurrentlyFails import struct TSCBasic.ByteString @@ -160,10 +159,7 @@ final class PackageModelTests: XCTestCase { } func testDetermineSwiftCompilers() throws { - try skipOnWindowsAsTestCurrentlyFails() - let fs = localFileSystem - try withTemporaryFile { _ in try withTemporaryDirectory(removeTreeOnDeinit: true) { tmp in // When swiftc is not in the toolchain bin directory, UserToolchain // should find it in the system PATH search paths in the order they @@ -175,10 +171,17 @@ final class PackageModelTests: XCTestCase { // Create a directory with two swiftc binaries in it. let binDirs = ["bin1", "bin2"].map { tmp.appending($0) } + #if os(Windows) + let exeSuffix = ".exe" + #else + let exeSuffix = "" + #endif + let expectedExecuable = "swiftc\(exeSuffix)" // Files that end with .exe are considered executable on Windows. for binDir in binDirs { try fs.createDirectory(binDir) - let binFile = binDir.appending("swiftc") + let binFile = binDir.appending(expectedExecuable) try fs.writeFileContents(binFile, bytes: ByteString(Self.tinyPEBytes)) + XCTAssertTrue(fs.exists(binFile), "File '\(binFile)' does not exist when it should") #if !os(Windows) try fs.chmod(.executable, path: binFile, options: []) #endif @@ -193,8 +196,7 @@ final class PackageModelTests: XCTestCase { ) // The first swiftc in the search paths should be chosen. - XCTAssertEqual(compilers.compile, binDirs.first?.appending("swiftc")) + XCTAssertEqual(compilers.compile, binDirs.first?.appending(expectedExecuable)) } - } } } diff --git a/Tests/QueryEngineTests/QueryEngineTests.swift b/Tests/QueryEngineTests/QueryEngineTests.swift index 840bff4d4e4..c87f59820ed 100644 --- a/Tests/QueryEngineTests/QueryEngineTests.swift +++ b/Tests/QueryEngineTests/QueryEngineTests.swift @@ -100,7 +100,7 @@ private struct Expression: CachingQuery { final class QueryEngineTests: XCTestCase { func testFilePathHashing() throws { - try skipOnWindowsAsTestCurrentlyFails() + try skipOnWindowsAsTestCurrentlyFails(because: "https://github.com/swiftlang/swift-package-manager/issues/8541") let path = "/root"