-
Notifications
You must be signed in to change notification settings - Fork 1.4k
enable netrc on non-darwin platforms #3466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>AvailableLibraries</key> | ||
<array> | ||
<dict> | ||
<key>LibraryIdentifier</key> | ||
<string>macos-x86_64</string> | ||
<key>LibraryPath</key> | ||
<string>Framework.framework</string> | ||
<key>SupportedArchitectures</key> | ||
<array> | ||
<string>x86_64</string> | ||
</array> | ||
<key>SupportedPlatform</key> | ||
<string>macos</string> | ||
</dict> | ||
</array> | ||
<key>CFBundlePackageType</key> | ||
<string>XFWK</string> | ||
<key>XCFrameworkFormatVersion</key> | ||
<string>1.0</string> | ||
</dict> | ||
</plist> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
public func foo() { | ||
{}() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1589,10 +1589,8 @@ extension Workspace { | |
let tempDiagnostics = DiagnosticsEngine() | ||
let result = ThreadSafeArrayStore<ManagedArtifact>() | ||
|
||
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? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @neonichu do you know why the error is ignored here? topic for different PR, but curios |
||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not meaningful any longer since SwiftPM is >= 10.15 and its supported on other platforms |
||
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 [email protected] 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 [email protected] 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. new fixtures that actually uses netrc :D |
||
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 { | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not meaningful any longer since SwiftPM is >= 10.15 and its supported on other platforms