diff --git a/Sources/_InternalTestSupport/XCTAssertHelpers.swift b/Sources/_InternalTestSupport/XCTAssertHelpers.swift index b558a0692bf..9ccbdc35723 100644 --- a/Sources/_InternalTestSupport/XCTAssertHelpers.swift +++ b/Sources/_InternalTestSupport/XCTAssertHelpers.swift @@ -67,10 +67,15 @@ public func XCTSkipOnWindows(because reason: String? = nil, skipPlatformCi: Bool } else { failureCause = "" } - if (skipPlatformCi || skipSelfHostedCI) { + 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) - } else { + } + + if (!skipPlatformCi && !skipSelfHostedCI) { throw XCTSkip("Skipping test\(failureCause)", file: file, line: line) } #endif diff --git a/Tests/CommandsTests/RunCommandTests.swift b/Tests/CommandsTests/RunCommandTests.swift index 336da79d38c..2eebe108e76 100644 --- a/Tests/CommandsTests/RunCommandTests.swift +++ b/Tests/CommandsTests/RunCommandTests.swift @@ -81,6 +81,12 @@ class RunCommandTestCase: CommandsBuildProviderTestCase { } func testUnknownProductAndArgumentPassing() async throws { + try XCTSkipOnWindows( + because: """ + Invalid absolute path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) try await fixture(name: "Miscellaneous/EchoExecutable") { fixturePath in let (stdout, stderr) = try await execute( ["secho", "1", "--hello", "world"], packagePath: fixturePath) @@ -115,6 +121,12 @@ class RunCommandTestCase: CommandsBuildProviderTestCase { } func testUnreachableExecutable() async throws { + try XCTSkipOnWindows( + because: """ + Invalid absolute path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) try await fixture(name: "Miscellaneous/UnreachableTargets") { fixturePath in let (output, _) = try await execute(["bexec"], packagePath: fixturePath.appending("A")) let outputLines = output.split(whereSeparator: { $0.isNewline }) @@ -246,6 +258,48 @@ class RunCommandNativeTests: RunCommandTestCase { override func testUsage() async throws { try await super.testUsage() } + + override func testUnknownProductAndArgumentPassing() async throws { + try XCTSkipOnWindows( + because: """ + Invalid absolute path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) + try await super.testUnknownProductAndArgumentPassing() + } + + override func testToolsetDebugger() async throws { + try XCTSkipOnWindows( + because: """ + Invalid absolute path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) + try await super.testToolsetDebugger() + } + + + override func testUnreachableExecutable() async throws { + try XCTSkipOnWindows( + because: """ + Invalid absolute path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) + try await super.testUnreachableExecutable() + } + + override func testMultipleExecutableAndExplicitExecutable() async throws { + try XCTSkipOnWindows( + because: """ + Invalid absolute path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) + try await super.testMultipleExecutableAndExplicitExecutable() + } + } diff --git a/Tests/FunctionalTests/MiscellaneousTests.swift b/Tests/FunctionalTests/MiscellaneousTests.swift index 7b22327e961..d6647fe7b75 100644 --- a/Tests/FunctionalTests/MiscellaneousTests.swift +++ b/Tests/FunctionalTests/MiscellaneousTests.swift @@ -474,7 +474,11 @@ final class MiscellaneousTestCase: XCTestCase { func testEditModeEndToEnd() async throws { try await fixture(name: "Miscellaneous/Edit") { fixturePath in + #if os(Windows) + let prefix = fixturePath + #else let prefix = try resolveSymlinks(fixturePath) + #endif let appPath = fixturePath.appending("App") // prepare the dependencies as git repos @@ -487,8 +491,12 @@ final class MiscellaneousTestCase: XCTestCase { // make sure it builds let output = try await executeSwiftBuild(appPath) // package resolution output goes to stderr - XCTAssertMatch(output.stderr, .contains("Fetching \(prefix.appending("Foo"))")) - XCTAssertMatch(output.stderr, .contains("Creating working copy for \(prefix.appending("Foo"))")) + XCTAssertMatch(output.stderr, .contains("Fetching \(prefix.appending("Foo").pathString)")) + XCTAssertMatch(output.stderr, .contains("Fetched \(prefix.appending("Foo").pathString)")) + XCTAssertMatch(output.stderr, .contains("Creating working copy for \(prefix.appending("Foo").pathString)")) + XCTAssertMatch(output.stderr, .contains("Fetching \(prefix.appending("Bar").pathString)")) + XCTAssertMatch(output.stderr, .contains("Fetched \(prefix.appending("Bar").pathString)")) + XCTAssertMatch(output.stderr, .contains("Creating working copy for \(prefix.appending("Bar").pathString)")) // in "swift build" build output goes to stdout XCTAssertMatch(output.stdout, .contains("Build complete!")) } @@ -597,6 +605,12 @@ final class MiscellaneousTestCase: XCTestCase { func testPluginGeneratedResources() async throws { // Only run the test if the environment in which we're running actually supports Swift concurrency (which the plugin APIs require). try XCTSkipIf(!UserToolchain.default.supportsSwiftConcurrency(), "skipping because test environment doesn't support concurrency") + try XCTSkipOnWindows( + because: """ + Invalid path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) try await fixture(name: "Miscellaneous/PluginGeneratedResources") { path in let result = try await SwiftPM.Run.execute(packagePath: path) @@ -610,7 +624,7 @@ final class MiscellaneousTestCase: XCTestCase { await XCTAssertBuilds(fixturePath) } } - + func testNoJSONOutputWithFlatPackageStructure() async throws { try await fixture(name: "Miscellaneous/FlatPackage") { package in // First build, make sure we got the `.build` directory where we expect it, and that there is no JSON output (by looking for known output). diff --git a/Tests/FunctionalTests/ResourcesTests.swift b/Tests/FunctionalTests/ResourcesTests.swift index 2dd37feff13..1e505447c3e 100644 --- a/Tests/FunctionalTests/ResourcesTests.swift +++ b/Tests/FunctionalTests/ResourcesTests.swift @@ -17,6 +17,13 @@ import XCTest final class ResourcesTests: XCTestCase { func testSimpleResources() async throws { + try XCTSkipOnWindows( + because: """ + Invalid path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) + try await fixture(name: "Resources/Simple") { fixturePath in var executables = ["SwiftyResource"] diff --git a/Tests/FunctionalTests/TraitTests.swift b/Tests/FunctionalTests/TraitTests.swift index 470dc6082a3..554253595af 100644 --- a/Tests/FunctionalTests/TraitTests.swift +++ b/Tests/FunctionalTests/TraitTests.swift @@ -18,6 +18,12 @@ import XCTest final class TraitTests: XCTestCase { func testTraits_whenNoFlagPassed() async throws { + try XCTSkipOnWindows( + because: """ + Error during swift Run Invalid path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) try await fixture(name: "Traits") { fixturePath in let (stdout, stderr) = try await executeSwiftRun( fixturePath.appending("Example"), @@ -40,6 +46,12 @@ final class TraitTests: XCTestCase { } func testTraits_whenTraitUnification() async throws { + try XCTSkipOnWindows( + because: """ + Error during swift Run Invalid path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) try await fixture(name: "Traits") { fixturePath in let (stdout, stderr) = try await executeSwiftRun( fixturePath.appending("Example"), @@ -66,6 +78,12 @@ final class TraitTests: XCTestCase { } func testTraits_whenTraitUnification_whenSecondTraitNotEnabled() async throws { + try XCTSkipOnWindows( + because: """ + Error during swift Run Invalid path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) try await fixture(name: "Traits") { fixturePath in let (stdout, stderr) = try await executeSwiftRun( fixturePath.appending("Example"), @@ -90,6 +108,12 @@ final class TraitTests: XCTestCase { } func testTraits_whenIndividualTraitsEnabled_andDefaultTraits() async throws { + try XCTSkipOnWindows( + because: """ + Error during swift Run Invalid path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) try await fixture(name: "Traits") { fixturePath in let (stdout, stderr) = try await executeSwiftRun( fixturePath.appending("Example"), @@ -119,6 +143,13 @@ final class TraitTests: XCTestCase { } func testTraits_whenDefaultTraitsDisabled() async throws { + try XCTSkipOnWindows( + because: """ + Error during swift Run Invalid path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) + try await fixture(name: "Traits") { fixturePath in let (stdout, stderr) = try await executeSwiftRun( fixturePath.appending("Example"), @@ -137,6 +168,12 @@ final class TraitTests: XCTestCase { } func testTraits_whenIndividualTraitsEnabled_andDefaultTraitsDisabled() async throws { + try XCTSkipOnWindows( + because: """ + Error during swift Run Invalid path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) try await fixture(name: "Traits") { fixturePath in let (stdout, stderr) = try await executeSwiftRun( fixturePath.appending("Example"), @@ -158,6 +195,13 @@ final class TraitTests: XCTestCase { } func testTraits_whenAllTraitsEnabled() async throws { + try XCTSkipOnWindows( + because: """ + Error during swift Run Invalid path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) + try await fixture(name: "Traits") { fixturePath in let (stdout, stderr) = try await executeSwiftRun( fixturePath.appending("Example"), @@ -187,6 +231,13 @@ final class TraitTests: XCTestCase { } func testTraits_whenAllTraitsEnabled_andDefaultTraitsDisabled() async throws { + try XCTSkipOnWindows( + because: """ + Error during swift Run Invalid path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) + try await fixture(name: "Traits") { fixturePath in let (stdout, stderr) = try await executeSwiftRun( fixturePath.appending("Example"), @@ -231,6 +282,12 @@ final class TraitTests: XCTestCase { } func testTests_whenNoFlagPassed() async throws { + try XCTSkipOnWindows( + because: """ + Error during swift Run Invalid path. Possibly related to https://github.com/swiftlang/swift-package-manager/issues/8511 or https://github.com/swiftlang/swift-package-manager/issues/8602 + """, + skipPlatformCi: true, + ) try await fixture(name: "Traits") { fixturePath in let (stdout, _) = try await executeSwiftTest( fixturePath.appending("Example"), diff --git a/Tests/WorkspaceTests/ManifestSourceGenerationTests.swift b/Tests/WorkspaceTests/ManifestSourceGenerationTests.swift index a7f1d7d8cab..8ec499e2476 100644 --- a/Tests/WorkspaceTests/ManifestSourceGenerationTests.swift +++ b/Tests/WorkspaceTests/ManifestSourceGenerationTests.swift @@ -41,7 +41,9 @@ final class ManifestSourceGenerationTests: XCTestCase { toolsVersion: ToolsVersion, toolsVersionHeaderComment: String? = .none, additionalImportModuleNames: [String] = [], - fs: FileSystem = localFileSystem + fs: FileSystem = localFileSystem, + file: StaticString = #file, + line: UInt = #line, ) async throws -> String { try await withTemporaryDirectory { packageDir in let observability = ObservabilitySystem.makeForTesting() @@ -98,18 +100,18 @@ final class ManifestSourceGenerationTests: XCTestCase { // Check that all the relevant properties survived. let failureDetails = "\n--- ORIGINAL MANIFEST CONTENTS ---\n" + manifestContents + "\n--- REWRITTEN MANIFEST CONTENTS ---\n" + newContents - XCTAssertEqual(newManifest.toolsVersion, manifest.toolsVersion, failureDetails) - XCTAssertEqual(newManifest.displayName, manifest.displayName, failureDetails) - XCTAssertEqual(newManifest.defaultLocalization, manifest.defaultLocalization, failureDetails) - XCTAssertEqual(newManifest.platforms, manifest.platforms, failureDetails) - XCTAssertEqual(newManifest.pkgConfig, manifest.pkgConfig, failureDetails) - XCTAssertEqual(newManifest.providers, manifest.providers, failureDetails) - XCTAssertEqual(newManifest.products, manifest.products, failureDetails) - XCTAssertEqual(newManifest.dependencies, manifest.dependencies, failureDetails) - XCTAssertEqual(newManifest.targets, manifest.targets, failureDetails) - XCTAssertEqual(newManifest.swiftLanguageVersions, manifest.swiftLanguageVersions, failureDetails) - XCTAssertEqual(newManifest.cLanguageStandard, manifest.cLanguageStandard, failureDetails) - XCTAssertEqual(newManifest.cxxLanguageStandard, manifest.cxxLanguageStandard, failureDetails) + XCTAssertEqual(newManifest.toolsVersion, manifest.toolsVersion, "toolsVersion not as expected" + failureDetails, file: file, line: line) + XCTAssertEqual(newManifest.displayName, manifest.displayName, "displayName not as expected" + failureDetails, file: file, line: line) + XCTAssertEqual(newManifest.defaultLocalization, manifest.defaultLocalization, "defaultLocalization not as expected" + failureDetails, file: file, line: line) + XCTAssertEqual(newManifest.platforms, manifest.platforms, "platforms not as expected" + failureDetails, file: file, line: line) + XCTAssertEqual(newManifest.pkgConfig, manifest.pkgConfig, "pkgConfig not as expected" + failureDetails, file: file, line: line) + XCTAssertEqual(newManifest.providers, manifest.providers, "providers not as expected" + failureDetails, file: file, line: line) + XCTAssertEqual(newManifest.products, manifest.products, "products not as expected" + failureDetails, file: file, line: line) + XCTAssertEqual(newManifest.dependencies, manifest.dependencies, "dependencies not as expected" + failureDetails, file: file, line: line) + XCTAssertEqual(newManifest.targets, manifest.targets, "targets not as expected" + failureDetails, file: file, line: line) + XCTAssertEqual(newManifest.swiftLanguageVersions, manifest.swiftLanguageVersions, "swiftLanguageVersions not as expected" + failureDetails, file: file, line: line) + XCTAssertEqual(newManifest.cLanguageStandard, manifest.cLanguageStandard, "cLanguageStandard not as expected" + failureDetails, file: file, line: line) + XCTAssertEqual(newManifest.cxxLanguageStandard, manifest.cxxLanguageStandard, "cxxLanguageStandard not as expected" + failureDetails, file: file, line: line) // Return the generated manifest so that the caller can do further testing on it. return newContents @@ -282,6 +284,10 @@ final class ManifestSourceGenerationTests: XCTestCase { } func testPackageDependencyVariations() async throws { + try XCTSkipOnWindows( + because:"Intermittently fails", + skipPlatformCi: true, + ) let manifestContents = """ // swift-tools-version:5.4 import PackageDescription