Resolve Swift 5 Warnings (#325)

- Updating SwiftPM dependency
  - `asString` has been renamed to `pathString`
  - `Utility` module has been renamed to `SPMUtility`

Test Plan:

- Verify unit tests pass `swift test`
- Verify acceptance tests pass `bundle exec rake features`
This commit is contained in:
Kas 2019-04-14 19:02:56 +01:00 committed by GitHub
parent fcbbfb14ac
commit 1dd8ace215
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
107 changed files with 281 additions and 264 deletions

View File

@ -50,8 +50,8 @@
"package": "SwiftPM", "package": "SwiftPM",
"repositoryURL": "https://github.com/apple/swift-package-manager", "repositoryURL": "https://github.com/apple/swift-package-manager",
"state": { "state": {
"branch": null, "branch": "swift-5.0-RELEASE",
"revision": "a107d28d1b40491cf505799a046fee53e7c422e1", "revision": "3a57975e10be0b1a8b87992ddf3a49701036f96c",
"version": null "version": null
} }
}, },

View File

@ -27,12 +27,12 @@ let package = Package(
], ],
dependencies: [ dependencies: [
.package(url: "https://github.com/tuist/xcodeproj.git", .revision("86b5dd403c1fcf0a7325a65b6d6f10a8a3a369b9")), .package(url: "https://github.com/tuist/xcodeproj.git", .revision("86b5dd403c1fcf0a7325a65b6d6f10a8a3a369b9")),
.package(url: "https://github.com/apple/swift-package-manager", .revision("a107d28d1b40491cf505799a046fee53e7c422e1")), .package(url: "https://github.com/apple/swift-package-manager", .branch("swift-5.0-RELEASE")),
], ],
targets: [ targets: [
.target( .target(
name: "TuistKit", name: "TuistKit",
dependencies: ["XcodeProj", "Utility", "TuistCore", "TuistGenerator", "ProjectDescription"] dependencies: ["XcodeProj", "SPMUtility", "TuistCore", "TuistGenerator", "ProjectDescription"]
), ),
.testTarget( .testTarget(
name: "TuistKitTests", name: "TuistKitTests",
@ -44,7 +44,7 @@ let package = Package(
), ),
.target( .target(
name: "TuistEnvKit", name: "TuistEnvKit",
dependencies: ["Utility", "TuistCore"] dependencies: ["SPMUtility", "TuistCore"]
), ),
.testTarget( .testTarget(
name: "TuistEnvKitTests", name: "TuistEnvKitTests",
@ -64,7 +64,7 @@ let package = Package(
), ),
.target( .target(
name: "TuistCore", name: "TuistCore",
dependencies: ["Utility"] dependencies: ["SPMUtility"]
), ),
.target( .target(
name: "TuistCoreTesting", name: "TuistCoreTesting",
@ -76,7 +76,7 @@ let package = Package(
), ),
.target( .target(
name: "TuistGenerator", name: "TuistGenerator",
dependencies: ["XcodeProj", "Utility", "TuistCore"] dependencies: ["XcodeProj", "SPMUtility", "TuistCore"]
), ),
.testTarget( .testTarget(
name: "TuistGeneratorTests", name: "TuistGeneratorTests",

View File

@ -1,4 +1,4 @@
import Utility import SPMUtility
/// Protocol that defines the interface a CLI command. /// Protocol that defines the interface a CLI command.
public protocol Command { public protocol Command {

View File

@ -12,7 +12,7 @@ extension AbsolutePath {
/// Returns the URL that references the absolute path. /// Returns the URL that references the absolute path.
public var url: URL { public var url: URL {
return URL(fileURLWithPath: asString) return URL(fileURLWithPath: pathString)
} }
/// Returns the list of paths that match the given glob pattern. /// Returns the list of paths that match the given glob pattern.
@ -20,7 +20,7 @@ extension AbsolutePath {
/// - Parameter pattern: Relative glob pattern used to match the paths. /// - Parameter pattern: Relative glob pattern used to match the paths.
/// - Returns: List of paths that match the given pattern. /// - Returns: List of paths that match the given pattern.
public func glob(_ pattern: String) -> [AbsolutePath] { public func glob(_ pattern: String) -> [AbsolutePath] {
return Glob(pattern: appending(RelativePath(pattern)).asString).paths.map { AbsolutePath($0) } return Glob(pattern: appending(RelativePath(pattern)).pathString).paths.map { AbsolutePath($0) }
} }
/// Returns the path with the last component removed. For example, given the path /// Returns the path with the last component removed. For example, given the path

View File

@ -1,4 +1,4 @@
import Utility import SPMUtility
// MARK: - FatalError // MARK: - FatalError

View File

@ -25,8 +25,8 @@ import Foundation
public extension String { public extension String {
var md5: String { var md5: String {
if let data = data(using: .utf8, allowLossyConversion: true) { if let data = data(using: .utf8, allowLossyConversion: true) {
let message = data.withUnsafeBytes { bytes -> [UInt8] in let message = data.withUnsafeBytes { (pointer) -> [UInt8] in
Array(UnsafeBufferPointer(start: bytes, count: data.count)) Array(pointer)
} }
let MD5Calculator = MD5(message) let MD5Calculator = MD5(message)

View File

@ -6,7 +6,7 @@ enum FileHandlerError: FatalError {
var description: String { var description: String {
switch self { switch self {
case let .invalidTextEncoding(path): case let .invalidTextEncoding(path):
return "The file at \(path.asString) is not a utf8 text file" return "The file at \(path.pathString) is not a utf8 text file"
} }
} }
@ -98,7 +98,7 @@ public final class FileHandler: FileHandling {
/// - Parameter path: Path to check. /// - Parameter path: Path to check.
/// - Returns: True if there's a folder or file at the given path. /// - Returns: True if there's a folder or file at the given path.
public func exists(_ path: AbsolutePath) -> Bool { public func exists(_ path: AbsolutePath) -> Bool {
return FileManager.default.fileExists(atPath: path.asString) return FileManager.default.fileExists(atPath: path.pathString)
} }
/// It copies a file or folder to another path. /// It copies a file or folder to another path.
@ -108,7 +108,7 @@ public final class FileHandler: FileHandling {
/// - to: Path where the file/folder will be copied. /// - to: Path where the file/folder will be copied.
/// - Throws: An error if from doesn't exist or to does. /// - Throws: An error if from doesn't exist or to does.
public func copy(from: AbsolutePath, to: AbsolutePath) throws { public func copy(from: AbsolutePath, to: AbsolutePath) throws {
try FileManager.default.copyItem(atPath: from.asString, toPath: to.asString) try FileManager.default.copyItem(atPath: from.pathString, toPath: to.pathString)
} }
/// Reads a text file at the given path and returns it. /// Reads a text file at the given path and returns it.
@ -136,7 +136,7 @@ public final class FileHandler: FileHandling {
} }
public func delete(_ path: AbsolutePath) throws { public func delete(_ path: AbsolutePath) throws {
try FileManager.default.removeItem(atPath: path.asString) try FileManager.default.removeItem(atPath: path.pathString)
} }
public func touch(_ path: AbsolutePath) throws { public func touch(_ path: AbsolutePath) throws {
@ -148,7 +148,7 @@ public final class FileHandler: FileHandling {
public func isFolder(_ path: AbsolutePath) -> Bool { public func isFolder(_ path: AbsolutePath) -> Bool {
var isDirectory = ObjCBool(true) var isDirectory = ObjCBool(true)
let exists = FileManager.default.fileExists(atPath: path.asString, isDirectory: &isDirectory) let exists = FileManager.default.fileExists(atPath: path.pathString, isDirectory: &isDirectory)
return exists && isDirectory.boolValue return exists && isDirectory.boolValue
} }
} }

View File

@ -14,7 +14,7 @@ enum OpeningError: FatalError, Equatable {
var description: String { var description: String {
switch self { switch self {
case let .notFound(path): case let .notFound(path):
return "Couldn't open file at path \(path.asString)" return "Couldn't open file at path \(path.pathString)"
} }
} }
@ -50,6 +50,6 @@ public class Opener: Opening {
if !fileHandler.exists(path) { if !fileHandler.exists(path) {
throw OpeningError.notFound(path) throw OpeningError.notFound(path)
} }
try system.runAndPrint("/usr/bin/open", path.asString) try system.runAndPrint("/usr/bin/open", path.pathString)
} }
} }

View File

@ -307,9 +307,9 @@ public final class System: Systeming {
let process = Process(arguments: arguments, let process = Process(arguments: arguments,
environment: environment, environment: environment,
outputRedirection: .stream(stdout: { bytes in outputRedirection: .stream(stdout: { bytes in
FileHandle.standardOutput.write(Data(bytes: bytes)) FileHandle.standardOutput.write(Data(bytes))
}, stderr: { bytes in }, stderr: { bytes in
FileHandle.standardError.write(Data(bytes: bytes)) FileHandle.standardError.write(Data(bytes))
}), verbose: verbose, }), verbose: verbose,
startNewProcessGroup: false) startNewProcessGroup: false)
try process.launch() try process.launch()

View File

@ -1,6 +1,6 @@
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
public final class MockCommand: Command { public final class MockCommand: Command {
public static let command: String = "command" public static let command: String = "command"

View File

@ -1,6 +1,6 @@
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
public final class MockHiddenCommand: HiddenCommand { public final class MockHiddenCommand: HiddenCommand {
public static var command: String = "hidden" public static var command: String = "hidden"

View File

@ -1,6 +1,6 @@
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
public final class MockRawCommand: RawCommand { public final class MockRawCommand: RawCommand {
public static var command: String = "raw" public static var command: String = "raw"

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
enum BundleCommandError: FatalError, Equatable { enum BundleCommandError: FatalError, Equatable {
case missingVersionFile(AbsolutePath) case missingVersionFile(AbsolutePath)
@ -16,7 +16,7 @@ enum BundleCommandError: FatalError, Equatable {
var description: String { var description: String {
switch self { switch self {
case let .missingVersionFile(path): case let .missingVersionFile(path):
return "Couldn't find a .tuist-version file in the directory \(path.asString)" return "Couldn't find a .tuist-version file in the directory \(path.pathString)"
} }
} }
@ -74,7 +74,7 @@ final class BundleCommand: Command {
} }
let version = try String(contentsOf: versionFilePath.url) let version = try String(contentsOf: versionFilePath.url)
printer.print(section: "Bundling the version \(version) in the directory \(binFolderPath.asString)") printer.print(section: "Bundling the version \(version) in the directory \(binFolderPath.pathString)")
let versionPath = versionsController.path(version: version) let versionPath = versionsController.path(version: version)
@ -90,6 +90,6 @@ final class BundleCommand: Command {
} }
try fileHandler.copy(from: versionPath, to: binFolderPath) try fileHandler.copy(from: versionPath, to: binFolderPath)
printer.print(success: "tuist bundled successfully at \(binFolderPath.asString)") printer.print(success: "tuist bundled successfully at \(binFolderPath.pathString)")
} }
} }

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
public final class CommandRegistry { public final class CommandRegistry {
// MARK: - Attributes // MARK: - Attributes

View File

@ -69,9 +69,9 @@ class CommandRunner: CommandRunning {
switch resolvedVersion { switch resolvedVersion {
case let .bin(path): case let .bin(path):
printer.print("Using bundled version at path \(path.asString)") printer.print("Using bundled version at path \(path.pathString)")
case let .versionFile(path, value): case let .versionFile(path, value):
printer.print("Using version \(value) defined at \(path.asString)") printer.print("Using version \(value) defined at \(path.pathString)")
default: default:
break break
} }
@ -115,7 +115,7 @@ class CommandRunner: CommandRunning {
} }
func runAtPath(_ path: AbsolutePath) throws { func runAtPath(_ path: AbsolutePath) throws {
var args = [path.appending(component: Constants.binName).asString] var args = [path.appending(component: Constants.binName).pathString]
args.append(contentsOf: Array(arguments().dropFirst())) args.append(contentsOf: Array(arguments().dropFirst()))
try system.runAndPrint(args, verbose: false, environment: ProcessInfo.processInfo.environment) try system.runAndPrint(args, verbose: false, environment: ProcessInfo.processInfo.environment)

View File

@ -1,6 +1,6 @@
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
/// Command that installs new versions of Tuist in the system. /// Command that installs new versions of Tuist in the system.
final class InstallCommand: Command { final class InstallCommand: Command {

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
class LocalCommand: Command { class LocalCommand: Command {
// MARK: - Command // MARK: - Command
@ -64,9 +64,9 @@ class LocalCommand: Command {
let currentPath = fileHandler.currentPath let currentPath = fileHandler.currentPath
printer.print(section: "Generating \(Constants.versionFileName) file with version \(version)") printer.print(section: "Generating \(Constants.versionFileName) file with version \(version)")
let tuistVersionPath = currentPath.appending(component: Constants.versionFileName) let tuistVersionPath = currentPath.appending(component: Constants.versionFileName)
try "\(version)".write(to: URL(fileURLWithPath: tuistVersionPath.asString), try "\(version)".write(to: URL(fileURLWithPath: tuistVersionPath.pathString),
atomically: true, atomically: true,
encoding: .utf8) encoding: .utf8)
printer.print(success: "File generated at path \(tuistVersionPath.asString)") printer.print(success: "File generated at path \(tuistVersionPath.pathString)")
} }
} }

View File

@ -1,6 +1,6 @@
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
final class UninstallCommand: Command { final class UninstallCommand: Command {
// MARK: - Command // MARK: - Command

View File

@ -1,6 +1,6 @@
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
/// Command that updates the version of Tuist in the environment. /// Command that updates the version of Tuist in the environment.
final class UpdateCommand: Command { final class UpdateCommand: Command {

View File

@ -1,6 +1,6 @@
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
protocol GitHubClienting: AnyObject { protocol GitHubClienting: AnyObject {
func releases() throws -> [Release] func releases() throws -> [Release]

View File

@ -1,6 +1,6 @@
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
enum ReleaseDecodeError: FatalError, Equatable { enum ReleaseDecodeError: FatalError, Equatable {
case invalidVersionFormat(String) case invalidVersionFormat(String)

View File

@ -36,9 +36,9 @@ class BuildCopier: BuildCopying {
let filePath = from.appending(component: file) let filePath = from.appending(component: file)
let toPath = to.appending(component: file) let toPath = to.appending(component: file)
if !fileHandler.exists(filePath) { return } if !fileHandler.exists(filePath) { return }
try system.run("/bin/cp", "-rf", filePath.asString, toPath.asString) try system.run("/bin/cp", "-rf", filePath.pathString, toPath.pathString)
if file == "tuist" { if file == "tuist" {
try system.run("/bin/chmod", "+x", toPath.asString) try system.run("/bin/chmod", "+x", toPath.pathString)
} }
} }
} }

View File

@ -152,11 +152,11 @@ final class Installer: Installing {
// Download bundle // Download bundle
printer.print("Downloading version from \(bundleURL.absoluteString)") printer.print("Downloading version from \(bundleURL.absoluteString)")
let downloadPath = temporaryDirectory.path.appending(component: Constants.bundleName) let downloadPath = temporaryDirectory.path.appending(component: Constants.bundleName)
try system.run("/usr/bin/curl", "-LSs", "--output", downloadPath.asString, bundleURL.absoluteString) try system.run("/usr/bin/curl", "-LSs", "--output", downloadPath.pathString, bundleURL.absoluteString)
// Unzip // Unzip
printer.print("Installing...") printer.print("Installing...")
try system.run("/usr/bin/unzip", downloadPath.asString, "-d", installationDirectory.asString) try system.run("/usr/bin/unzip", downloadPath.pathString, "-d", installationDirectory.pathString)
try createTuistVersionFile(version: version, path: installationDirectory) try createTuistVersionFile(version: version, path: installationDirectory)
printer.print("Version \(version) installed") printer.print("Version \(version) installed")
@ -171,10 +171,10 @@ final class Installer: Installing {
// Cloning and building // Cloning and building
printer.print("Pulling source code") printer.print("Pulling source code")
try system.run("/usr/bin/env", "git", "clone", Constants.gitRepositoryURL, temporaryDirectory.path.asString) try system.run("/usr/bin/env", "git", "clone", Constants.gitRepositoryURL, temporaryDirectory.path.pathString)
do { do {
try system.run("/usr/bin/env", "git", "-C", temporaryDirectory.path.asString, "checkout", version) try system.run("/usr/bin/env", "git", "-C", temporaryDirectory.path.pathString, "checkout", version)
} catch let error as SystemError { } catch let error as SystemError {
if error.description.contains("did not match any file(s) known to git") { if error.description.contains("did not match any file(s) known to git") {
throw InstallerError.versionNotFound(version) throw InstallerError.versionNotFound(version)
@ -187,12 +187,12 @@ final class Installer: Installing {
try system.run(swiftPath, "build", try system.run(swiftPath, "build",
"--product", "tuist", "--product", "tuist",
"--package-path", temporaryDirectory.path.asString, "--package-path", temporaryDirectory.path.pathString,
"--configuration", "release", "--configuration", "release",
"-Xswiftc", "-static-stdlib") "-Xswiftc", "-static-stdlib")
try system.run(swiftPath, "build", try system.run(swiftPath, "build",
"--product", "ProjectDescription", "--product", "ProjectDescription",
"--package-path", temporaryDirectory.path.asString, "--package-path", temporaryDirectory.path.pathString,
"--configuration", "release") "--configuration", "release")
if fileHandler.exists(installationDirectory) { if fileHandler.exists(installationDirectory) {

View File

@ -44,7 +44,7 @@ class SettingsController: SettingsControlling {
func settings() throws -> Settings { func settings() throws -> Settings {
let path = environmentController.settingsPath let path = environmentController.settingsPath
if !fileHandler.exists(path) { return Settings() } if !fileHandler.exists(path) { return Settings() }
let data = try Data(contentsOf: URL(fileURLWithPath: path.asString)) let data = try Data(contentsOf: URL(fileURLWithPath: path.pathString))
let decoder = JSONDecoder() let decoder = JSONDecoder()
return try decoder.decode(Settings.self, from: data) return try decoder.decode(Settings.self, from: data)
} }
@ -58,7 +58,7 @@ class SettingsController: SettingsControlling {
let data = try encoder.encode(settings) let data = try encoder.encode(settings)
let path = environmentController.settingsPath let path = environmentController.settingsPath
if fileHandler.exists(path) { try fileHandler.delete(path) } if fileHandler.exists(path) { try fileHandler.delete(path) }
let url = URL(fileURLWithPath: path.asString) let url = URL(fileURLWithPath: path.pathString)
try data.write(to: url, options: Data.WritingOptions.atomic) try data.write(to: url, options: Data.WritingOptions.atomic)
} }
} }

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
/// Protocol that defines the interface to update the environment. /// Protocol that defines the interface to update the environment.
protocol EnvUpdating { protocol EnvUpdating {
@ -49,8 +49,8 @@ final class EnvUpdater: EnvUpdating {
// Download // Download
let fileName = asset.downloadURL.lastPathComponent let fileName = asset.downloadURL.lastPathComponent
let downloadPath = directory.appending(component: fileName) let downloadPath = directory.appending(component: fileName)
try system.run("/usr/bin/curl", "-LSs", "--output", downloadPath.asString, asset.downloadURL.absoluteString) try system.run("/usr/bin/curl", "-LSs", "--output", downloadPath.pathString, asset.downloadURL.absoluteString)
try system.run("/usr/bin/unzip", "-o", downloadPath.asString, "-d", "/tmp/") try system.run("/usr/bin/unzip", "-o", downloadPath.pathString, "-d", "/tmp/")
let binaryPath = "/tmp/tuistenv" let binaryPath = "/tmp/tuistenv"
try system.run(["/bin/chmod", "+x", binaryPath]) try system.run(["/bin/chmod", "+x", binaryPath])

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
enum ResolvedVersion: Equatable { enum ResolvedVersion: Equatable {
case bin(AbsolutePath) case bin(AbsolutePath)
@ -38,7 +38,7 @@ enum VersionResolverError: FatalError, Equatable {
var description: String { var description: String {
switch self { switch self {
case let .readError(path): case let .readError(path):
return "Cannot read the version file at path \(path.asString)." return "Cannot read the version file at path \(path.pathString)."
} }
} }
@ -73,9 +73,9 @@ class VersionResolver: VersionResolving {
private func resolveTraversing(from path: AbsolutePath) throws -> ResolvedVersion { private func resolveTraversing(from path: AbsolutePath) throws -> ResolvedVersion {
let versionPath = path.appending(component: Constants.versionFileName) let versionPath = path.appending(component: Constants.versionFileName)
let binPath = path.appending(component: Constants.binFolderName) let binPath = path.appending(component: Constants.binFolderName)
if fileManager.fileExists(atPath: binPath.asString) { if fileManager.fileExists(atPath: binPath.pathString) {
return .bin(binPath) return .bin(binPath)
} else if fileManager.fileExists(atPath: versionPath.asString) { } else if fileManager.fileExists(atPath: versionPath.pathString) {
return try resolveVersionFile(path: versionPath) return try resolveVersionFile(path: versionPath)
} }
if path.components.count > 1 { if path.components.count > 1 {
@ -87,7 +87,7 @@ class VersionResolver: VersionResolving {
private func resolveVersionFile(path: AbsolutePath) throws -> ResolvedVersion { private func resolveVersionFile(path: AbsolutePath) throws -> ResolvedVersion {
var value: String! var value: String!
do { do {
value = try String(contentsOf: URL(fileURLWithPath: path.asString)) value = try String(contentsOf: URL(fileURLWithPath: path.pathString))
} catch { } catch {
throw VersionResolverError.readError(path: path) throw VersionResolverError.readError(path: path)
} }

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
protocol VersionsControlling: AnyObject { protocol VersionsControlling: AnyObject {
typealias Installation = (AbsolutePath) throws -> Void typealias Installation = (AbsolutePath) throws -> Void

View File

@ -4,6 +4,6 @@ import PathKit
extension AbsolutePath { extension AbsolutePath {
var path: Path { var path: Path {
return Path(asString) return Path(pathString)
} }
} }

View File

@ -9,7 +9,7 @@ enum BuildPhaseGenerationError: FatalError, Equatable {
var description: String { var description: String {
switch self { switch self {
case let .missingFileReference(path): case let .missingFileReference(path):
return "Trying to add a file at path \(path.asString) to a build phase that hasn't been added to the project." return "Trying to add a file at path \(path.pathString) to a build phase that hasn't been added to the project."
} }
} }
@ -159,7 +159,7 @@ final class BuildPhaseGenerator: BuildPhaseGenerating {
pbxproj: PBXProj, pbxproj: PBXProj,
resourcesBuildPhase: PBXResourcesBuildPhase) throws { resourcesBuildPhase: PBXResourcesBuildPhase) throws {
try files.forEach { buildFilePath in try files.forEach { buildFilePath in
let pathString = buildFilePath.asString let pathString = buildFilePath.pathString
let pathRange = NSRange(location: 0, length: pathString.count) let pathRange = NSRange(location: 0, length: pathString.count)
let isLocalized = ProjectFileElements.localizedRegex.firstMatch(in: pathString, options: [], range: pathRange) != nil let isLocalized = ProjectFileElements.localizedRegex.firstMatch(in: pathString, options: [], range: pathRange) != nil
let isLproj = buildFilePath.extension == "lproj" let isLproj = buildFilePath.extension == "lproj"

View File

@ -154,10 +154,10 @@ final class ConfigGenerator: ConfigGenerating {
/// Target attributes /// Target attributes
settings["PRODUCT_BUNDLE_IDENTIFIER"] = target.bundleId settings["PRODUCT_BUNDLE_IDENTIFIER"] = target.bundleId
if let infoPlist = target.infoPlist { if let infoPlist = target.infoPlist {
settings["INFOPLIST_FILE"] = "$(SRCROOT)/\(infoPlist.relative(to: sourceRootPath).asString)" settings["INFOPLIST_FILE"] = "$(SRCROOT)/\(infoPlist.relative(to: sourceRootPath).pathString)"
} }
if let entitlements = target.entitlements { if let entitlements = target.entitlements {
settings["CODE_SIGN_ENTITLEMENTS"] = "$(SRCROOT)/\(entitlements.relative(to: sourceRootPath).asString)" settings["CODE_SIGN_ENTITLEMENTS"] = "$(SRCROOT)/\(entitlements.relative(to: sourceRootPath).pathString)"
} }
settings["SDKROOT"] = target.platform.xcodeSdkRoot settings["SDKROOT"] = target.platform.xcodeSdkRoot
settings["SUPPORTED_PLATFORMS"] = target.platform.xcodeSupportedPlatforms settings["SUPPORTED_PLATFORMS"] = target.platform.xcodeSupportedPlatforms

View File

@ -37,7 +37,7 @@ final class GeneratedProject {
/// - Parameter path: Path to the project (.xcodeproj) /// - Parameter path: Path to the project (.xcodeproj)
/// - Returns: GeneratedProject instance. /// - Returns: GeneratedProject instance.
func at(path: AbsolutePath) throws -> GeneratedProject { func at(path: AbsolutePath) throws -> GeneratedProject {
let xcode = try XcodeProj(pathString: path.asString) let xcode = try XcodeProj(pathString: path.pathString)
return GeneratedProject(pbxproj: xcode.pbxproj, return GeneratedProject(pbxproj: xcode.pbxproj,
path: path, path: path,

View File

@ -13,7 +13,7 @@ enum LinkGeneratorError: FatalError, Equatable {
case let .missingProduct(name): case let .missingProduct(name):
return "Couldn't find a reference for the product \(name)." return "Couldn't find a reference for the product \(name)."
case let .missingReference(path): case let .missingReference(path):
return "Couldn't find a reference for the file at path \(path.asString)." return "Couldn't find a reference for the file at path \(path.pathString)."
case let .missingConfigurationList(targetName): case let .missingConfigurationList(targetName):
return "The target \(targetName) doesn't have a configuration list." return "The target \(targetName) doesn't have a configuration list."
} }
@ -148,9 +148,9 @@ final class LinkGenerator: LinkGenerating {
try dependencies.forEach { dependency in try dependencies.forEach { dependency in
if case let DependencyReference.absolute(path) = dependency { if case let DependencyReference.absolute(path) = dependency {
let relativePath = "$(SRCROOT)/\(path.relative(to: sourceRootPath).asString)" let relativePath = "$(SRCROOT)/\(path.relative(to: sourceRootPath).pathString)"
let binary = binaryLocator.copyFrameworksBinary() let binary = binaryLocator.copyFrameworksBinary()
script.append("\(binary) embed \(path.relative(to: sourceRootPath).asString)") script.append("\(binary) embed \(path.relative(to: sourceRootPath).pathString)")
precompiledEmbedPhase.inputPaths.append(relativePath) precompiledEmbedPhase.inputPaths.append(relativePath)
precompiledEmbedPhase.outputPaths.append("$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/\(path.components.last!)") precompiledEmbedPhase.outputPaths.append("$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/\(path.components.last!)")
@ -218,7 +218,7 @@ final class LinkGenerator: LinkGenerating {
pbxTarget: PBXTarget, pbxTarget: PBXTarget,
sourceRootPath: AbsolutePath) throws { sourceRootPath: AbsolutePath) throws {
let relativePaths = paths let relativePaths = paths
.map { $0.relative(to: sourceRootPath).asString } .map { $0.relative(to: sourceRootPath).pathString }
.map { "$(SRCROOT)/\($0)" } .map { "$(SRCROOT)/\($0)" }
guard let configurationList = pbxTarget.buildConfigurationList else { guard let configurationList = pbxTarget.buildConfigurationList else {
throw LinkGeneratorError.missingConfigurationList(targetName: pbxTarget.name) throw LinkGeneratorError.missingConfigurationList(targetName: pbxTarget.name)

View File

@ -72,7 +72,7 @@ class ProjectDirectoryHelper: ProjectDirectoryHelping {
func setupDirectory(name: String, path: AbsolutePath, directory: GenerationDirectory) throws -> AbsolutePath { func setupDirectory(name: String, path: AbsolutePath, directory: GenerationDirectory) throws -> AbsolutePath {
switch directory { switch directory {
case .derivedProjects: case .derivedProjects:
let md5 = path.asString.md5 let md5 = path.pathString.md5
let path = environmentController.derivedProjectsDirectory.appending(component: "\(name)-\(md5)") let path = environmentController.derivedProjectsDirectory.appending(component: "\(name)-\(md5)")
if !fileHandler.exists(path) { if !fileHandler.exists(path) {
try fileHandler.createFolder(path) try fileHandler.createFolder(path)

View File

@ -380,7 +380,7 @@ class ProjectFileElements {
pbxproj: PBXProj) -> (element: PBXFileElement, path: AbsolutePath) { pbxproj: PBXProj) -> (element: PBXFileElement, path: AbsolutePath) {
let versionGroupType = Xcode.filetype(extension: folderRelativePath.extension!) let versionGroupType = Xcode.filetype(extension: folderRelativePath.extension!)
let group = XCVersionGroup(currentVersion: nil, let group = XCVersionGroup(currentVersion: nil,
path: folderRelativePath.asString, path: folderRelativePath.pathString,
name: name, name: name,
sourceTree: .group, sourceTree: .group,
versionGroupType: versionGroupType) versionGroupType: versionGroupType)
@ -396,7 +396,7 @@ class ProjectFileElements {
name: String?, name: String?,
toGroup: PBXGroup, toGroup: PBXGroup,
pbxproj: PBXProj) -> (element: PBXFileElement, path: AbsolutePath) { pbxproj: PBXProj) -> (element: PBXFileElement, path: AbsolutePath) {
let group = PBXGroup(children: [], sourceTree: .group, name: name, path: folderRelativePath.asString) let group = PBXGroup(children: [], sourceTree: .group, name: name, path: folderRelativePath.pathString)
pbxproj.add(object: group) pbxproj.add(object: group)
toGroup.children.append(group) toGroup.children.append(group)
elements[folderAbsolutePath] = group elements[folderAbsolutePath] = group
@ -410,7 +410,7 @@ class ProjectFileElements {
toGroup: PBXGroup, toGroup: PBXGroup,
pbxproj: PBXProj) { pbxproj: PBXProj) {
let lastKnownFileType = fileAbsolutePath.extension.flatMap { Xcode.filetype(extension: $0) } let lastKnownFileType = fileAbsolutePath.extension.flatMap { Xcode.filetype(extension: $0) }
let file = PBXFileReference(sourceTree: .group, name: name, lastKnownFileType: lastKnownFileType, path: fileRelativePath.asString) let file = PBXFileReference(sourceTree: .group, name: name, lastKnownFileType: lastKnownFileType, path: fileRelativePath.pathString)
pbxproj.add(object: file) pbxproj.add(object: file)
toGroup.children.append(file) toGroup.children.append(file)
elements[fileAbsolutePath] = file elements[fileAbsolutePath] = file
@ -447,7 +447,7 @@ class ProjectFileElements {
/// - Example: /// - Example:
/// /test/es.lproj/Main.storyboard ~> /test/es.lproj /// /test/es.lproj/Main.storyboard ~> /test/es.lproj
func normalize(_ path: AbsolutePath) -> AbsolutePath { func normalize(_ path: AbsolutePath) -> AbsolutePath {
let pathString = path.asString let pathString = path.pathString
let range = NSRange(location: 0, length: pathString.count) let range = NSRange(location: 0, length: pathString.count)
if let localizedMatch = ProjectFileElements.localizedRegex.firstMatch(in: pathString, if let localizedMatch = ProjectFileElements.localizedRegex.firstMatch(in: pathString,
options: [], options: [],

View File

@ -68,7 +68,7 @@ class ProjectGroups {
sourceRootPath: AbsolutePath, sourceRootPath: AbsolutePath,
playgrounds: Playgrounding = Playgrounds()) -> ProjectGroups { playgrounds: Playgrounding = Playgrounds()) -> ProjectGroups {
/// Main /// Main
let projectRelativePath = project.path.relative(to: sourceRootPath).asString let projectRelativePath = project.path.relative(to: sourceRootPath).pathString
let mainGroup = PBXGroup(children: [], let mainGroup = PBXGroup(children: [],
sourceTree: .group, sourceTree: .group,
path: (projectRelativePath != ".") ? projectRelativePath : nil) path: (projectRelativePath != ".") ? projectRelativePath : nil)

View File

@ -147,7 +147,7 @@ final class WorkspaceGenerator: WorkspaceGenerating {
/// ///
/// - Parameter path: The relative path to the file /// - Parameter path: The relative path to the file
private func workspaceFileElement(path: RelativePath) -> XCWorkspaceDataElement { private func workspaceFileElement(path: RelativePath) -> XCWorkspaceDataElement {
let location = XCWorkspaceDataElementLocationType.group(path.asString) let location = XCWorkspaceDataElementLocationType.group(path.pathString)
let fileRef = XCWorkspaceDataFileRef(location: location) let fileRef = XCWorkspaceDataFileRef(location: location)
return .file(fileRef) return .file(fileRef)
} }
@ -211,7 +211,7 @@ final class WorkspaceGenerator: WorkspaceGenerating {
return workspaceFileElement(path: folderPath.relative(to: path)) return workspaceFileElement(path: folderPath.relative(to: path))
case let .group(name: name, path: groupPath, contents: contents): case let .group(name: name, path: groupPath, contents: contents):
let location = XCWorkspaceDataElementLocationType.group(groupPath.relative(to: path).asString) let location = XCWorkspaceDataElementLocationType.group(groupPath.relative(to: path).pathString)
let groupReference = XCWorkspaceDataGroup( let groupReference = XCWorkspaceDataGroup(
location: location, location: location,

View File

@ -202,13 +202,13 @@ extension DirectoryStructure.Node: CustomDebugStringConvertible {
var debugDescription: String { var debugDescription: String {
switch self { switch self {
case let .file(path): case let .file(path):
return "file: \(path.asString)" return "file: \(path.pathString)"
case let .project(path): case let .project(path):
return "project: \(path.asString)" return "project: \(path.pathString)"
case let .directory(path, graph): case let .directory(path, graph):
return "directory: \(path.asString) > \(graph.nodes)" return "directory: \(path.pathString) > \(graph.nodes)"
case let .folderReference(path): case let .folderReference(path):
return "folderReference: \(path.asString)" return "folderReference: \(path.pathString)"
} }
} }
} }

View File

@ -33,18 +33,18 @@ enum GraphLoadingError: FatalError, Equatable {
var description: String { var description: String {
switch self { switch self {
case let .manifestNotFound(path): case let .manifestNotFound(path):
return "Couldn't find manifest at path: '\(path.asString)'" return "Couldn't find manifest at path: '\(path.pathString)'"
case let .targetNotFound(targetName, path): case let .targetNotFound(targetName, path):
return "Couldn't find target '\(targetName)' at '\(path.asString)'" return "Couldn't find target '\(targetName)' at '\(path.pathString)'"
case let .missingFile(path): case let .missingFile(path):
return "Couldn't find file at path '\(path.asString)'" return "Couldn't find file at path '\(path.pathString)'"
case let .unexpected(message): case let .unexpected(message):
return message return message
case let .circularDependency(from, to): case let .circularDependency(from, to):
var message = "" var message = ""
message.append("Found circular dependency between the target") message.append("Found circular dependency between the target")
message.append(" '\(from.name)' at '\(from.path.asString)'") message.append(" '\(from.name)' at '\(from.path.pathString)'")
message.append(" and the target '\(to.name)' at '\(to.path.asString)'") message.append(" and the target '\(to.name)' at '\(to.path.pathString)'")
return message return message
} }
} }

View File

@ -126,7 +126,7 @@ enum PrecompiledNodeError: FatalError, Equatable {
var description: String { var description: String {
switch self { switch self {
case let .architecturesNotFound(path): case let .architecturesNotFound(path):
return "Couldn't find architectures for binary at path \(path.asString)" return "Couldn't find architectures for binary at path \(path.pathString)"
} }
} }
@ -164,7 +164,7 @@ class PrecompiledNode: GraphNode {
} }
func architectures(system: Systeming = System()) throws -> [Architecture] { func architectures(system: Systeming = System()) throws -> [Architecture] {
let result = try system.capture("/usr/bin/lipo", "-info", binaryPath.asString).spm_chuzzle() ?? "" let result = try system.capture("/usr/bin/lipo", "-info", binaryPath.pathString).spm_chuzzle() ?? ""
let regex = try NSRegularExpression(pattern: ".+:\\s.+\\sis\\sarchitecture:\\s(.+)", options: []) let regex = try NSRegularExpression(pattern: ".+:\\s.+\\sis\\sarchitecture:\\s(.+)", options: [])
guard let match = regex.firstMatch(in: result, options: [], range: NSRange(location: 0, length: result.count)) else { guard let match = regex.firstMatch(in: result, options: [], range: NSRange(location: 0, length: result.count)) else {
throw PrecompiledNodeError.architecturesNotFound(binaryPath) throw PrecompiledNodeError.architecturesNotFound(binaryPath)
@ -174,7 +174,7 @@ class PrecompiledNode: GraphNode {
} }
func linking(system: Systeming = System()) throws -> Linking { func linking(system: Systeming = System()) throws -> Linking {
let result = try system.capture("/usr/bin/file", binaryPath.asString).spm_chuzzle() ?? "" let result = try system.capture("/usr/bin/file", binaryPath.pathString).spm_chuzzle() ?? ""
return result.contains("dynamically linked") ? .dynamic : .static return result.contains("dynamically linked") ? .dynamic : .static
} }
} }
@ -191,7 +191,7 @@ class FrameworkNode: PrecompiledNode {
} }
var isCarthage: Bool { var isCarthage: Bool {
return path.asString.contains("Carthage/Build") return path.pathString.contains("Carthage/Build")
} }
override var binaryPath: AbsolutePath { override var binaryPath: AbsolutePath {

View File

@ -64,10 +64,10 @@ class GraphLinter: GraphLinting {
let carthageIssues = carthageFrameworks let carthageIssues = carthageFrameworks
.filter { !fileHandler.exists($0.path) } .filter { !fileHandler.exists($0.path) }
.map { LintingIssue(reason: "Framework not found at path \($0.path.asString). The path might be wrong or Carthage dependencies not fetched", severity: .warning) } .map { LintingIssue(reason: "Framework not found at path \($0.path.pathString). The path might be wrong or Carthage dependencies not fetched", severity: .warning) }
let nonCarthageIssues = nonCarthageFrameworks let nonCarthageIssues = nonCarthageFrameworks
.filter { !fileHandler.exists($0.path) } .filter { !fileHandler.exists($0.path) }
.map { LintingIssue(reason: "Framework not found at path \($0.path.asString)", severity: .error) } .map { LintingIssue(reason: "Framework not found at path \($0.path.pathString)", severity: .error) }
var issues: [LintingIssue] = [] var issues: [LintingIssue] = []
issues.append(contentsOf: carthageIssues) issues.append(contentsOf: carthageIssues)

View File

@ -47,7 +47,7 @@ class ProjectLinter: ProjectLinting {
.filter { $0.value > 1 } .filter { $0.value > 1 }
.keys .keys
if !duplicatedTargets.isEmpty { if !duplicatedTargets.isEmpty {
let issue = LintingIssue(reason: "Targets \(duplicatedTargets.joined(separator: ", ")) from project at \(project.path.asString) have duplicates.", let issue = LintingIssue(reason: "Targets \(duplicatedTargets.joined(separator: ", ")) from project at \(project.path.pathString) have duplicates.",
severity: .error) severity: .error)
issues.append(issue) issues.append(issue)
} }

View File

@ -32,7 +32,7 @@ final class SettingsLinter: SettingsLinting {
let lintPath: (AbsolutePath) -> Void = { path in let lintPath: (AbsolutePath) -> Void = { path in
if !self.fileHandler.exists(path) { if !self.fileHandler.exists(path) {
issues.append(LintingIssue(reason: "Configuration file not found at path \(path.asString)", severity: .error)) issues.append(LintingIssue(reason: "Configuration file not found at path \(path.pathString)", severity: .error))
} }
} }

View File

@ -55,7 +55,7 @@ class TargetActionLinter: TargetActionLinting {
func lintPathExistence(_ action: TargetAction) -> [LintingIssue] { func lintPathExistence(_ action: TargetAction) -> [LintingIssue] {
guard let path = action.path else { return [] } guard let path = action.path else { return [] }
if fileHandler.exists(path) { return [] } if fileHandler.exists(path) { return [] }
return [LintingIssue(reason: "The action path \(path.asString) doesn't exist", return [LintingIssue(reason: "The action path \(path.pathString) doesn't exist",
severity: .error)] severity: .error)]
} }
} }

View File

@ -77,15 +77,15 @@ class TargetLinter: TargetLinting {
var issues: [LintingIssue] = [] var issues: [LintingIssue] = []
let files = target.resources.map(\.path) let files = target.resources.map(\.path)
let infoPlists = files.filter { $0.asString.contains("Info.plist") } let infoPlists = files.filter { $0.pathString.contains("Info.plist") }
let entitlements = files.filter { $0.asString.contains(".entitlements") } let entitlements = files.filter { $0.pathString.contains(".entitlements") }
issues.append(contentsOf: infoPlists.map { issues.append(contentsOf: infoPlists.map {
let reason = "Info.plist at path \($0.asString) being copied into the target \(target.name) product." let reason = "Info.plist at path \($0.pathString) being copied into the target \(target.name) product."
return LintingIssue(reason: reason, severity: .warning) return LintingIssue(reason: reason, severity: .warning)
}) })
issues.append(contentsOf: entitlements.map { issues.append(contentsOf: entitlements.map {
let reason = "Entitlements file at path \($0.asString) being copied into the target \(target.name) product." let reason = "Entitlements file at path \($0.pathString) being copied into the target \(target.name) product."
return LintingIssue(reason: reason, severity: .warning) return LintingIssue(reason: reason, severity: .warning)
}) })
@ -97,7 +97,7 @@ class TargetLinter: TargetLinting {
private func lintInfoplistExists(target: Target) -> [LintingIssue] { private func lintInfoplistExists(target: Target) -> [LintingIssue] {
var issues: [LintingIssue] = [] var issues: [LintingIssue] = []
if let infoPlist = target.infoPlist, !fileHandler.exists(infoPlist) { if let infoPlist = target.infoPlist, !fileHandler.exists(infoPlist) {
issues.append(LintingIssue(reason: "Info.plist file not found at path \(infoPlist.asString)", severity: .error)) issues.append(LintingIssue(reason: "Info.plist file not found at path \(infoPlist.pathString)", severity: .error))
} }
return issues return issues
} }
@ -105,7 +105,7 @@ class TargetLinter: TargetLinting {
private func lintEntitlementsExist(target: Target) -> [LintingIssue] { private func lintEntitlementsExist(target: Target) -> [LintingIssue] {
var issues: [LintingIssue] = [] var issues: [LintingIssue] = []
if let path = target.entitlements, !fileHandler.exists(path) { if let path = target.entitlements, !fileHandler.exists(path) {
issues.append(LintingIssue(reason: "Entitlements file not found at path \(path.asString)", severity: .error)) issues.append(LintingIssue(reason: "Entitlements file not found at path \(path.pathString)", severity: .error))
} }
return issues return issues
} }

View File

@ -58,7 +58,7 @@ public struct TargetAction {
func shellScript(sourceRootPath: AbsolutePath, func shellScript(sourceRootPath: AbsolutePath,
system: Systeming = System()) throws -> String { system: Systeming = System()) throws -> String {
if let path = path { if let path = path {
return "\(path.relative(to: sourceRootPath).asString) \(arguments.joined(separator: " "))" return "\(path.relative(to: sourceRootPath).pathString) \(arguments.joined(separator: " "))"
} else { } else {
return try "\(system.which(tool!).spm_chomp().spm_chuzzle()!) \(arguments.joined(separator: " "))" return try "\(system.which(tool!).spm_chomp().spm_chuzzle()!) \(arguments.joined(separator: " "))"
} }

View File

@ -27,7 +27,7 @@ final class BinaryLocator: BinaryLocating {
func copyFrameworksBinary() -> String { func copyFrameworksBinary() -> String {
let debugPathPatterns = [".build/", "DerivedData"] let debugPathPatterns = [".build/", "DerivedData"]
if let launchPath = CommandLine.arguments.first, debugPathPatterns.contains(where: { launchPath.contains($0) }) { if let launchPath = CommandLine.arguments.first, debugPathPatterns.contains(where: { launchPath.contains($0) }) {
return AbsolutePath(launchPath, relativeTo: fileHandler.currentPath).asString return AbsolutePath(launchPath, relativeTo: fileHandler.currentPath).pathString
} }
return "tuist" return "tuist"
} }

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
enum BuildCommandError: FatalError { enum BuildCommandError: FatalError {
// Error description // Error description

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
public final class CommandRegistry { public final class CommandRegistry {
// MARK: - Attributes // MARK: - Attributes

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
class CreateIssueCommand: NSObject, Command { class CreateIssueCommand: NSObject, Command {
static let createIssueUrl: String = "https://github.com/tuist/tuist/issues/new" static let createIssueUrl: String = "https://github.com/tuist/tuist/issues/new"

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
class DumpCommand: NSObject, Command { class DumpCommand: NSObject, Command {
// MARK: - Command // MARK: - Command

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
enum EmbedCommandError: FatalError { enum EmbedCommandError: FatalError {
case missingFrameworkPath case missingFrameworkPath
@ -57,7 +57,7 @@ final class EmbedCommand: HiddenCommand {
throw EmbedCommandError.missingFrameworkPath throw EmbedCommandError.missingFrameworkPath
} }
let path = RelativePath(pathString) let path = RelativePath(pathString)
printer.print("Embedding framework \(path.asString)") printer.print("Embedding framework \(path.pathString)")
try embedder.embed(path: path) try embedder.embed(path: path)
printer.print(success: "Framework embedded") printer.print(success: "Framework embedded")
} }

View File

@ -1,8 +1,8 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import TuistGenerator import TuistGenerator
import Utility
/// The focus command generates the Xcode workspace and launches it on Xcode. /// The focus command generates the Xcode workspace and launches it on Xcode.
class FocusCommand: NSObject, Command { class FocusCommand: NSObject, Command {

View File

@ -1,8 +1,8 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import TuistGenerator import TuistGenerator
import Utility
class GenerateCommand: NSObject, Command { class GenerateCommand: NSObject, Command {
// MARK: - Static // MARK: - Static

View File

@ -1,8 +1,8 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import TuistGenerator import TuistGenerator
import Utility
private typealias Platform = TuistGenerator.Platform private typealias Platform = TuistGenerator.Platform
private typealias Product = TuistGenerator.Product private typealias Product = TuistGenerator.Product
@ -18,9 +18,9 @@ enum InitCommandError: FatalError, Equatable {
var description: String { var description: String {
switch self { switch self {
case let .ungettableProjectName(path): case let .ungettableProjectName(path):
return "Couldn't infer the project name from path \(path.asString)." return "Couldn't infer the project name from path \(path.pathString)."
case let .nonEmptyDirectory(path): case let .nonEmptyDirectory(path):
return "Can't initialize a project in the non-empty directory at path \(path.asString)." return "Can't initialize a project in the non-empty directory at path \(path.pathString)."
} }
} }
@ -113,7 +113,7 @@ class InitCommand: NSObject, Command {
try generatePlaygrounds(name: name, path: path, platform: platform) try generatePlaygrounds(name: name, path: path, platform: platform)
try generateGitIgnore(path: path) try generateGitIgnore(path: path)
try generateSetup(path: path) try generateSetup(path: path)
printer.print(success: "Project generated at path \(path.asString).") printer.print(success: "Project generated at path \(path.pathString).")
} }
// MARK: - Fileprivate // MARK: - Fileprivate

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
/// Command that configures the environment to work on the project. /// Command that configures the environment to work on the project.
class UpCommand: NSObject, Command { class UpCommand: NSObject, Command {

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
class VersionCommand: NSObject, Command { class VersionCommand: NSObject, Command {
// MARK: - Command // MARK: - Command

View File

@ -24,9 +24,9 @@ enum EmbeddableError: FatalError, Equatable {
var description: String { var description: String {
switch self { switch self {
case let .missingBundleExecutable(path): case let .missingBundleExecutable(path):
return "Couldn't find executable in bundle at path \(path.asString)" return "Couldn't find executable in bundle at path \(path.pathString)"
case let .unstrippableNonFatEmbeddable(path): case let .unstrippableNonFatEmbeddable(path):
return "Can't strip architectures from the non-fat package at path \(path.asString)" return "Can't strip architectures from the non-fat package at path \(path.pathString)"
} }
} }
@ -61,7 +61,7 @@ final class Embeddable {
// MARK: - Package Information // MARK: - Package Information
func binaryPath() throws -> AbsolutePath? { func binaryPath() throws -> AbsolutePath? {
guard let bundle = Bundle(path: path.asString) else { return nil } guard let bundle = Bundle(path: path.pathString) else { return nil }
guard let packageType = packageType() else { return nil } guard let packageType = packageType() else { return nil }
switch packageType { switch packageType {
case .framework, .bundle: case .framework, .bundle:
@ -70,7 +70,7 @@ final class Embeddable {
} }
return path.appending(RelativePath(bundleExecutable)) return path.appending(RelativePath(bundleExecutable))
case .dSYM: case .dSYM:
let binaryName = URL(fileURLWithPath: path.asString) let binaryName = URL(fileURLWithPath: path.pathString)
.deletingPathExtension() .deletingPathExtension()
.deletingPathExtension() .deletingPathExtension()
.lastPathComponent .lastPathComponent
@ -82,7 +82,7 @@ final class Embeddable {
} }
func packageType() -> EmbeddableType? { func packageType() -> EmbeddableType? {
guard let bundle = Bundle(path: path.asString) else { return nil } guard let bundle = Bundle(path: path.pathString) else { return nil }
guard let bundlePackageType = bundle.object(forInfoDictionaryKey: "CFBundlePackageType") as? String else { guard let bundlePackageType = bundle.object(forInfoDictionaryKey: "CFBundlePackageType") as? String else {
return nil return nil
} }
@ -91,7 +91,7 @@ final class Embeddable {
func architectures(system: Systeming = System()) throws -> [String] { func architectures(system: Systeming = System()) throws -> [String] {
guard let binPath = try binaryPath() else { return [] } guard let binPath = try binaryPath() else { return [] }
let lipoResult = try system.capture("/usr/bin/lipo", "-info", binPath.asString).spm_chuzzle() ?? "" let lipoResult = try system.capture("/usr/bin/lipo", "-info", binPath.pathString).spm_chuzzle() ?? ""
var characterSet = CharacterSet.alphanumerics var characterSet = CharacterSet.alphanumerics
characterSet.insert(charactersIn: " _-") characterSet.insert(charactersIn: " _-")
let scanner = Scanner(string: lipoResult) let scanner = Scanner(string: lipoResult)
@ -103,7 +103,7 @@ final class Embeddable {
// Architectures in the fat file: PathToBinary are: armv7 arm64 // Architectures in the fat file: PathToBinary are: armv7 arm64
// //
var architectures: NSString? var architectures: NSString?
scanner.scanString(binPath.asString, into: nil) scanner.scanString(binPath.pathString, into: nil)
scanner.scanString("are:", into: nil) scanner.scanString("are:", into: nil)
scanner.scanCharacters(from: characterSet, into: &architectures) scanner.scanCharacters(from: characterSet, into: &architectures)
let components = architectures? let components = architectures?
@ -120,7 +120,7 @@ final class Embeddable {
// Non-fat file: PathToBinary is architecture: x86_64 // Non-fat file: PathToBinary is architecture: x86_64
// //
var architecture: NSString? var architecture: NSString?
scanner.scanString(binPath.asString, into: nil) scanner.scanString(binPath.pathString, into: nil)
scanner.scanString("is architecture:", into: nil) scanner.scanString("is architecture:", into: nil)
scanner.scanCharacters(from: characterSet, into: &architecture) scanner.scanCharacters(from: characterSet, into: &architecture)
if let architecture = architecture { if let architecture = architecture {
@ -170,7 +170,7 @@ final class Embeddable {
private func stripArchitecture(packagePath: AbsolutePath, private func stripArchitecture(packagePath: AbsolutePath,
architecture: String, architecture: String,
system: Systeming = System()) throws { system: Systeming = System()) throws {
try system.run("/usr/bin/lipo", "-remove", architecture, "-output", packagePath.asString, packagePath.asString) try system.run("/usr/bin/lipo", "-remove", architecture, "-output", packagePath.pathString, packagePath.pathString)
} }
private func stripHeaders(frameworkPath: AbsolutePath) throws { private func stripHeaders(frameworkPath: AbsolutePath) throws {
@ -217,7 +217,7 @@ final class Embeddable {
private func uuidsFromDwarfdump(path: AbsolutePath, private func uuidsFromDwarfdump(path: AbsolutePath,
system: Systeming = System()) throws -> Set<UUID> { system: Systeming = System()) throws -> Set<UUID> {
let result = try system.capture("/usr/bin/dwarfdump", "--uuid", path.asString).spm_chuzzle() ?? "" let result = try system.capture("/usr/bin/dwarfdump", "--uuid", path.pathString).spm_chuzzle() ?? ""
var uuidCharacterSet = CharacterSet() var uuidCharacterSet = CharacterSet()
uuidCharacterSet.formUnion(.letters) uuidCharacterSet.formUnion(.letters)
uuidCharacterSet.formUnion(.decimalDigits) uuidCharacterSet.formUnion(.decimalDigits)

View File

@ -51,7 +51,7 @@ final class FrameworkEmbedder: FrameworkEmbedding {
} }
let builtProductsDir = AbsolutePath(environment.builtProductsDir) let builtProductsDir = AbsolutePath(environment.builtProductsDir)
let frameworkAbsolutePath = srcRoot.appending(frameworkPath) let frameworkAbsolutePath = srcRoot.appending(frameworkPath)
let frameworkDsymPath = AbsolutePath("\(frameworkAbsolutePath.asString).dSYM") let frameworkDsymPath = AbsolutePath("\(frameworkAbsolutePath.pathString).dSYM")
let productFrameworksPath = destinationPath.appending(frameworksPath) let productFrameworksPath = destinationPath.appending(frameworksPath)
let embeddable = Embeddable(path: frameworkAbsolutePath) let embeddable = Embeddable(path: frameworkAbsolutePath)

View File

@ -21,7 +21,7 @@ enum GeneratorModelLoaderError: Error, Equatable, FatalError {
case let .featureNotYetSupported(details): case let .featureNotYetSupported(details):
return "\(details) is not yet supported" return "\(details) is not yet supported"
case let .missingFile(path): case let .missingFile(path):
return "Couldn't find file at path '\(path.asString)'" return "Couldn't find file at path '\(path.pathString)'"
} }
} }
} }

View File

@ -15,11 +15,11 @@ enum GraphManifestLoaderError: FatalError, Equatable {
var description: String { var description: String {
switch self { switch self {
case let .projectDescriptionNotFound(path): case let .projectDescriptionNotFound(path):
return "Couldn't find ProjectDescription.framework at path \(path.asString)" return "Couldn't find ProjectDescription.framework at path \(path.pathString)"
case let .unexpectedOutput(path): case let .unexpectedOutput(path):
return "Unexpected output trying to parse the manifest at path \(path.asString)" return "Unexpected output trying to parse the manifest at path \(path.pathString)"
case let .manifestNotFound(manifest, path): case let .manifestNotFound(manifest, path):
return "\(manifest?.fileName ?? "Manifest") not found at path \(path.asString)" return "\(manifest?.fileName ?? "Manifest") not found at path \(path.pathString)"
} }
} }
@ -171,12 +171,12 @@ class GraphManifestLoader: GraphManifestLoading {
"swiftc", "swiftc",
"--driver-mode=swift", "--driver-mode=swift",
"-suppress-warnings", "-suppress-warnings",
"-I", projectDescriptionPath.parentDirectory.asString, "-I", projectDescriptionPath.parentDirectory.pathString,
"-L", projectDescriptionPath.parentDirectory.asString, "-L", projectDescriptionPath.parentDirectory.pathString,
"-F", projectDescriptionPath.parentDirectory.asString, "-F", projectDescriptionPath.parentDirectory.pathString,
"-lProjectDescription", "-lProjectDescription",
] ]
arguments.append(path.asString) arguments.append(path.pathString)
arguments.append("--dump") arguments.append("--dump")
guard let jsonString = try system.capture(arguments).spm_chuzzle(), guard let jsonString = try system.capture(arguments).spm_chuzzle(),

View File

@ -35,9 +35,9 @@ class ManifestTargetGenerator: ManifestTargetGenerating {
func manifestTargetBuildSettings() throws -> [String: String] { func manifestTargetBuildSettings() throws -> [String: String] {
let frameworkParentDirectory = try resourceLocator.projectDescription().parentDirectory let frameworkParentDirectory = try resourceLocator.projectDescription().parentDirectory
var buildSettings = [String: String]() var buildSettings = [String: String]()
buildSettings["FRAMEWORK_SEARCH_PATHS"] = frameworkParentDirectory.asString buildSettings["FRAMEWORK_SEARCH_PATHS"] = frameworkParentDirectory.pathString
buildSettings["LIBRARY_SEARCH_PATHS"] = frameworkParentDirectory.asString buildSettings["LIBRARY_SEARCH_PATHS"] = frameworkParentDirectory.pathString
buildSettings["SWIFT_INCLUDE_PATHS"] = frameworkParentDirectory.asString buildSettings["SWIFT_INCLUDE_PATHS"] = frameworkParentDirectory.pathString
buildSettings["SWIFT_VERSION"] = Constants.swiftVersion buildSettings["SWIFT_VERSION"] = Constants.swiftVersion
return buildSettings return buildSettings
} }

View File

@ -48,7 +48,7 @@ class UpCustom: Up, GraphInitiatable {
override func meet(system: Systeming, printer _: Printing, projectPath: AbsolutePath) throws { override func meet(system: Systeming, printer _: Printing, projectPath: AbsolutePath) throws {
let launchPath = try self.launchPath(command: meet, projectPath: projectPath, system: system) let launchPath = try self.launchPath(command: meet, projectPath: projectPath, system: system)
var arguments = [launchPath.asString] var arguments = [launchPath.pathString]
arguments.append(contentsOf: Array(meet.dropFirst())) arguments.append(contentsOf: Array(meet.dropFirst()))
try system.runAndPrint(arguments) try system.runAndPrint(arguments)
@ -68,7 +68,7 @@ class UpCustom: Up, GraphInitiatable {
} catch { } catch {
return false return false
} }
var arguments = [launchPath.asString] var arguments = [launchPath.pathString]
arguments.append(contentsOf: Array(isMet.dropFirst())) arguments.append(contentsOf: Array(isMet.dropFirst()))
do { do {

View File

@ -9,7 +9,7 @@ enum PlaygroundGenerationError: FatalError, Equatable {
var description: String { var description: String {
switch self { switch self {
case let .alreadyExisting(path): case let .alreadyExisting(path):
return "A playground already exists at path \(path.asString)" return "A playground already exists at path \(path.pathString)"
} }
} }

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
/// Protocol that represents an entity that knows how to get the environment status /// Protocol that represents an entity that knows how to get the environment status
/// for a given project and configure it. /// for a given project and configure it.

View File

@ -58,7 +58,7 @@ final class Carthage: Carthaging {
var command: [String] = [carthagePath] var command: [String] = [carthagePath]
command.append("update") command.append("update")
command.append("--project-directory") command.append("--project-directory")
command.append(path.asString) command.append(path.pathString)
if !platforms.isEmpty { if !platforms.isEmpty {
command.append("--platform") command.append("--platform")

View File

@ -0,0 +1,17 @@
import Foundation
import XCTest
@testable import TuistCore
final class StringMD5Tests: XCTestCase {
func test_md5() {
// Given
let string = "abc"
// When
let md5 = string.md5
// Then
XCTAssertEqual(md5, "900150983cd24fb0d6963f7d28e17f72")
}
}

View File

@ -41,7 +41,7 @@ final class OpenerTests: XCTestCase {
func test_open() throws { func test_open() throws {
let path = fileHandler.currentPath.appending(component: "tool") let path = fileHandler.currentPath.appending(component: "tool")
try fileHandler.touch(path) try fileHandler.touch(path)
system.succeedCommand("/usr/bin/open", path.asString) system.succeedCommand("/usr/bin/open", path.pathString)
try subject.open(path: path) try subject.open(path: path)
} }
} }

View File

@ -1,10 +1,10 @@
import Basic import Basic
import Foundation import Foundation
import XCTest import XCTest
@testable import SPMUtility
@testable import TuistCore @testable import TuistCore
@testable import TuistCoreTesting @testable import TuistCoreTesting
@testable import TuistEnvKit @testable import TuistEnvKit
@testable import Utility
final class BundleCommandErrorTests: XCTestCase { final class BundleCommandErrorTests: XCTestCase {
func test_type() { func test_type() {
@ -14,7 +14,7 @@ final class BundleCommandErrorTests: XCTestCase {
func test_description() { func test_description() {
let path = AbsolutePath("/test") let path = AbsolutePath("/test")
XCTAssertEqual(BundleCommandError.missingVersionFile(path).description, "Couldn't find a .tuist-version file in the directory \(path.asString)") XCTAssertEqual(BundleCommandError.missingVersionFile(path).description, "Couldn't find a .tuist-version file in the directory \(path.pathString)")
} }
} }
@ -111,12 +111,12 @@ final class BundleCommandTests: XCTestCase {
try subject.run(with: result) try subject.run(with: result)
XCTAssertEqual(printer.printSectionArgs.count, 1) XCTAssertEqual(printer.printSectionArgs.count, 1)
XCTAssertEqual(printer.printSectionArgs.first, "Bundling the version 3.2.1 in the directory \(binPath.asString)") XCTAssertEqual(printer.printSectionArgs.first, "Bundling the version 3.2.1 in the directory \(binPath.pathString)")
XCTAssertEqual(printer.printArgs.count, 1) XCTAssertEqual(printer.printArgs.count, 1)
XCTAssertEqual(printer.printArgs.first, "Version 3.2.1 not available locally. Installing...") XCTAssertEqual(printer.printArgs.first, "Version 3.2.1 not available locally. Installing...")
XCTAssertEqual(printer.printSuccessArgs.count, 1) XCTAssertEqual(printer.printSuccessArgs.count, 1)
XCTAssertEqual(printer.printSuccessArgs.first, "tuist bundled successfully at \(binPath.asString)") XCTAssertEqual(printer.printSuccessArgs.first, "tuist bundled successfully at \(binPath.pathString)")
} }
} }

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
import XCTest import XCTest
@testable import TuistCoreTesting @testable import TuistCoreTesting
@testable import TuistEnvKit @testable import TuistEnvKit
@ -53,7 +53,7 @@ final class CommandRunnerTests: XCTestCase {
arguments = ["tuist", "--help"] arguments = ["tuist", "--help"]
versionResolver.resolveStub = { _ in ResolvedVersion.bin(self.fileHandler.currentPath) } versionResolver.resolveStub = { _ in ResolvedVersion.bin(self.fileHandler.currentPath) }
system.succeedCommand(binaryPath.asString, "--help", output: "output") system.succeedCommand(binaryPath.pathString, "--help", output: "output")
try subject.run() try subject.run()
} }
@ -62,7 +62,7 @@ final class CommandRunnerTests: XCTestCase {
arguments = ["tuist", "--help"] arguments = ["tuist", "--help"]
versionResolver.resolveStub = { _ in ResolvedVersion.bin(self.fileHandler.currentPath) } versionResolver.resolveStub = { _ in ResolvedVersion.bin(self.fileHandler.currentPath) }
system.errorCommand(binaryPath.asString, "--help", error: "error") system.errorCommand(binaryPath.pathString, "--help", error: "error")
XCTAssertThrowsError(try subject.run()) XCTAssertThrowsError(try subject.run())
} }
@ -80,12 +80,12 @@ final class CommandRunnerTests: XCTestCase {
var installArgs: [(version: String, force: Bool)] = [] var installArgs: [(version: String, force: Bool)] = []
installer.installStub = { version, force in installArgs.append((version: version, force: force)) } installer.installStub = { version, force in installArgs.append((version: version, force: force)) }
system.succeedCommand(binaryPath.asString, "--help", output: "") system.succeedCommand(binaryPath.pathString, "--help", output: "")
try subject.run() try subject.run()
XCTAssertEqual(printer.printArgs.count, 2) XCTAssertEqual(printer.printArgs.count, 2)
XCTAssertEqual(printer.printArgs.first, "Using version 3.2.1 defined at \(fileHandler.currentPath.asString)") XCTAssertEqual(printer.printArgs.first, "Using version 3.2.1 defined at \(fileHandler.currentPath.pathString)")
XCTAssertEqual(printer.printArgs.last, "Version 3.2.1 not found locally. Installing...") XCTAssertEqual(printer.printArgs.last, "Version 3.2.1 not found locally. Installing...")
XCTAssertEqual(installArgs.count, 1) XCTAssertEqual(installArgs.count, 1)
XCTAssertEqual(installArgs.first?.version, "3.2.1") XCTAssertEqual(installArgs.first?.version, "3.2.1")
@ -116,7 +116,7 @@ final class CommandRunnerTests: XCTestCase {
versionResolver.resolveStub = { _ in ResolvedVersion.versionFile(self.fileHandler.currentPath, "3.2.1") versionResolver.resolveStub = { _ in ResolvedVersion.versionFile(self.fileHandler.currentPath, "3.2.1")
} }
system.errorCommand(binaryPath.asString, "--help", error: "error") system.errorCommand(binaryPath.pathString, "--help", error: "error")
XCTAssertThrowsError(try subject.run()) XCTAssertThrowsError(try subject.run())
} }
@ -132,7 +132,7 @@ final class CommandRunnerTests: XCTestCase {
$0 == "3.2.1" ? self.fileHandler.currentPath : AbsolutePath("/invalid") $0 == "3.2.1" ? self.fileHandler.currentPath : AbsolutePath("/invalid")
} }
system.succeedCommand(binaryPath.asString, "--help", output: "") system.succeedCommand(binaryPath.pathString, "--help", output: "")
try subject.run() try subject.run()
} }
@ -152,7 +152,7 @@ final class CommandRunnerTests: XCTestCase {
$0 == "3.2.1" ? self.fileHandler.currentPath : AbsolutePath("/invalid") $0 == "3.2.1" ? self.fileHandler.currentPath : AbsolutePath("/invalid")
} }
system.succeedCommand(binaryPath.asString, "--help", output: "") system.succeedCommand(binaryPath.pathString, "--help", output: "")
try subject.run() try subject.run()
} }
@ -186,7 +186,7 @@ final class CommandRunnerTests: XCTestCase {
$0 == "3.2.1" ? self.fileHandler.currentPath : AbsolutePath("/invalid") $0 == "3.2.1" ? self.fileHandler.currentPath : AbsolutePath("/invalid")
} }
system.errorCommand(binaryPath.asString, "--help", error: "error") system.errorCommand(binaryPath.pathString, "--help", error: "error")
XCTAssertThrowsError(try subject.run()) XCTAssertThrowsError(try subject.run())
} }

View File

@ -2,9 +2,9 @@ import Basic
import Foundation import Foundation
import TuistCore import TuistCore
import XCTest import XCTest
@testable import SPMUtility
@testable import TuistCoreTesting @testable import TuistCoreTesting
@testable import TuistEnvKit @testable import TuistEnvKit
@testable import Utility
final class InstallCommandTests: XCTestCase { final class InstallCommandTests: XCTestCase {
var parser: ArgumentParser! var parser: ArgumentParser!

View File

@ -2,9 +2,9 @@ import Basic
import Foundation import Foundation
import TuistCore import TuistCore
import XCTest import XCTest
@testable import SPMUtility
@testable import TuistCoreTesting @testable import TuistCoreTesting
@testable import TuistEnvKit @testable import TuistEnvKit
@testable import Utility
final class LocalCommandTests: XCTestCase { final class LocalCommandTests: XCTestCase {
var argumentParser: ArgumentParser! var argumentParser: ArgumentParser!
@ -58,7 +58,7 @@ final class LocalCommandTests: XCTestCase {
XCTAssertEqual(printer.printSectionArgs.first, "Generating \(Constants.versionFileName) file with version 3.2.1") XCTAssertEqual(printer.printSectionArgs.first, "Generating \(Constants.versionFileName) file with version 3.2.1")
XCTAssertEqual(printer.printSuccessArgs.count, 1) XCTAssertEqual(printer.printSuccessArgs.count, 1)
XCTAssertEqual(printer.printSuccessArgs.last, "File generated at path \(versionPath.asString)") XCTAssertEqual(printer.printSuccessArgs.last, "File generated at path \(versionPath.pathString)")
} }
func test_run_prints_when_no_argument_is_passed() throws { func test_run_prints_when_no_argument_is_passed() throws {

View File

@ -2,9 +2,9 @@ import Basic
import Foundation import Foundation
import TuistCore import TuistCore
import XCTest import XCTest
@testable import SPMUtility
@testable import TuistCoreTesting @testable import TuistCoreTesting
@testable import TuistEnvKit @testable import TuistEnvKit
@testable import Utility
final class UninstallCommandTests: XCTestCase { final class UninstallCommandTests: XCTestCase {
var parser: ArgumentParser! var parser: ArgumentParser!

View File

@ -1,9 +1,9 @@
import Foundation import Foundation
import XCTest import XCTest
@testable import SPMUtility
@testable import TuistCoreTesting @testable import TuistCoreTesting
@testable import TuistEnvKit @testable import TuistEnvKit
@testable import Utility
final class UpdateCommandTests: XCTestCase { final class UpdateCommandTests: XCTestCase {
var parser: ArgumentParser! var parser: ArgumentParser!

View File

@ -1,5 +1,5 @@
import Foundation import Foundation
import Utility import SPMUtility
import XCTest import XCTest
@testable import TuistEnvKit @testable import TuistEnvKit

View File

@ -1,6 +1,6 @@
import Basic import Basic
import Foundation import Foundation
import Utility import SPMUtility
@testable import TuistEnvKit @testable import TuistEnvKit
extension Release { extension Release {

View File

@ -41,6 +41,6 @@ final class BuildCopierTests: XCTestCase {
try subject.copy(from: fromPath, to: toPath) try subject.copy(from: fromPath, to: toPath)
XCTAssertEqual(toPath.glob("*").count, BuildCopier.files.count) XCTAssertEqual(toPath.glob("*").count, BuildCopier.files.count)
XCTAssertFalse(fileManager.fileExists(atPath: toPath.appending(component: "test").asString)) XCTAssertFalse(fileManager.fileExists(atPath: toPath.appending(component: "test").pathString))
} }
} }

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
import XCTest import XCTest
@testable import TuistCoreTesting @testable import TuistCoreTesting
@testable import TuistEnvKit @testable import TuistEnvKit
@ -74,10 +74,10 @@ final class InstallerTests: XCTestCase {
.path .path
.appending(component: Constants.bundleName) .appending(component: Constants.bundleName)
system.succeedCommand("/usr/bin/curl", "-LSs", system.succeedCommand("/usr/bin/curl", "-LSs",
"--output", downloadPath.asString, "--output", downloadPath.pathString,
downloadURL.absoluteString) downloadURL.absoluteString)
system.succeedCommand("/usr/bin/unzip", downloadPath.asString, system.succeedCommand("/usr/bin/unzip", downloadPath.pathString,
"-d", fileHandler.currentPath.asString) "-d", fileHandler.currentPath.pathString)
try subject.install(version: version, try subject.install(version: version,
temporaryDirectory: temporaryDirectory) temporaryDirectory: temporaryDirectory)
@ -113,7 +113,7 @@ final class InstallerTests: XCTestCase {
.path .path
.appending(component: Constants.bundleName) .appending(component: Constants.bundleName)
system.errorCommand("/usr/bin/curl", "-LSs", system.errorCommand("/usr/bin/curl", "-LSs",
"--output", downloadPath.asString, "--output", downloadPath.pathString,
downloadURL.absoluteString, downloadURL.absoluteString,
error: "download_error") error: "download_error")
@ -141,10 +141,10 @@ final class InstallerTests: XCTestCase {
.path .path
.appending(component: Constants.bundleName) .appending(component: Constants.bundleName)
system.succeedCommand("/usr/bin/curl", "-LSs", system.succeedCommand("/usr/bin/curl", "-LSs",
"--output", downloadPath.asString, "--output", downloadPath.pathString,
downloadURL.absoluteString) downloadURL.absoluteString)
system.errorCommand("/usr/bin/unzip", downloadPath.asString, system.errorCommand("/usr/bin/unzip", downloadPath.pathString,
"-d", fileHandler.currentPath.asString, "-d", fileHandler.currentPath.pathString,
error: "unzip_error") error: "unzip_error")
XCTAssertThrowsError(try subject.install(version: version, temporaryDirectory: temporaryDirectory)) XCTAssertThrowsError(try subject.install(version: version, temporaryDirectory: temporaryDirectory))
@ -162,19 +162,19 @@ final class InstallerTests: XCTestCase {
system.succeedCommand("/usr/bin/env", "git", system.succeedCommand("/usr/bin/env", "git",
"clone", Constants.gitRepositoryURL, "clone", Constants.gitRepositoryURL,
temporaryDirectory.path.asString) temporaryDirectory.path.pathString)
system.succeedCommand("/usr/bin/env", "git", "-C", temporaryDirectory.path.asString, system.succeedCommand("/usr/bin/env", "git", "-C", temporaryDirectory.path.pathString,
"checkout", version) "checkout", version)
system.succeedCommand("/usr/bin/xcrun", "-f", "swift", output: "/path/to/swift") system.succeedCommand("/usr/bin/xcrun", "-f", "swift", output: "/path/to/swift")
system.succeedCommand("/path/to/swift", "build", system.succeedCommand("/path/to/swift", "build",
"--product", "tuist", "--product", "tuist",
"--package-path", temporaryDirectory.path.asString, "--package-path", temporaryDirectory.path.pathString,
"--configuration", "release", "--configuration", "release",
"-Xswiftc", "-static-stdlib") "-Xswiftc", "-static-stdlib")
system.succeedCommand("/path/to/swift", "build", system.succeedCommand("/path/to/swift", "build",
"--product", "ProjectDescription", "--product", "ProjectDescription",
"--package-path", temporaryDirectory.path.asString, "--package-path", temporaryDirectory.path.pathString,
"--configuration", "release") "--configuration", "release")
try subject.install(version: version, temporaryDirectory: temporaryDirectory) try subject.install(version: version, temporaryDirectory: temporaryDirectory)
@ -204,19 +204,19 @@ final class InstallerTests: XCTestCase {
system.succeedCommand("/usr/bin/env", "git", system.succeedCommand("/usr/bin/env", "git",
"clone", Constants.gitRepositoryURL, "clone", Constants.gitRepositoryURL,
temporaryDirectory.path.asString) temporaryDirectory.path.pathString)
system.succeedCommand("/usr/bin/env", "git", "-C", temporaryDirectory.path.asString, system.succeedCommand("/usr/bin/env", "git", "-C", temporaryDirectory.path.pathString,
"checkout", version) "checkout", version)
system.succeedCommand("/usr/bin/xcrun", "-f", "swift", system.succeedCommand("/usr/bin/xcrun", "-f", "swift",
output: "/path/to/swift") output: "/path/to/swift")
system.succeedCommand("/path/to/swift", "build", system.succeedCommand("/path/to/swift", "build",
"--product", "tuist", "--product", "tuist",
"--package-path", temporaryDirectory.path.asString, "--package-path", temporaryDirectory.path.pathString,
"--configuration", "release", "--configuration", "release",
"-Xswiftc", "-static-stdlib") "-Xswiftc", "-static-stdlib")
system.succeedCommand("/path/to/swift", "build", system.succeedCommand("/path/to/swift", "build",
"--product", "ProjectDescription", "--product", "ProjectDescription",
"--package-path", temporaryDirectory.path.asString, "--package-path", temporaryDirectory.path.pathString,
"--configuration", "release") "--configuration", "release")
try subject.install(version: version, temporaryDirectory: temporaryDirectory, force: true) try subject.install(version: version, temporaryDirectory: temporaryDirectory, force: true)
@ -242,8 +242,8 @@ final class InstallerTests: XCTestCase {
} }
system.succeedCommand("/usr/bin/env", "git", system.succeedCommand("/usr/bin/env", "git",
"clone", Constants.gitRepositoryURL, "clone", Constants.gitRepositoryURL,
temporaryDirectory.path.asString) temporaryDirectory.path.pathString)
system.errorCommand("/usr/bin/env", "git", "-C", temporaryDirectory.path.asString, system.errorCommand("/usr/bin/env", "git", "-C", temporaryDirectory.path.pathString,
"checkout", version, "checkout", version,
error: "did not match any file(s) known to git ") error: "did not match any file(s) known to git ")

View File

@ -28,8 +28,8 @@ final class EnvUpdaterTests: XCTestCase {
githubClient.releasesStub = { [release] } githubClient.releasesStub = { [release] }
let downloadPath = fileHandler.currentPath.appending(component: "tuistenv.zip") let downloadPath = fileHandler.currentPath.appending(component: "tuistenv.zip")
system.succeedCommand(["/usr/bin/curl", "-LSs", "--output", downloadPath.asString, downloadURL.absoluteString]) system.succeedCommand(["/usr/bin/curl", "-LSs", "--output", downloadPath.pathString, downloadURL.absoluteString])
system.succeedCommand(["/usr/bin/unzip", "-o", downloadPath.asString, "-d", "/tmp/"]) system.succeedCommand(["/usr/bin/unzip", "-o", downloadPath.pathString, "-d", "/tmp/"])
system.succeedCommand(["/bin/chmod", "+x", "/tmp/tuistenv"]) system.succeedCommand(["/bin/chmod", "+x", "/tmp/tuistenv"])
system.succeedCommand(["/bin/cp", "-rf", "/tmp/tuistenv", "/usr/local/bin/tuist"]) system.succeedCommand(["/bin/cp", "-rf", "/tmp/tuistenv", "/usr/local/bin/tuist"])
system.succeedCommand(["/bin/rm", "/tmp/tuistenv"]) system.succeedCommand(["/bin/rm", "/tmp/tuistenv"])

View File

@ -1,6 +1,6 @@
import Basic import Basic
import Foundation import Foundation
import Utility import SPMUtility
@testable import TuistEnvKit @testable import TuistEnvKit
final class MockVersionsController: VersionsControlling { final class MockVersionsController: VersionsControlling {

View File

@ -32,11 +32,11 @@ final class VersionResolverTests: XCTestCase {
let binPath = tmp_dir.path.appending(component: Constants.binFolderName) let binPath = tmp_dir.path.appending(component: Constants.binFolderName)
// /tmp/dir/.tuist-version // /tmp/dir/.tuist-version
try "3.2.1".write(to: URL(fileURLWithPath: versionPath.asString), try "3.2.1".write(to: URL(fileURLWithPath: versionPath.pathString),
atomically: true, atomically: true,
encoding: .utf8) encoding: .utf8)
// /tmp/dir/.tuist-bin // /tmp/dir/.tuist-bin
try FileManager.default.createDirectory(at: URL(fileURLWithPath: binPath.asString), try FileManager.default.createDirectory(at: URL(fileURLWithPath: binPath.pathString),
withIntermediateDirectories: true, withIntermediateDirectories: true,
attributes: nil) attributes: nil)
@ -49,7 +49,7 @@ final class VersionResolverTests: XCTestCase {
let versionPath = tmp_dir.path.appending(component: Constants.versionFileName) let versionPath = tmp_dir.path.appending(component: Constants.versionFileName)
// /tmp/dir/.tuist-version // /tmp/dir/.tuist-version
try "3.2.1".write(to: URL(fileURLWithPath: versionPath.asString), try "3.2.1".write(to: URL(fileURLWithPath: versionPath.pathString),
atomically: true, atomically: true,
encoding: .utf8) encoding: .utf8)
@ -62,7 +62,7 @@ final class VersionResolverTests: XCTestCase {
let binPath = tmp_dir.path.appending(component: Constants.binFolderName) let binPath = tmp_dir.path.appending(component: Constants.binFolderName)
// /tmp/dir/.tuist-bin // /tmp/dir/.tuist-bin
try FileManager.default.createDirectory(at: URL(fileURLWithPath: binPath.asString), try FileManager.default.createDirectory(at: URL(fileURLWithPath: binPath.pathString),
withIntermediateDirectories: true, withIntermediateDirectories: true,
attributes: nil) attributes: nil)
@ -76,10 +76,10 @@ final class VersionResolverTests: XCTestCase {
let childPath = tmp_dir.path.appending(component: "child") let childPath = tmp_dir.path.appending(component: "child")
// /tmp/dir/.tuist-version // /tmp/dir/.tuist-version
try "3.2.1".write(to: URL(fileURLWithPath: versionPath.asString), try "3.2.1".write(to: URL(fileURLWithPath: versionPath.pathString),
atomically: true, atomically: true,
encoding: .utf8) encoding: .utf8)
try FileManager.default.createDirectory(at: URL(fileURLWithPath: childPath.asString), try FileManager.default.createDirectory(at: URL(fileURLWithPath: childPath.pathString),
withIntermediateDirectories: true, withIntermediateDirectories: true,
attributes: nil) attributes: nil)
@ -93,10 +93,10 @@ final class VersionResolverTests: XCTestCase {
let childPath = tmp_dir.path.appending(component: "child") let childPath = tmp_dir.path.appending(component: "child")
// /tmp/dir/.tuist-bin // /tmp/dir/.tuist-bin
try FileManager.default.createDirectory(at: URL(fileURLWithPath: binPath.asString), try FileManager.default.createDirectory(at: URL(fileURLWithPath: binPath.pathString),
withIntermediateDirectories: true, withIntermediateDirectories: true,
attributes: nil) attributes: nil)
try FileManager.default.createDirectory(at: URL(fileURLWithPath: childPath.asString), try FileManager.default.createDirectory(at: URL(fileURLWithPath: childPath.pathString),
withIntermediateDirectories: true, withIntermediateDirectories: true,
attributes: nil) attributes: nil)

View File

@ -1,6 +1,6 @@
import Basic import Basic
import Foundation import Foundation
import Utility import SPMUtility
import XCTest import XCTest
@testable import TuistCoreTesting @testable import TuistCoreTesting
@testable import TuistEnvKit @testable import TuistEnvKit

View File

@ -8,7 +8,7 @@ import XCTest
final class BuildPhaseGenerationErrorTests: XCTestCase { final class BuildPhaseGenerationErrorTests: XCTestCase {
func test_description_when_missingFileReference() { func test_description_when_missingFileReference() {
let path = AbsolutePath("/test") let path = AbsolutePath("/test")
let expected = "Trying to add a file at path \(path.asString) to a build phase that hasn't been added to the project." let expected = "Trying to add a file at path \(path.pathString) to a build phase that hasn't been added to the project."
XCTAssertEqual(BuildPhaseGenerationError.missingFileReference(path).description, expected) XCTAssertEqual(BuildPhaseGenerationError.missingFileReference(path).description, expected)
} }

View File

@ -21,7 +21,7 @@ final class ProjectDirectoryHelperTests: XCTestCase {
let got = try subject.setupDirectory(name: "MyApp", let got = try subject.setupDirectory(name: "MyApp",
path: path, path: path,
directory: .derivedProjects) directory: .derivedProjects)
let expected = environmentController.derivedProjectsDirectory.appending(component: "MyApp-\(path.asString.md5)") let expected = environmentController.derivedProjectsDirectory.appending(component: "MyApp-\(path.pathString.md5)")
XCTAssertEqual(got, expected) XCTAssertEqual(got, expected)
XCTAssertTrue(fileHandler.exists(expected)) XCTAssertTrue(fileHandler.exists(expected))

View File

@ -59,7 +59,7 @@ final class WorkspaceGeneratorTests: XCTestCase {
options: GenerationOptions()) options: GenerationOptions())
// Then // Then
let xcworkspace = try XCWorkspace(pathString: workspacePath.asString) let xcworkspace = try XCWorkspace(pathString: workspacePath.pathString)
XCTAssertEqual(xcworkspace.data.children, [ XCTAssertEqual(xcworkspace.data.children, [
.group(.init(location: .group("Documentation"), name: "Documentation", children: [ .group(.init(location: .group("Documentation"), name: "Documentation", children: [
.file(.init(location: .group("README.md"))), .file(.init(location: .group("README.md"))),
@ -105,7 +105,7 @@ final class WorkspaceGeneratorTests: XCTestCase {
options: GenerationOptions()) options: GenerationOptions())
// Then // Then
let xcworkspace = try XCWorkspace(pathString: workspacePath.asString) let xcworkspace = try XCWorkspace(pathString: workspacePath.pathString)
XCTAssertEqual(xcworkspace.data.children, [ XCTAssertEqual(xcworkspace.data.children, [
.file(.init(location: .group("Test.xcodeproj"))), .file(.init(location: .group("Test.xcodeproj"))),
]) ])

View File

@ -137,7 +137,7 @@ final class FrameworkNodeTests: XCTestCase {
} }
func test_binaryPath() { func test_binaryPath() {
XCTAssertEqual(subject.binaryPath.asString, "/test.framework/test") XCTAssertEqual(subject.binaryPath.pathString, "/test.framework/test")
} }
func test_isCarthage() { func test_isCarthage() {
@ -172,7 +172,7 @@ final class LibraryNodeTests: XCTestCase {
} }
func test_binaryPath() { func test_binaryPath() {
XCTAssertEqual(subject.binaryPath.asString, "/test.a") XCTAssertEqual(subject.binaryPath.pathString, "/test.a")
} }
func test_architectures() throws { func test_architectures() throws {

View File

@ -32,7 +32,7 @@ final class GraphLinterTests: XCTestCase {
let result = subject.lint(graph: graph) let result = subject.lint(graph: graph)
XCTAssertTrue(result.contains(LintingIssue(reason: "Framework not found at path \(frameworkBPath.asString). The path might be wrong or Carthage dependencies not fetched", severity: .warning))) XCTAssertTrue(result.contains(LintingIssue(reason: "Framework not found at path \(frameworkBPath.pathString). The path might be wrong or Carthage dependencies not fetched", severity: .warning)))
} }
func test_lint_when_frameworks_are_missing() throws { func test_lint_when_frameworks_are_missing() throws {
@ -52,7 +52,7 @@ final class GraphLinterTests: XCTestCase {
let result = subject.lint(graph: graph) let result = subject.lint(graph: graph)
XCTAssertTrue(result.contains(LintingIssue(reason: "Framework not found at path \(frameworkBPath.asString)", severity: .error))) XCTAssertTrue(result.contains(LintingIssue(reason: "Framework not found at path \(frameworkBPath.pathString)", severity: .error)))
} }
func test_lint_when_static_product_linked_twice() throws { func test_lint_when_static_product_linked_twice() throws {

View File

@ -16,6 +16,6 @@ final class ProjectLinterTests: XCTestCase {
let target = Target.test(name: "A") let target = Target.test(name: "A")
let project = Project.test(targets: [target, target]) let project = Project.test(targets: [target, target])
let got = subject.lint(project) let got = subject.lint(project)
XCTAssertTrue(got.contains(LintingIssue(reason: "Targets A from project at \(project.path.asString) have duplicates.", severity: .error))) XCTAssertTrue(got.contains(LintingIssue(reason: "Targets A from project at \(project.path.pathString) have duplicates.", severity: .error)))
} }
} }

View File

@ -24,7 +24,7 @@ final class SettingsLinterTests: XCTestCase {
let got = subject.lint(settings: settings) let got = subject.lint(settings: settings)
XCTAssertTrue(got.contains(LintingIssue(reason: "Configuration file not found at path \(debugPath.asString)", severity: .error))) XCTAssertTrue(got.contains(LintingIssue(reason: "Configuration file not found at path \(debugPath.pathString)", severity: .error)))
XCTAssertTrue(got.contains(LintingIssue(reason: "Configuration file not found at path \(releasePath.asString)", severity: .error))) XCTAssertTrue(got.contains(LintingIssue(reason: "Configuration file not found at path \(releasePath.pathString)", severity: .error)))
} }
} }

View File

@ -35,7 +35,7 @@ final class TargetActionLinterTests: XCTestCase {
path: fileHandler.currentPath.appending(component: "invalid.sh")) path: fileHandler.currentPath.appending(component: "invalid.sh"))
let got = subject.lint(action) let got = subject.lint(action)
let expected = LintingIssue(reason: "The action path \(action.path!.asString) doesn't exist", let expected = LintingIssue(reason: "The action path \(action.path!.pathString) doesn't exist",
severity: .error) severity: .error)
XCTAssertTrue(got.contains(expected)) XCTAssertTrue(got.contains(expected))
} }

View File

@ -47,7 +47,7 @@ final class TargetLinterTests: XCTestCase {
let got = subject.lint(target: target) let got = subject.lint(target: target)
XCTAssertTrue(got.contains(LintingIssue(reason: "Info.plist at path \(path.asString) being copied into the target \(target.name) product.", severity: .warning))) XCTAssertTrue(got.contains(LintingIssue(reason: "Info.plist at path \(path.pathString) being copied into the target \(target.name) product.", severity: .warning)))
} }
func test_lint_when_a_entitlements_file_is_being_copied() { func test_lint_when_a_entitlements_file_is_being_copied() {
@ -56,7 +56,7 @@ final class TargetLinterTests: XCTestCase {
let got = subject.lint(target: target) let got = subject.lint(target: target)
XCTAssertTrue(got.contains(LintingIssue(reason: "Entitlements file at path \(path.asString) being copied into the target \(target.name) product.", severity: .warning))) XCTAssertTrue(got.contains(LintingIssue(reason: "Entitlements file at path \(path.pathString) being copied into the target \(target.name) product.", severity: .warning)))
} }
func test_lint_when_entitlements_not_missing() { func test_lint_when_entitlements_not_missing() {
@ -65,7 +65,7 @@ final class TargetLinterTests: XCTestCase {
let got = subject.lint(target: target) let got = subject.lint(target: target)
XCTAssertTrue(got.contains(LintingIssue(reason: "Info.plist file not found at path \(path.asString)", severity: .error))) XCTAssertTrue(got.contains(LintingIssue(reason: "Info.plist file not found at path \(path.pathString)", severity: .error)))
} }
func test_lint_when_infoplist_not_found() { func test_lint_when_infoplist_not_found() {
@ -74,7 +74,7 @@ final class TargetLinterTests: XCTestCase {
let got = subject.lint(target: target) let got = subject.lint(target: target)
XCTAssertTrue(got.contains(LintingIssue(reason: "Entitlements file not found at path \(path.asString)", severity: .error))) XCTAssertTrue(got.contains(LintingIssue(reason: "Entitlements file not found at path \(path.pathString)", severity: .error)))
} }
func test_lint_when_library_has_resources() { func test_lint_when_library_has_resources() {

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
import XCTest import XCTest
@testable import TuistCoreTesting @testable import TuistCoreTesting
@testable import TuistGenerator @testable import TuistGenerator

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
import XCTest import XCTest
@testable import TuistCoreTesting @testable import TuistCoreTesting
@testable import TuistGenerator @testable import TuistGenerator

View File

@ -66,7 +66,7 @@ final class TargetTests: XCTestCase {
fileHandler: fileHandler) fileHandler: fileHandler)
// Then // Then
let relativeSources = sources.map { $0.relative(to: fileHandler.currentPath).asString } let relativeSources = sources.map { $0.relative(to: fileHandler.currentPath).pathString }
XCTAssertEqual(relativeSources, [ XCTAssertEqual(relativeSources, [
"sources/a.swift", "sources/a.swift",
"sources/b.m", "sources/b.m",
@ -98,7 +98,7 @@ final class TargetTests: XCTestCase {
let resources = paths.filter { Target.isResource(path: $0, fileHandler: fileHandler) } let resources = paths.filter { Target.isResource(path: $0, fileHandler: fileHandler) }
// Then // Then
let relativeResources = resources.map { $0.relative(to: fileHandler.currentPath).asString } let relativeResources = resources.map { $0.relative(to: fileHandler.currentPath).pathString }
XCTAssertEqual(relativeResources, [ XCTAssertEqual(relativeResources, [
"resources/d.xcassets", "resources/d.xcassets",
"resources/g.bundle", "resources/g.bundle",

View File

@ -1,5 +1,5 @@
import Foundation import Foundation
import Utility import SPMUtility
import XCTest import XCTest
@testable import TuistCoreTesting @testable import TuistCoreTesting
@testable import TuistKit @testable import TuistKit

View File

@ -1,6 +1,6 @@
import Basic import Basic
import Foundation import Foundation
import Utility import SPMUtility
import XCTest import XCTest
@testable import TuistCoreTesting @testable import TuistCoreTesting
@testable import TuistKit @testable import TuistKit
@ -35,7 +35,7 @@ final class DumpCommandTests: XCTestCase {
func test_run_throws_when_file_doesnt_exist() throws { func test_run_throws_when_file_doesnt_exist() throws {
let tmpDir = try TemporaryDirectory(removeTreeOnDeinit: true) let tmpDir = try TemporaryDirectory(removeTreeOnDeinit: true)
let result = try parser.parse([DumpCommand.command, "-p", tmpDir.path.asString]) let result = try parser.parse([DumpCommand.command, "-p", tmpDir.path.pathString])
XCTAssertThrowsError(try subject.run(with: result)) { XCTAssertThrowsError(try subject.run(with: result)) {
XCTAssertEqual($0 as? GraphManifestLoaderError, GraphManifestLoaderError.manifestNotFound(.project, tmpDir.path)) XCTAssertEqual($0 as? GraphManifestLoaderError, GraphManifestLoaderError.manifestNotFound(.project, tmpDir.path))
} }
@ -43,10 +43,10 @@ final class DumpCommandTests: XCTestCase {
func test_run_throws_when_the_manifest_loading_fails() throws { func test_run_throws_when_the_manifest_loading_fails() throws {
let tmpDir = try TemporaryDirectory(removeTreeOnDeinit: true) let tmpDir = try TemporaryDirectory(removeTreeOnDeinit: true)
try "invalid config".write(toFile: tmpDir.path.appending(component: "Project.swift").asString, try "invalid config".write(toFile: tmpDir.path.appending(component: "Project.swift").pathString,
atomically: true, atomically: true,
encoding: .utf8) encoding: .utf8)
let result = try parser.parse([DumpCommand.command, "-p", tmpDir.path.asString]) let result = try parser.parse([DumpCommand.command, "-p", tmpDir.path.pathString])
XCTAssertThrowsError(try subject.run(with: result)) XCTAssertThrowsError(try subject.run(with: result))
} }
@ -59,10 +59,10 @@ final class DumpCommandTests: XCTestCase {
settings: nil, settings: nil,
targets: []) targets: [])
""" """
try config.write(toFile: tmpDir.path.appending(component: "Project.swift").asString, try config.write(toFile: tmpDir.path.appending(component: "Project.swift").pathString,
atomically: true, atomically: true,
encoding: .utf8) encoding: .utf8)
let result = try parser.parse([DumpCommand.command, "-p", tmpDir.path.asString]) let result = try parser.parse([DumpCommand.command, "-p", tmpDir.path.pathString])
try subject.run(with: result) try subject.run(with: result)
let expected = "{\n \"additionalFiles\": [\n\n ],\n \"name\": \"tuist\",\n \"targets\": [\n\n ]\n}\n" let expected = "{\n \"additionalFiles\": [\n\n ],\n \"name\": \"tuist\",\n \"targets\": [\n\n ]\n}\n"
XCTAssertEqual(printer.printArgs.first, expected) XCTAssertEqual(printer.printArgs.first, expected)

View File

@ -1,6 +1,6 @@
import Basic import Basic
import Foundation import Foundation
import Utility import SPMUtility
import XcodeProj import XcodeProj
import XCTest import XCTest
@testable import TuistCoreTesting @testable import TuistCoreTesting

View File

@ -1,7 +1,7 @@
import Basic import Basic
import Foundation import Foundation
import SPMUtility
import TuistCore import TuistCore
import Utility
import XcodeProj import XcodeProj
import XCTest import XCTest
@testable import TuistCoreTesting @testable import TuistCoreTesting

View File

@ -1,9 +1,9 @@
import Basic import Basic
import Foundation import Foundation
import XCTest import XCTest
@testable import SPMUtility
@testable import TuistCoreTesting @testable import TuistCoreTesting
@testable import TuistKit @testable import TuistKit
@testable import Utility
final class InitCommandErrorTests: XCTestCase { final class InitCommandErrorTests: XCTestCase {
func test_description() { func test_description() {
@ -92,7 +92,7 @@ final class InitCommandTests: XCTestCase {
let path = fileHandler.currentPath let path = fileHandler.currentPath
try fileHandler.touch(path.appending(component: "dummy")) try fileHandler.touch(path.appending(component: "dummy"))
let result = try parser.parse(["init", "--path", path.asString, "--name", "Test"]) let result = try parser.parse(["init", "--path", path.pathString, "--name", "Test"])
XCTAssertThrowsError(try subject.run(with: result)) { error in XCTAssertThrowsError(try subject.run(with: result)) { error in
let expected = InitCommandError.nonEmptyDirectory(path) let expected = InitCommandError.nonEmptyDirectory(path)
@ -111,7 +111,7 @@ final class InitCommandTests: XCTestCase {
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(component: "Tests.plist"))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(component: "Tests.plist")))
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Sources/AppDelegate.swift")))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Sources/AppDelegate.swift"))))
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Tests/\(name)Tests.swift")))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Tests/\(name)Tests.swift"))))
XCTAssertEqual(printer.printSuccessArgs.first, "Project generated at path \(fileHandler.currentPath.asString).") XCTAssertEqual(printer.printSuccessArgs.first, "Project generated at path \(fileHandler.currentPath.pathString).")
let playgroundsPath = fileHandler.currentPath.appending(component: "Playgrounds") let playgroundsPath = fileHandler.currentPath.appending(component: "Playgrounds")
XCTAssertTrue(fileHandler.exists(playgroundsPath)) XCTAssertTrue(fileHandler.exists(playgroundsPath))
@ -133,7 +133,7 @@ final class InitCommandTests: XCTestCase {
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(component: "Tests.plist"))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(component: "Tests.plist")))
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Sources/AppDelegate.swift")))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Sources/AppDelegate.swift"))))
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Tests/\(name)Tests.swift")))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Tests/\(name)Tests.swift"))))
XCTAssertEqual(printer.printSuccessArgs.first, "Project generated at path \(fileHandler.currentPath.asString).") XCTAssertEqual(printer.printSuccessArgs.first, "Project generated at path \(fileHandler.currentPath.pathString).")
let playgroundsPath = fileHandler.currentPath.appending(component: "Playgrounds") let playgroundsPath = fileHandler.currentPath.appending(component: "Playgrounds")
XCTAssertTrue(fileHandler.exists(playgroundsPath)) XCTAssertTrue(fileHandler.exists(playgroundsPath))
@ -155,7 +155,7 @@ final class InitCommandTests: XCTestCase {
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(component: "Tests.plist"))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(component: "Tests.plist")))
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Sources/AppDelegate.swift")))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Sources/AppDelegate.swift"))))
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Tests/\(name)Tests.swift")))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Tests/\(name)Tests.swift"))))
XCTAssertEqual(printer.printSuccessArgs.first, "Project generated at path \(fileHandler.currentPath.asString).") XCTAssertEqual(printer.printSuccessArgs.first, "Project generated at path \(fileHandler.currentPath.pathString).")
let playgroundsPath = fileHandler.currentPath.appending(component: "Playgrounds") let playgroundsPath = fileHandler.currentPath.appending(component: "Playgrounds")
XCTAssertTrue(fileHandler.exists(playgroundsPath)) XCTAssertTrue(fileHandler.exists(playgroundsPath))
@ -177,7 +177,7 @@ final class InitCommandTests: XCTestCase {
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(component: "Tests.plist"))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(component: "Tests.plist")))
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Sources/\(name).swift")))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Sources/\(name).swift"))))
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Tests/\(name)Tests.swift")))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Tests/\(name)Tests.swift"))))
XCTAssertEqual(printer.printSuccessArgs.first, "Project generated at path \(fileHandler.currentPath.asString).") XCTAssertEqual(printer.printSuccessArgs.first, "Project generated at path \(fileHandler.currentPath.pathString).")
let playgroundsPath = fileHandler.currentPath.appending(component: "Playgrounds") let playgroundsPath = fileHandler.currentPath.appending(component: "Playgrounds")
XCTAssertTrue(fileHandler.exists(playgroundsPath)) XCTAssertTrue(fileHandler.exists(playgroundsPath))
@ -200,7 +200,7 @@ final class InitCommandTests: XCTestCase {
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(component: "Tests.plist"))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(component: "Tests.plist")))
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Sources/\(name).swift")))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Sources/\(name).swift"))))
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Tests/\(name)Tests.swift")))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Tests/\(name)Tests.swift"))))
XCTAssertEqual(printer.printSuccessArgs.first, "Project generated at path \(fileHandler.currentPath.asString).") XCTAssertEqual(printer.printSuccessArgs.first, "Project generated at path \(fileHandler.currentPath.pathString).")
let playgroundsPath = fileHandler.currentPath.appending(component: "Playgrounds") let playgroundsPath = fileHandler.currentPath.appending(component: "Playgrounds")
XCTAssertTrue(fileHandler.exists(playgroundsPath)) XCTAssertTrue(fileHandler.exists(playgroundsPath))
@ -222,7 +222,7 @@ final class InitCommandTests: XCTestCase {
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(component: "Tests.plist"))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(component: "Tests.plist")))
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Sources/\(name).swift")))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Sources/\(name).swift"))))
XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Tests/\(name)Tests.swift")))) XCTAssertTrue(fileHandler.exists(fileHandler.currentPath.appending(RelativePath("Tests/\(name)Tests.swift"))))
XCTAssertEqual(printer.printSuccessArgs.first, "Project generated at path \(fileHandler.currentPath.asString).") XCTAssertEqual(printer.printSuccessArgs.first, "Project generated at path \(fileHandler.currentPath.pathString).")
let playgroundsPath = fileHandler.currentPath.appending(component: "Playgrounds") let playgroundsPath = fileHandler.currentPath.appending(component: "Playgrounds")
XCTAssertTrue(fileHandler.exists(playgroundsPath)) XCTAssertTrue(fileHandler.exists(playgroundsPath))

View File

@ -1,6 +1,6 @@
import Basic import Basic
import Foundation import Foundation
import Utility import SPMUtility
import XCTest import XCTest
@testable import TuistCoreTesting @testable import TuistCoreTesting
@ -33,11 +33,11 @@ final class UpCommandTests: XCTestCase {
func test_run_configures_the_environment() throws { func test_run_configures_the_environment() throws {
// given // given
let currentPath = fileHandler.currentPath.asString let currentPath = fileHandler.currentPath.pathString
let result = try parser.parse([UpCommand.command]) let result = try parser.parse([UpCommand.command])
var receivedPaths = [String]() var receivedPaths = [String]()
setupLoader.meetStub = { path in setupLoader.meetStub = { path in
receivedPaths.append(path.asString) receivedPaths.append(path.pathString)
} }
// when // when
@ -51,10 +51,10 @@ final class UpCommandTests: XCTestCase {
func test_run_uses_the_given_path() throws { func test_run_uses_the_given_path() throws {
// given // given
let path = AbsolutePath("/path") let path = AbsolutePath("/path")
let result = try parser.parse([UpCommand.command, "-p", path.asString]) let result = try parser.parse([UpCommand.command, "-p", path.pathString])
var receivedPaths = [String]() var receivedPaths = [String]()
setupLoader.meetStub = { path in setupLoader.meetStub = { path in
receivedPaths.append(path.asString) receivedPaths.append(path.pathString)
} }
// when // when

View File

@ -75,17 +75,17 @@ final class EmbeddableTests: XCTestCase {
func test_strip_whenFramework() throws { func test_strip_whenFramework() throws {
try withUniversalFramework { try withUniversalFramework {
XCTAssertTrue(fm.fileExists(atPath: $0.path.appending(component: "Headers").asString)) XCTAssertTrue(fm.fileExists(atPath: $0.path.appending(component: "Headers").pathString))
XCTAssertTrue(fm.fileExists(atPath: $0.path.appending(component: "PrivateHeaders").asString)) XCTAssertTrue(fm.fileExists(atPath: $0.path.appending(component: "PrivateHeaders").pathString))
XCTAssertTrue(fm.fileExists(atPath: $0.path.appending(component: "Modules").asString)) XCTAssertTrue(fm.fileExists(atPath: $0.path.appending(component: "Modules").pathString))
try XCTAssertEqual($0.architectures(), ["x86_64", "arm64"]) try XCTAssertEqual($0.architectures(), ["x86_64", "arm64"])
try $0.strip(keepingArchitectures: ["x86_64"]) try $0.strip(keepingArchitectures: ["x86_64"])
try XCTAssertEqual($0.architectures(), ["x86_64"]) try XCTAssertEqual($0.architectures(), ["x86_64"])
XCTAssertFalse(fm.fileExists(atPath: $0.path.appending(component: "Headers").asString)) XCTAssertFalse(fm.fileExists(atPath: $0.path.appending(component: "Headers").pathString))
XCTAssertFalse(fm.fileExists(atPath: $0.path.appending(component: "PrivateHeaders").asString)) XCTAssertFalse(fm.fileExists(atPath: $0.path.appending(component: "PrivateHeaders").pathString))
XCTAssertFalse(fm.fileExists(atPath: $0.path.appending(component: "Modules").asString)) XCTAssertFalse(fm.fileExists(atPath: $0.path.appending(component: "Modules").pathString))
} }
} }
@ -120,7 +120,7 @@ final class EmbeddableTests: XCTestCase {
try $0.uuids().forEach { try $0.uuids().forEach {
let symbolMapPath = path.parentDirectory.appending(component: "\($0.uuidString).bcsymbolmap") let symbolMapPath = path.parentDirectory.appending(component: "\($0.uuidString).bcsymbolmap")
symbolMapsPaths.append(symbolMapPath) symbolMapsPaths.append(symbolMapPath)
fm.createFile(atPath: symbolMapPath.asString, fm.createFile(atPath: symbolMapPath.pathString,
contents: nil, contents: nil,
attributes: [:]) attributes: [:])
} }
@ -133,8 +133,8 @@ final class EmbeddableTests: XCTestCase {
let testsPath = AbsolutePath(#file).parentDirectory.parentDirectory.parentDirectory let testsPath = AbsolutePath(#file).parentDirectory.parentDirectory.parentDirectory
let frameworkPath = testsPath.appending(RelativePath("Fixtures/xpm.framework")) let frameworkPath = testsPath.appending(RelativePath("Fixtures/xpm.framework"))
let frameworkTmpPath = tmpDir.path.appending(component: "xpm.framework") let frameworkTmpPath = tmpDir.path.appending(component: "xpm.framework")
try fm.copyItem(atPath: frameworkPath.asString, try fm.copyItem(atPath: frameworkPath.pathString,
toPath: frameworkTmpPath.asString) toPath: frameworkTmpPath.pathString)
let embeddable = Embeddable(path: frameworkTmpPath) let embeddable = Embeddable(path: frameworkTmpPath)
try action(embeddable) try action(embeddable)
} }
@ -144,8 +144,8 @@ final class EmbeddableTests: XCTestCase {
let testsPath = AbsolutePath(#file).parentDirectory.parentDirectory.parentDirectory let testsPath = AbsolutePath(#file).parentDirectory.parentDirectory.parentDirectory
let frameworkPath = testsPath.appending(RelativePath("Fixtures/xpm.framework.dSYM")) let frameworkPath = testsPath.appending(RelativePath("Fixtures/xpm.framework.dSYM"))
let frameworkTmpPath = tmpDir.path.appending(component: "xpm.framework.dSYM") let frameworkTmpPath = tmpDir.path.appending(component: "xpm.framework.dSYM")
try fm.copyItem(atPath: frameworkPath.asString, try fm.copyItem(atPath: frameworkPath.pathString,
toPath: frameworkTmpPath.asString) toPath: frameworkTmpPath.pathString)
let embeddable = Embeddable(path: frameworkTmpPath) let embeddable = Embeddable(path: frameworkTmpPath)
try action(embeddable) try action(embeddable)
} }

Some files were not shown because too many files have changed in this diff Show More