diff --git a/Fixtures/DependencyResolution/External/XCFramework/Foo.xcframework/Info.plist b/Fixtures/DependencyResolution/External/XCFramework/Foo.xcframework/Info.plist new file mode 100644 index 00000000000..cc8593be096 --- /dev/null +++ b/Fixtures/DependencyResolution/External/XCFramework/Foo.xcframework/Info.plist @@ -0,0 +1,25 @@ + + + + + AvailableLibraries + + + LibraryIdentifier + macos-x86_64 + LibraryPath + Framework.framework + SupportedArchitectures + + x86_64 + + SupportedPlatform + macos + + + CFBundlePackageType + XFWK + XCFrameworkFormatVersion + 1.0 + + diff --git a/Fixtures/DependencyResolution/External/XCFramework/Foo/Foo.swift b/Fixtures/DependencyResolution/External/XCFramework/Foo/Foo.swift new file mode 100644 index 00000000000..ad5e70131a1 --- /dev/null +++ b/Fixtures/DependencyResolution/External/XCFramework/Foo/Foo.swift @@ -0,0 +1,3 @@ +public func foo() { + {}() +} diff --git a/Fixtures/DependencyResolution/External/XCFramework/Package.swift b/Fixtures/DependencyResolution/External/XCFramework/Package.swift new file mode 100644 index 00000000000..c6ea4ae6e8a --- /dev/null +++ b/Fixtures/DependencyResolution/External/XCFramework/Package.swift @@ -0,0 +1,14 @@ +// swift-tools-version:5.3 + +import PackageDescription + +let package = Package( + name: "Foo", + products: [ + .library(name: "Foo", targets: ["Foo", "XCFramework"]), + ], + targets: [ + .target(name: "Foo", path: "./Foo"), + .binaryTarget(name: "XCFramework", path: "./Foo.xcframework") + ] +) diff --git a/Sources/Commands/SwiftTool.swift b/Sources/Commands/SwiftTool.swift index 26aab1795cf..2cc19b40820 100644 --- a/Sources/Commands/SwiftTool.swift +++ b/Sources/Commands/SwiftTool.swift @@ -439,19 +439,6 @@ public class SwiftTool { if !options.archs.isEmpty && options.customCompileTriple != nil { diagnostics.emit(.mutuallyExclusiveArgumentsError(arguments: ["--arch", "--triple"])) } - - if options.netrcFilePath != nil { - // --netrc-file option only supported on macOS >=10.13 - #if os(macOS) - if #available(macOS 10.13, *) { - // ok, check succeeds - } else { - diagnostics.emit(error: "'--netrc-file' option is only supported on macOS >=10.13") - } - #else - diagnostics.emit(error: "'--netrc-file' option is only supported on macOS >=10.13") - #endif - } // --enable-test-discovery should never be called on darwin based platforms #if canImport(Darwin) diff --git a/Sources/Workspace/Workspace.swift b/Sources/Workspace/Workspace.swift index 2d1df3d8e0f..bdecc748d67 100644 --- a/Sources/Workspace/Workspace.swift +++ b/Sources/Workspace/Workspace.swift @@ -1589,10 +1589,8 @@ extension Workspace { let tempDiagnostics = DiagnosticsEngine() let result = ThreadSafeArrayStore() - var authProvider: AuthorizationProviding? = nil - #if os(macOS) // Netrc feature currently only supported on macOS - authProvider = try? Netrc.load(fromFileAtPath: netrcFilePath).get() - #endif + // FIXME: should this handle the error more gracefully? + let authProvider: AuthorizationProviding? = try? Netrc.load(fromFileAtPath: netrcFilePath).get() // zip files to download // stored in a thread-safe way as we may fetch more from "ari" files diff --git a/Tests/BasicsTests/URLSessionHTTPClientTests.swift b/Tests/BasicsTests/URLSessionHTTPClientTests.swift index f171f864fb5..83cb03f949f 100644 --- a/Tests/BasicsTests/URLSessionHTTPClientTests.swift +++ b/Tests/BasicsTests/URLSessionHTTPClientTests.swift @@ -17,10 +17,7 @@ import FoundationNetworking #endif import TSCBasic import TSCTestSupport -// // Netrc only available on macOS for now -#if os(macOS) import struct TSCUtility.Netrc -#endif import XCTest final class URLSessionHTTPClientTest: XCTestCase { diff --git a/Tests/CommandsTests/PackageToolTests.swift b/Tests/CommandsTests/PackageToolTests.swift index f4e55baf5ea..a310a309092 100644 --- a/Tests/CommandsTests/PackageToolTests.swift +++ b/Tests/CommandsTests/PackageToolTests.swift @@ -47,89 +47,50 @@ final class PackageToolTests: XCTestCase { let stdout = try execute(["--version"]).stdout XCTAssert(stdout.contains("Swift Package Manager"), "got stdout:\n" + stdout) } - - func testNetrcSupportedOS() throws { - func verifyUnsupportedOSThrows() { + + func testNetrcFile() throws { + fixture(name: "DependencyResolution/External/XCFramework") { packageRoot in + let fs = localFileSystem + let netrcPath = packageRoot.appending(component: ".netrc") + try fs.writeFileContents(netrcPath) { stream in + stream <<< "machine mymachine.labkey.org login user@labkey.org password mypassword" + } + do { - // should throw and be caught - try execute(["update", "--netrc-file", "/Users/me/.hidden/.netrc"]) - XCTFail() + // file at correct location + try execute(["--netrc-file", netrcPath.pathString, "resolve"], packagePath: packageRoot) + // file does not exist, but is optional + let textOutput = try execute(["--netrc-file", "/foo", "--netrc-optional", "resolve"], packagePath: packageRoot).stderr + XCTAssert(textOutput.contains("warning: Did not find optional .netrc file at /foo.")) + + // required file does not exist, will throw + try execute(["--netrc-file", "/foo", "resolve"], packagePath: packageRoot) } catch { - XCTAssert(true) + XCTAssert(String(describing: error).contains("Cannot find mandatory .netrc file at /foo"), "\(error)") } } - #if os(macOS) - if #available(macOS 10.13, *) { - // should succeed - XCTAssert(try execute(["--netrc"]).stdout.contains("USAGE: swift package")) - XCTAssert(try execute(["--netrc-file", "/Users/me/.hidden/.netrc"]).stdout.contains("USAGE: swift package")) - XCTAssert(try execute(["--netrc-optional"]).stdout.contains("USAGE: swift package")) - } else { - verifyUnsupportedOSThrows() - } - #else - verifyUnsupportedOSThrows() - #endif - } - - func testNetrcFile() throws { - #if os(macOS) - if #available(macOS 10.13, *) { - // SUPPORTED OS - fixture(name: "DependencyResolution/External/Complex") { prefix in - let packageRoot = prefix.appending(component: "app") - - let fs = localFileSystem - let netrcPath = prefix.appending(component: ".netrc") - try fs.writeFileContents(netrcPath) { stream in - stream <<< "machine mymachine.labkey.org login user@labkey.org password mypassword" - } - - do { - // file at correct location - try execute(["--netrc-file", netrcPath.pathString, "resolve"], packagePath: packageRoot) - XCTAssert(true) + + fixture(name: "DependencyResolution/External/XCFramework") { packageRoot in + do { + // Developer machine may have .netrc file at NSHomeDirectory; modify test accordingly + if localFileSystem.exists(localFileSystem.homeDirectory.appending(RelativePath(".netrc"))) { + try execute(["--netrc", "resolve"], packagePath: packageRoot) + } else { // file does not exist, but is optional - let textOutput = try execute(["--netrc-file", "/foo", "--netrc-optional", "resolve"], packagePath: packageRoot).stderr - XCTAssert(textOutput.contains("warning: Did not find optional .netrc file at /foo.")) - + let textOutput = try execute(["--netrc", "--netrc-optional", "resolve"], packagePath: packageRoot) + XCTAssert(textOutput.stderr.contains("Did not find optional .netrc file at \(localFileSystem.homeDirectory)/.netrc.")) + + // file does not exist, but is optional + let textOutput2 = try execute(["--netrc-optional", "resolve"], packagePath: packageRoot) + XCTAssert(textOutput2.stderr.contains("Did not find optional .netrc file at \(localFileSystem.homeDirectory)/.netrc.")) + // required file does not exist, will throw - try execute(["--netrc-file", "/foo", "resolve"], packagePath: packageRoot) - - } catch { - XCTAssert(String(describing: error).contains("Cannot find mandatory .netrc file at /foo")) - } - } - - fixture(name: "DependencyResolution/External/Complex") { prefix in - let packageRoot = prefix.appending(component: "app") - do { - // Developer machine may have .netrc file at NSHomeDirectory; modify test accordingly - if localFileSystem.exists(localFileSystem.homeDirectory.appending(RelativePath(".netrc"))) { - try execute(["--netrc", "resolve"], packagePath: packageRoot) - XCTAssert(true) - } else { - // file does not exist, but is optional - let textOutput = try execute(["--netrc", "--netrc-optional", "resolve"], packagePath: packageRoot) - XCTAssert(textOutput.stderr.contains("Did not find optional .netrc file at \(localFileSystem.homeDirectory)/.netrc.")) - - // file does not exist, but is optional - let textOutput2 = try execute(["--netrc-optional", "resolve"], packagePath: packageRoot) - XCTAssert(textOutput2.stderr.contains("Did not find optional .netrc file at \(localFileSystem.homeDirectory)/.netrc.")) - - // required file does not exist, will throw - try execute(["--netrc", "resolve"], packagePath: packageRoot) - } - } catch { - XCTAssert(String(describing: error).contains("Cannot find mandatory .netrc file at \(localFileSystem.homeDirectory)/.netrc")) + try execute(["--netrc", "resolve"], packagePath: packageRoot) } + } catch { + XCTAssert(String(describing: error).contains("Cannot find mandatory .netrc file at \(localFileSystem.homeDirectory)/.netrc")) } - } else { - // UNSUPPORTED OS, HANDLED ELSEWHERE } - #else - // UNSUPPORTED OS, HANDLED ELSEWHERE - #endif } func testResolve() throws {