From 0092570d88155836c58df84fdb3d66a1ea5cf8a6 Mon Sep 17 00:00:00 2001 From: Sam Khouri Date: Mon, 7 Jul 2025 08:24:14 -0400 Subject: [PATCH 1/2] Tests: Update test expectation - take 2 Update test expectation for executing SwiftPM tests using the build.ps1 script found in swiftlang/swift/utils/build.ps1. Relates to: https://github.com/swiftlang/swift/pull/80405 --- Tests/CommandsTests/PackageCommandTests.swift | 81 +++++++++++++++++++ Tests/CommandsTests/RunCommandTests.swift | 13 ++- Tests/CommandsTests/TestCommandTests.swift | 3 +- .../PD_6_2_LoadingTests.swift | 2 +- 4 files changed, 93 insertions(+), 6 deletions(-) diff --git a/Tests/CommandsTests/PackageCommandTests.swift b/Tests/CommandsTests/PackageCommandTests.swift index 70c5b6767e8..8469e246e44 100644 --- a/Tests/CommandsTests/PackageCommandTests.swift +++ b/Tests/CommandsTests/PackageCommandTests.swift @@ -4411,6 +4411,15 @@ class PackageCommandNativeTests: PackageCommandTestCase { override func testNoParameters() async throws { try await super.testNoParameters() } + + override func testMigrateCommandWhenDependencyBuildsForHostAndTarget() async throws { + try XCTSkipOnWindows( + because: "error: build planning stopped due to build-tool plugin failures", + skipPlatformCi: true, + ) + + try await super.testMigrateCommandWhenDependencyBuildsForHostAndTarget() + } } class PackageCommandSwiftBuildTests: PackageCommandTestCase { @@ -4423,6 +4432,78 @@ class PackageCommandSwiftBuildTests: PackageCommandTestCase { try await super.testNoParameters() } + override func testMigrateCommand() async throws { + try XCTSkipOnWindows( + because: """ + Possibly https://github.com/swiftlang/swift-package-manager/issues/8602: + error: Could not choose a single platform for target 'AllIncludingTests' from the supported platforms 'android qnx webassembly'. Specialization parameters imposed by workspace: platform 'nil' sdkVariant 'nil' supportedPlatforms: 'nil' toolchain: 'nil' + """, + skipPlatformCi: true, + ) + + try await super.testMigrateCommand() + } + + override func testMigrateCommandUpdateManifest2Targets() async throws { + try XCTSkipOnWindows( + because: """ + Possibly https://github.com/swiftlang/swift-package-manager/issues/8602: + error: Could not choose a single platform for target 'A' from the supported platforms 'android qnx webassembly'. Specialization parameters imposed by workspace: platform 'nil' sdkVariant 'nil' supportedPlatforms: 'nil' toolchain: 'nil' + """, + skipPlatformCi: true, + ) + + try await super.testMigrateCommandUpdateManifest2Targets() + } + + override func testMigrateCommandUpdateManifestSingleTarget() async throws { + try XCTSkipOnWindows( + because: """ + Possibly https://github.com/swiftlang/swift-package-manager/issues/8602: + error: Could not choose a single platform for target 'A' from the supported platforms 'android qnx webassembly'. Specialization parameters imposed by workspace: platform 'nil' sdkVariant 'nil' supportedPlatforms: 'nil' toolchain: 'nil' + """, + skipPlatformCi: true, + ) + + try await super.testMigrateCommandUpdateManifestSingleTarget() + } + + override func testMigrateCommandUpdateManifestWithErrors() async throws { + try XCTSkipOnWindows( + because: """ + Possibly https://github.com/swiftlang/swift-package-manager/issues/8602: + error: Could not choose a single platform for target 'A' from the supported platforms 'android qnx webassembly'. Specialization parameters imposed by workspace: platform 'nil' sdkVariant 'nil' supportedPlatforms: 'nil' toolchain: 'nil' + """, + skipPlatformCi: true, + ) + + try await super.testMigrateCommandUpdateManifestWithErrors() + } + + override func testMigrateCommandWhenDependencyBuildsForHostAndTarget() async throws { + try XCTSkipOnWindows( + because: """ + Possibly https://github.com/swiftlang/swift-package-manager/issues/8602: + error: Could not choose a single platform for target 'A' from the supported platforms 'android qnx webassembly'. Specialization parameters imposed by workspace: platform 'nil' sdkVariant 'nil' supportedPlatforms: 'nil' toolchain: 'nil' + """, + skipPlatformCi: true, + ) + + try await super.testMigrateCommandWhenDependencyBuildsForHostAndTarget() + } + + override func testMigrateCommandWithBuildToolPlugins() async throws { + try XCTSkipOnWindows( + because: """ + Possibly https://github.com/swiftlang/swift-package-manager/issues/8602: + error: Could not choose a single platform for target 'A' from the supported platforms 'android qnx webassembly'. Specialization parameters imposed by workspace: platform 'nil' sdkVariant 'nil' supportedPlatforms: 'nil' toolchain: 'nil' + """, + skipPlatformCi: true, + ) + + try await super.testMigrateCommandWithBuildToolPlugins() + } + override func testCommandPluginSymbolGraphCallbacks() async throws { try XCTSkipOnWindows(because: "TSCBasic/Path.swift:969: Assertion failed, https://github.com/swiftlang/swift-package-manager/issues/8602") try await super.testCommandPluginSymbolGraphCallbacks() diff --git a/Tests/CommandsTests/RunCommandTests.swift b/Tests/CommandsTests/RunCommandTests.swift index 33c66cc1300..58d24bc7a97 100644 --- a/Tests/CommandsTests/RunCommandTests.swift +++ b/Tests/CommandsTests/RunCommandTests.swift @@ -399,7 +399,9 @@ struct RunCommandTests { } @Test( - .bug("https://github.com/swiftlang/swift-package-manager/issues/8844"), + .issue("https://github.com/swiftlang/swift-package-manager/issues/8844", relationship: .verifies), + .issue("https://github.com/swiftlang/swift-package-manager/issues/8911", relationship: .defect), + .issue("https://github.com/swiftlang/swift-package-manager/issues/8912", relationship: .defect), arguments: SupportedBuildSystemOnPlatform, BuildConfiguration.allCases ) func swiftRunQuietLogLevel( @@ -423,9 +425,12 @@ struct RunCommandTests { #expect(stdout == "done\n") } } when: { - ProcessInfo.hostOperatingSystem == .linux && - buildSystem == .swiftbuild && - CiEnvironment.runningInSelfHostedPipeline + ( + ProcessInfo.hostOperatingSystem == .linux && + buildSystem == .swiftbuild && + CiEnvironment.runningInSelfHostedPipeline + ) + || (CiEnvironment.runningInSmokeTestPipeline && ProcessInfo.hostOperatingSystem == .windows) } } diff --git a/Tests/CommandsTests/TestCommandTests.swift b/Tests/CommandsTests/TestCommandTests.swift index c8cb6840747..dadf7dc3282 100644 --- a/Tests/CommandsTests/TestCommandTests.swift +++ b/Tests/CommandsTests/TestCommandTests.swift @@ -243,7 +243,8 @@ struct TestCommandTests { } } when: { (buildSystem == .swiftbuild && .linux == ProcessInfo.hostOperatingSystem) - || (buildSystem == .swiftbuild && .windows == ProcessInfo.hostOperatingSystem && CiEnvironment.runningInSelfHostedPipeline) + // || (buildSystem == .swiftbuild && .windows == ProcessInfo.hostOperatingSystem && CiEnvironment.runningInSelfHostedPipeline) + || (buildSystem == .swiftbuild && .windows == ProcessInfo.hostOperatingSystem ) } } diff --git a/Tests/PackageLoadingTests/PD_6_2_LoadingTests.swift b/Tests/PackageLoadingTests/PD_6_2_LoadingTests.swift index 00fedd695f5..19ddde7e991 100644 --- a/Tests/PackageLoadingTests/PD_6_2_LoadingTests.swift +++ b/Tests/PackageLoadingTests/PD_6_2_LoadingTests.swift @@ -86,7 +86,7 @@ struct PackageDescription6_2LoadingTests { results.checkIsEmpty() } } when: { - isWindows + isWindows && !CiEnvironment.runningInSmokeTestPipeline } } } From 3cbdade1068636ad33a2cba05f636c0f56b30001 Mon Sep 17 00:00:00 2001 From: Sam Khouri Date: Mon, 5 May 2025 08:36:35 -0400 Subject: [PATCH 2/2] Test: Enable additional tests on Windows Enabled additional tests on Windows Since all tests on Windows are either enabled, or are skipped with an associated GitHub issue, update the XCTSkipOnWindows(...) helper API to require providing a reson as to why the test is being skipped. Fixes: #8433 Issue: rdar://148248105 --- .../_InternalTestSupport/XCTAssertHelpers.swift | 17 +++++------------ .../PackageGraphPerfTests.swift | 2 -- .../ManifestSourceGenerationTests.swift | 2 +- .../RegistryPackageContainerTests.swift | 5 ----- Tests/WorkspaceTests/WorkspaceTests.swift | 16 +--------------- 5 files changed, 7 insertions(+), 35 deletions(-) diff --git a/Sources/_InternalTestSupport/XCTAssertHelpers.swift b/Sources/_InternalTestSupport/XCTAssertHelpers.swift index 58a47f7fc43..5fbcdc74875 100644 --- a/Sources/_InternalTestSupport/XCTAssertHelpers.swift +++ b/Sources/_InternalTestSupport/XCTAssertHelpers.swift @@ -61,20 +61,13 @@ public func XCTSkipIfselfHostedCI(because reason: String, file: StaticString = # } } -public func XCTSkipOnWindows(because reason: String? = nil, skipPlatformCi: Bool = false, skipSelfHostedCI: Bool = false , file: StaticString = #filePath, line: UInt = #line) throws { +public func XCTSkipOnWindows(because reason: String, skipPlatformCi: Bool = false, skipSelfHostedCI: Bool = false , file: StaticString = #filePath, line: UInt = #line) throws { #if os(Windows) - let failureCause: String - if let reason { - failureCause = " because \(reason.description)" - } else { - failureCause = "" - } + let failureCause = "Skipping because \(reason.description)" if (skipPlatformCi) { - try XCTSkipIfPlatformCI(because: "Test is run in Platform CI. Skipping\(failureCause)", file: file, line: line) - } - - if (skipSelfHostedCI) { - try XCTSkipIfselfHostedCI(because: "Test is run in Self hosted CI. Skipping\(failureCause)", file: file, line: line) + try XCTSkipIfPlatformCI(because: "Test is run in Platform CI. \(failureCause)", file: file, line: line) + } else if skipSelfHostedCI { + try XCTSkipIfselfHostedCI(because: "Test is run in Self hosted CI. \(failureCause)", file: file, line: line) } if (!skipPlatformCi && !skipSelfHostedCI) { diff --git a/Tests/PackageGraphPerformanceTests/PackageGraphPerfTests.swift b/Tests/PackageGraphPerformanceTests/PackageGraphPerfTests.swift index 66c98c79c27..179685e17c5 100644 --- a/Tests/PackageGraphPerformanceTests/PackageGraphPerfTests.swift +++ b/Tests/PackageGraphPerformanceTests/PackageGraphPerfTests.swift @@ -167,8 +167,6 @@ final class PackageGraphPerfTests: XCTestCasePerf { } func testRecursiveDependencies() throws { - try XCTSkipOnWindows() - var resolvedTarget = ResolvedModule.mock(packageIdentity: "pkg", name: "t0") for i in 1..<1000 { resolvedTarget = ResolvedModule.mock(packageIdentity: "pkg", name: "t\(i)", deps: resolvedTarget) diff --git a/Tests/WorkspaceTests/ManifestSourceGenerationTests.swift b/Tests/WorkspaceTests/ManifestSourceGenerationTests.swift index 18e5ccfab44..f14e60b990c 100644 --- a/Tests/WorkspaceTests/ManifestSourceGenerationTests.swift +++ b/Tests/WorkspaceTests/ManifestSourceGenerationTests.swift @@ -233,7 +233,7 @@ final class ManifestSourceGenerationTests: XCTestCase { } func testAdvancedFeatures() async throws { - try XCTSkipOnWindows() + try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8602: TSCBasic/Path.swift:969: Assertion failed") let manifestContents = """ // swift-tools-version:5.3 diff --git a/Tests/WorkspaceTests/RegistryPackageContainerTests.swift b/Tests/WorkspaceTests/RegistryPackageContainerTests.swift index d7eb6a20461..5a1595a53be 100644 --- a/Tests/WorkspaceTests/RegistryPackageContainerTests.swift +++ b/Tests/WorkspaceTests/RegistryPackageContainerTests.swift @@ -24,11 +24,6 @@ import XCTest import struct TSCUtility.Version final class RegistryPackageContainerTests: XCTestCase { - - override func setUpWithError() throws { - try XCTSkipOnWindows() - } - func testToolsVersionCompatibleVersions() async throws { let fs = InMemoryFileSystem() try fs.createMockToolchain() diff --git a/Tests/WorkspaceTests/WorkspaceTests.swift b/Tests/WorkspaceTests/WorkspaceTests.swift index 667d61aee2f..571b91683ac 100644 --- a/Tests/WorkspaceTests/WorkspaceTests.swift +++ b/Tests/WorkspaceTests/WorkspaceTests.swift @@ -28,20 +28,6 @@ import struct TSCBasic.ByteString import struct TSCUtility.Version final class WorkspaceTests: XCTestCase { - // override func setUpWithError() throws { - // let windowsPassingTests = [ - // #selector(self.testBinaryArtifactsInvalidPath), - // #selector(self.testManifestLoaderDiagnostics), - // #selector(self.testInterpreterFlags), - // #selector(self.testManifestParseError), - // #selector(self.testSimpleAPI) - // ] - // let matches = windowsPassingTests.filter { $0 == self.invocation?.selector} - // if matches.count == 0 { - // try XCTSkipOnWindows() - // } - // } - func testBasics() async throws { let sandbox = AbsolutePath("/tmp/ws/") let fs = InMemoryFileSystem() @@ -8036,7 +8022,7 @@ final class WorkspaceTests: XCTestCase { func testArtifactChecksum() async throws { try XCTSkipOnWindows(because: #""" - threw error "\tmp\ws doesn't exist in file system" because there is an issue with InMemoryFileSystem readFileContents(...) on Windows + https://github.com/swiftlang/swift-package-manager/issues/8615: threw error "\tmp\ws doesn't exist in file system" because there is an issue with InMemoryFileSystem readFileContents(...) on Windows """#) let fs = InMemoryFileSystem()