Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Sources/SourceControl/Repository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public struct RepositorySpecifier: Hashable, Sendable {
if basename.hasSuffix(".git") {
basename = String(basename.dropLast(4))
}
if basename == "/" {
if basename == "/" || basename == "\\" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a single central variable that is an array of the possible path separators for the host.

See https://github.com/swiftlang/swift-build/blob/bc2e7d92d36caed0399f64594b9e5518b2f83731/Sources/SWBUtil/Path.swift#L69 for example.

There might already be one in the SwiftPM codebase somewhere, or in TSC.

Also, this part of the logic should probably be constrained to file URLs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, I couldn't find a central definition for path separators like whats in swift-build, and it looks like from this https://github.com/swiftlang/swift-package-manager/pull/6706/files we moved away from URL

return ""
}
return basename
Expand Down
6 changes: 2 additions & 4 deletions Tests/BasicsTests/AsyncProcessTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,14 @@ final class AsyncProcessTests: XCTestCase {
}

func testPopenWithBufferLargerThanAllocated() throws {
try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/9031: test fails on windows.")

// Test buffer larger than that allocated.
try withTemporaryFile { file in
let count = 10000
let stream = BufferedOutputByteStream()
stream.send(Format.asRepeating(string: "a", count: count))
try localFileSystem.writeFileContents(file.path, bytes: stream.bytes)
file.fileHandle.write(Data(stream.bytes.contents))
let actualStreamCount = stream.bytes.count
XCTAssertTrue(actualStreamCount == count, "Actual stream count (\(actualStreamCount)) is not as exxpected (\(count))")
XCTAssertTrue(actualStreamCount == count, "Actual stream count (\(actualStreamCount)) is not as expected (\(count))")
let outputCount = try AsyncProcess.popen(arguments: catExecutableArgs + [file.path.pathString]).utf8Output().count
XCTAssert(outputCount == count, "Actual count (\(outputCount)) is not as expected (\(count))")
}
Expand Down
12 changes: 6 additions & 6 deletions Tests/BasicsTests/FileSystem/InMemoryFilesSystemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ struct InMemoryFileSystemTests {

// WHEN we write contents to the file
// THEn we expect an error to occus
withKnownIssue {
#expect(throws: (any Error).self) {
try fs.writeFileContents(pathUnderTest, bytes: expectedContents)
}

Expand All @@ -171,7 +171,7 @@ struct InMemoryFileSystemTests {

// WHEN we write contents to the file
// THEN we expect an error to occur
withKnownIssue {
#expect(throws: (any Error).self) {
try fs.writeFileContents(pathUnderTest, bytes: expectedContents)
}

Expand All @@ -191,7 +191,7 @@ struct InMemoryFileSystemTests {

// WHEN we write contents to the file
// THEN we expect an error to occur
withKnownIssue {
#expect(throws: (any Error).self) {
try fs.writeFileContents(pathUnderTest, bytes: expectedContents)
}

Expand All @@ -207,7 +207,7 @@ struct InMemoryFileSystemTests {

// WHEN we read a non-existing file
// THEN an error occurs
withKnownIssue {
#expect(throws: (any Error).self) {
let _ = try fs.readFileContents("/file/does/not/exists")
}
}
Expand Down Expand Up @@ -323,8 +323,8 @@ struct InMemoryFileSystemTests {

// WHEN we read the contents of a directory
// THEN we expect a failure to occur
withKnownIssue {
let _ = try fs.readFileContents(pathUnderTest.parentDirectory)
#expect(throws: (any Error).self) {
try fs.readFileContents(pathUnderTest.parentDirectory)
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions Tests/BasicsTests/Serialization/SerializedJSONTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@ final class SerializedJSONTests: XCTestCase {
}

func testPathInterpolationFailsOnWindows() throws {
try XCTSkipOnWindows(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"#)
var json: SerializedJSON = "\(path)"

XCTAssertEqual(json.underlying, #"C:\\Users"#)
XCTAssertEqual(json.underlying, #"\\\\?\\C:\\Users"#)

path = try AbsolutePath(validating: #"\\.\UNC\server\share\"#)
json = "\(path)"

XCTAssertEqual(json.underlying, #"\\.\\UNC\\server\\share"#)
XCTAssertEqual(json.underlying, #"\\\\.\\UNC\\server\\share"#)
#endif
}
}
14 changes: 7 additions & 7 deletions Tests/CommandsTests/BuildCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ struct BuildCommandTestCases {
data: BuildData,
) async throws {
let buildSystem = data.buildSystem
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
try await fixture(name: "Miscellaneous/LibraryEvolution") { fixturePath in
let result = try await build(
[],
Expand Down Expand Up @@ -857,7 +857,7 @@ struct BuildCommandTestCases {
data: BuildData,
) async throws {
let buildSystem = data.buildSystem
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
try await fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in
let buildCompleteRegex = try Regex(#"Build complete!\s?(\([0-9]*\.[0-9]*\s*s(econds)?\))?"#)
do {
Expand Down Expand Up @@ -1137,7 +1137,7 @@ struct BuildCommandTestCases {
) async throws {
try await withKnownIssue(
"error produced for this fixture",
isIntermittent: ProcessInfo.hostOperatingSystem == .linux,
isIntermittent: true,
) {
try await fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in
// Building with `-wmo` should result in a `remark: Incremental compilation has been disabled: it is not
Expand Down Expand Up @@ -1199,7 +1199,7 @@ struct BuildCommandTestCases {

try await withKnownIssue(
"https://github.com/swiftlang/swift-package-manager/issues/8659, SWIFT_EXEC override is not working",
isIntermittent: (buildSystem == .native && config == .release)
isIntermittent: true
){
// Build with a swiftc that returns version 1.0, we expect a successful build which compiles our one source
// file.
Expand Down Expand Up @@ -1294,7 +1294,7 @@ struct BuildCommandTestCases {
func getTaskAllowEntitlement(
buildSystem: BuildSystemProvider.Kind,
) async throws {
try await withKnownIssue(isIntermittent: (ProcessInfo.hostOperatingSystem == .linux)) {
try await withKnownIssue(isIntermittent: true) {
try await fixture(name: "ValidLayouts/SingleModule/ExecutableNew") { fixturePath in
#if os(macOS)
// try await building with default parameters. This should succeed. We build verbosely so we get full command
Expand Down Expand Up @@ -1506,7 +1506,7 @@ struct BuildCommandTestCases {
func parseAsLibraryCriteria(
buildData: BuildData,
) async throws {
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
try await fixture(name: "Miscellaneous/ParseAsLibrary") { fixturePath in
_ = try await executeSwiftBuild(
fixturePath,
Expand Down Expand Up @@ -1571,7 +1571,7 @@ struct BuildCommandTestCases {
) async throws {
let buildSystem = data.buildSystem
let configuration = data.config
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
// GIVEN we have a simple test package
try await fixture(name: "Miscellaneous/SwiftBuild") { fixturePath in
//WHEN we build with the --quiet option
Expand Down
4 changes: 2 additions & 2 deletions Tests/CommandsTests/CoverageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct CoverageTests {
buildSystem: BuildSystemProvider.Kind,
) async throws {
let config = BuildConfiguration.debug
try await withKnownIssue(isIntermittent: (ProcessInfo.hostOperatingSystem == .linux && buildSystem == .swiftbuild)) {
try await withKnownIssue(isIntermittent: true) {
try await fixture(name: "Miscellaneous/TestDiscovery/Simple") { path in
_ = try await executeSwiftBuild(
path,
Expand Down Expand Up @@ -96,7 +96,7 @@ struct CoverageTests {
let codeCovPath = try AbsolutePath(validating: codeCovPathString)

// WHEN we build with coverage enabled
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
try await executeSwiftBuild(
path,
configuration: config,
Expand Down
42 changes: 20 additions & 22 deletions Tests/CommandsTests/PackageCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ struct PackageCommandTests {
func describeJson(
data: BuildData,
) async throws {
try await withKnownIssue(isIntermittent: ProcessInfo.hostOperatingSystem == .windows) {
try await withKnownIssue(isIntermittent: true) {
try await fixture(name: "DependencyResolution/External/Simple/Bar") { fixturePath in
// Generate the JSON description.
let (jsonOutput, _) = try await execute(
Expand Down Expand Up @@ -1189,7 +1189,7 @@ struct PackageCommandTests {
withPrettyPrinting: Bool,
) async throws {
// try XCTSkipIf(buildSystemProvider == .native && (try? UserToolchain.default.getSymbolGraphExtract()) == nil, "skipping test because the `swift-symbolgraph-extract` tools isn't available")
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
try await fixture(
name: "DependencyResolution/Internal/Simple",
removeFixturePathOnDeinit: true
Expand Down Expand Up @@ -3069,9 +3069,7 @@ struct PackageCommandTests {
func purgeCacheWithoutPackage(
data: BuildData,
) async throws {
try await withKnownIssue(
isIntermittent: ProcessInfo.isHostAmazonLinux2() //rdar://134238535
) {
try await withKnownIssue(isIntermittent: true) {
// Create a temporary directory without Package.swift
try await fixture(name: "Miscellaneous") { fixturePath in
let tempDir = fixturePath.appending("empty-dir-for-purge-test")
Expand All @@ -3090,7 +3088,7 @@ struct PackageCommandTests {
}
}
} when: {
ProcessInfo.isHostAmazonLinux2()
ProcessInfo.isHostAmazonLinux2() //rdar://134238535
}
}

Expand Down Expand Up @@ -3428,7 +3426,7 @@ struct PackageCommandTests {
"""
)
}
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
try await testWithTemporaryDirectory { tmpPath in
let packageDir = tmpPath.appending(components: "library")
try localFileSystem.writeFileContents(
Expand Down Expand Up @@ -4403,7 +4401,7 @@ struct PackageCommandTests {
func buildToolPlugin(
data: BuildData,
) async throws {
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
try await testBuildToolPlugin(data: data, staticStdlib: false)
} when: {
ProcessInfo.hostOperatingSystem == .windows && data.buildSystem == .swiftbuild
Expand Down Expand Up @@ -4546,7 +4544,7 @@ struct PackageCommandTests {
buildSystem: data.buildSystem,
)
) { error in
withKnownIssue {
withKnownIssue(isIntermittent: true) {
#expect(error.stderr.contains("This is text from the plugin"))
#expect(error.stderr.contains("error: This is an error from the plugin"))
} when: {
Expand Down Expand Up @@ -5476,7 +5474,7 @@ struct PackageCommandTests {
) async throws {
let debugTarget = try buildData.buildSystem.binPath(for: .debug) + [executableName("placeholder")]
let releaseTarget = try buildData.buildSystem.binPath(for: .release) + [executableName("placeholder")]
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
// By default, a plugin-requested build produces a debug binary
try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
let _ = try await execute(
Expand Down Expand Up @@ -5511,7 +5509,7 @@ struct PackageCommandTests {
) async throws {
let debugTarget = try buildData.buildSystem.binPath(for: .debug) + [executableName("placeholder")]
let releaseTarget = try buildData.buildSystem.binPath(for: .release) + [executableName("placeholder")]
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
// If the plugin specifies a debug binary, that is what will be built, regardless of overall configuration
try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
let _ = try await execute(
Expand Down Expand Up @@ -5550,7 +5548,7 @@ struct PackageCommandTests {
) async throws {
let debugTarget = try buildData.buildSystem.binPath(for: .debug) + [executableName("placeholder")]
let releaseTarget = try buildData.buildSystem.binPath(for: .release) + [executableName("placeholder")]
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
// If the plugin requests a release binary, that is what will be built, regardless of overall configuration
try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
let _ = try await execute(
Expand Down Expand Up @@ -5588,7 +5586,7 @@ struct PackageCommandTests {
) async throws {
let debugTarget = try buildData.buildSystem.binPath(for: .debug) + [executableName("placeholder")]
let releaseTarget = try buildData.buildSystem.binPath(for: .release) + [executableName("placeholder")]
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
// If the plugin inherits the overall build configuration, that is what will be built
try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
let _ = try await execute(
Expand Down Expand Up @@ -5627,7 +5625,7 @@ struct PackageCommandTests {
data: BuildData,
) async throws {
// Plugin arguments: check-testability <targetName> <config> <shouldTestable>
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
// Overall configuration: debug, plugin build request: debug -> without testability
try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
let _ = await #expect(throws: Never.self) {
Expand Down Expand Up @@ -5655,7 +5653,7 @@ struct PackageCommandTests {
func commandPluginBuildTestabilityInternalModule_Release_False(
data: BuildData,
) async throws {
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
// Overall configuration: debug, plugin build request: release -> without testability
try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
let _ = await #expect(throws: Never.self) {
Expand Down Expand Up @@ -5686,7 +5684,7 @@ struct PackageCommandTests {
func commandPluginBuildTestabilityAllWithTests_Release_True(
data: BuildData,
) async throws {
try await withKnownIssue(isIntermittent: (ProcessInfo.hostOperatingSystem == .linux)) {
try await withKnownIssue(isIntermittent: true) {
// Overall configuration: release, plugin build request: release including tests -> with testability
try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
let _ = await #expect(throws: Never.self) {
Expand Down Expand Up @@ -5735,7 +5733,7 @@ struct PackageCommandTests {
// otherwise the logs may be different in subsequent tests.

// Check than nothing is echoed when echoLogs is false
try await withKnownIssue(isIntermittent: ProcessInfo.hostOperatingSystem == .windows) {
try await withKnownIssue(isIntermittent: true) {
try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
let (stdout, stderr) = try await execute( //got here
["print-diagnostics", "build"],
Expand Down Expand Up @@ -6481,7 +6479,7 @@ struct PackageCommandTests {
func commandPluginBuildingCallbacks(
data: BuildData,
) async throws {
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
try await testWithTemporaryDirectory { tmpPath in
let buildSystemProvider = data.buildSystem
// Create a sample package with a library, an executable, and a command plugin.
Expand Down Expand Up @@ -6657,7 +6655,7 @@ struct PackageCommandTests {
}

// SwiftBuild is currently not producing a static archive for static products unless they are linked into some other binary.
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
// Invoke the plugin with parameters choosing a verbose build of MyStaticLibrary for release.
do {
let (stdout, _) = try await execute(
Expand Down Expand Up @@ -6736,7 +6734,7 @@ struct PackageCommandTests {
arguments: [BuildSystemProvider.Kind.native, .swiftbuild],
)
func commandPluginBuildingCallbacksExcludeUnbuiltArtifacts(buildSystem: BuildSystemProvider.Kind) async throws {
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
try await fixture(name: "PartiallyUnusedDependency") { fixturePath in
let (stdout, _) = try await execute(
["dump-artifacts-plugin"],
Expand Down Expand Up @@ -6775,7 +6773,7 @@ struct PackageCommandTests {
func commandPluginTestingCallbacks(
data: BuildData,
) async throws {
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
try await testWithTemporaryDirectory { tmpPath in
// Create a sample package with a library, a command plugin, and a couple of tests.
let packageDir = tmpPath.appending(components: "MyPackage")
Expand Down Expand Up @@ -7477,7 +7475,7 @@ struct PackageCommandTests {
func commandPluginDynamicDependencies(
buildData: BuildData
) async throws {
try await withKnownIssue {
try await withKnownIssue(isIntermittent: true) {
try await testWithTemporaryDirectory { tmpPath in
// Create a sample package with a command plugin that has a dynamic dependency.
let packageDir = tmpPath.appending(components: "MyPackage")
Expand Down
Loading