diff --git a/Package.resolved b/Package.resolved index 58b23de..5d7f287 100644 --- a/Package.resolved +++ b/Package.resolved @@ -9,31 +9,13 @@ "version" : "0.6.7" } }, - { - "identity" : "mockable", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Kolos65/Mockable.git", - "state" : { - "revision" : "f931faaae32a0ef21a0dcc731e5fc8bdc7d704f9", - "version" : "0.0.8" - } - }, { "identity" : "path", "kind" : "remoteSourceControl", "location" : "https://github.com/tuist/Path.git", "state" : { - "revision" : "61e3fa3b2fd56e0bd2496afd62a35c2cb98a6fca", - "version" : "0.2.0" - } - }, - { - "identity" : "swift-syntax", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", - "state" : { - "revision" : "64889f0c732f210a935a0ad7cda38f77f876262d", - "version" : "509.1.1" + "revision" : "4490da629937fc3994f72dd787dcc3f50d6973fe", + "version" : "0.3.0" } } ], diff --git a/Package.swift b/Package.swift index dbc132e..914c97b 100644 --- a/Package.swift +++ b/Package.swift @@ -10,14 +10,6 @@ var targets: [Target] = [ "Path", ] ), - .target( - name: "XcodeGraphTesting", - dependencies: [ - "XcodeGraph", - "AnyCodable", - ], - linkerSettings: [.linkedFramework("XCTest")] - ), ] let package = Package( @@ -28,11 +20,6 @@ let package = Package( name: "XcodeGraph", targets: ["XcodeGraph"] ), - .library( - name: "XcodeGraphTesting", - targets: ["XcodeGraphTesting"] - ), - ], dependencies: [ .package(url: "https://github.com/Flight-School/AnyCodable", .upToNextMajor(from: "0.6.7")), diff --git a/Project.swift b/Project.swift index 6ee7dc2..b3b6513 100644 --- a/Project.swift +++ b/Project.swift @@ -48,24 +48,6 @@ func schemes() -> [Scheme] { ) ) ), - .scheme( - name: "TuistUnitTests", - buildAction: .buildAction( - targets: Module.allCases.flatMap(\.unitTestTargets).map(\.name).sorted() - .map { .target($0) } - ), - testAction: .targets( - Module.allCases.flatMap(\.unitTestTargets).map { .testableTarget(target: .target($0.name)) } - ), - runAction: .runAction( - arguments: .arguments( - environmentVariables: [ - "TUIST_CONFIG_SRCROOT": "$(SRCROOT)", - "TUIST_FRAMEWORK_SEARCH_PATHS": "$(FRAMEWORK_SEARCH_PATHS)", - ] - ) - ) - ), ] schemes.append(contentsOf: Module.allCases.filter(\.isRunnable).map { .scheme( diff --git a/Sources/XcodeGraph/DependenciesGraph/DependenciesGraph.swift b/Sources/XcodeGraph/DependenciesGraph/DependenciesGraph.swift index 371d773..ad29684 100644 --- a/Sources/XcodeGraph/DependenciesGraph/DependenciesGraph.swift +++ b/Sources/XcodeGraph/DependenciesGraph/DependenciesGraph.swift @@ -19,3 +19,178 @@ public struct DependenciesGraph: Equatable, Codable { /// An empty `DependenciesGraph`. public static let none: DependenciesGraph = .init(externalDependencies: [:], externalProjects: [:]) } + +#if DEBUG + extension DependenciesGraph { + public static func test( + externalDependencies: [String: [TargetDependency]] = [:], + externalProjects: [AbsolutePath: Project] = [:] + ) -> Self { + .init(externalDependencies: externalDependencies, externalProjects: externalProjects) + } + + public static func testXCFramework( + name: String = "Test", + // swiftlint:disable:next force_try + path: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "Test.xcframework")), + status: FrameworkStatus = .required + ) -> DependenciesGraph { + let externalDependencies = [name: [TargetDependency.xcframework(path: path, status: status)]] + + return .init( + externalDependencies: externalDependencies, + externalProjects: [:] + ) + } + + public static func test( + packageFolder: AbsolutePath + ) -> Self { + let externalDependencies = [ + "Tuist": [ + TargetDependency.project( + target: "Tuist", + path: packageFolder + ), + ], + ] + + return .init( + externalDependencies: externalDependencies, + externalProjects: [:] + ) + } + + public static func aDependency( + packageFolder: AbsolutePath + ) -> Self { + let externalDependencies = [ + "ALibrary": [ + TargetDependency.project( + target: "ALibrary", + path: packageFolder + ), + ], + ] + + return .init( + externalDependencies: externalDependencies, + externalProjects: [:] + ) + } + + public static func anotherDependency( + packageFolder: AbsolutePath + ) -> Self { + let externalDependencies = [ + "AnotherLibrary": [ + TargetDependency.project( + target: "AnotherLibrary", + path: packageFolder + ), + ], + ] + + return .init( + externalDependencies: externalDependencies, + externalProjects: [:] + ) + } + + public static func alamofire( + packageFolder: AbsolutePath + ) -> Self { + let externalDependencies = [ + "Alamofire": [ + TargetDependency.project( + target: "Alamofire", + path: packageFolder + ), + ], + ] + + return .init( + externalDependencies: externalDependencies, + externalProjects: [:] + ) + } + + public static func googleAppMeasurement( + packageFolder: AbsolutePath + ) -> Self { + let externalDependencies = [ + "GoogleAppMeasurement": [ + TargetDependency.project( + target: "GoogleAppMeasurementTarget", + path: packageFolder + ), + ], + "GoogleAppMeasurementWithoutAdIdSupport": [ + TargetDependency.project( + target: "GoogleAppMeasurementWithoutAdIdSupportTarget", + path: packageFolder + ), + ], + ] + + return .init( + externalDependencies: externalDependencies, + externalProjects: [:] + ) + } + + public static func googleUtilities( + packageFolder: AbsolutePath + ) -> Self { + let externalDependencies = [ + "GULAppDelegateSwizzler": [ + TargetDependency.project( + target: "GULAppDelegateSwizzler", + path: packageFolder + ), + ], + "GULMethodSwizzler": [ + TargetDependency.project( + target: "GULMethodSwizzler", + path: packageFolder + ), + ], + "GULNSData": [ + TargetDependency.project( + target: "GULNSData", + path: packageFolder + ), + ], + "GULNetwork": [ + TargetDependency.project( + target: "GULNetwork", + path: packageFolder + ), + ], + ] + + return .init( + externalDependencies: externalDependencies, + externalProjects: [:] + ) + } + + public static func nanopb( + packageFolder: AbsolutePath + ) -> Self { + let externalDependencies = [ + "nanopb": [ + TargetDependency.project( + target: "nanopb", + path: packageFolder + ), + ], + ] + + return .init( + externalDependencies: externalDependencies, + externalProjects: [:] + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Graph/Graph.swift b/Sources/XcodeGraph/Graph/Graph.swift index 033b95a..8cdf72d 100644 --- a/Sources/XcodeGraph/Graph/Graph.swift +++ b/Sources/XcodeGraph/Graph/Graph.swift @@ -65,3 +65,27 @@ extension [GraphEdge: PlatformCondition] { } } } + +#if DEBUG + extension Graph { + public static func test( + name: String = "graph", + path: AbsolutePath = .root, + workspace: Workspace = .test(), + projects: [AbsolutePath: Project] = [:], + packages: [AbsolutePath: [String: Package]] = [:], + dependencies: [GraphDependency: Set] = [:], + dependencyConditions: [GraphEdge: PlatformCondition] = [:] + ) -> Graph { + Graph( + name: name, + path: path, + workspace: workspace, + projects: projects, + packages: packages, + dependencies: dependencies, + dependencyConditions: dependencyConditions + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Graph/GraphDependency.swift b/Sources/XcodeGraph/Graph/GraphDependency.swift index 870b73c..9d99134 100644 --- a/Sources/XcodeGraph/Graph/GraphDependency.swift +++ b/Sources/XcodeGraph/Graph/GraphDependency.swift @@ -282,3 +282,114 @@ public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Coda lhs.description < rhs.description } } + +#if DEBUG + // swiftlint:disable force_try + + extension GraphDependency { + public static func testFramework( + path: AbsolutePath = AbsolutePath.root.appending(component: "Test.framework"), + binaryPath: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "Test.framework/Test")), + dsymPath: AbsolutePath? = nil, + bcsymbolmapPaths: [AbsolutePath] = [], + linking: BinaryLinking = .dynamic, + architectures: [BinaryArchitecture] = [.armv7], + status: FrameworkStatus = .required + ) -> GraphDependency { + GraphDependency.framework( + path: path, + binaryPath: binaryPath, + dsymPath: dsymPath, + bcsymbolmapPaths: bcsymbolmapPaths, + linking: linking, + architectures: architectures, + status: status + ) + } + + public static func testMacro( + path: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "macro")) + ) -> GraphDependency { + .macro(path: path) + } + + public static func testXCFramework( + path: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "Test.xcframework")), + infoPlist: XCFrameworkInfoPlist = .test(), + primaryBinaryPath: AbsolutePath = AbsolutePath.root + .appending(try! RelativePath(validating: "Test.xcframework/Test")), + linking: BinaryLinking = .dynamic, + status: FrameworkStatus = .required, + macroPath: AbsolutePath? = nil + ) -> GraphDependency { + .xcframework( + GraphDependency.XCFramework( + path: path, + infoPlist: infoPlist, + primaryBinaryPath: primaryBinaryPath, + linking: linking, + mergeable: false, + status: status, + macroPath: macroPath + ) + ) + } + + public static func testTarget( + name: String = "Test", + path: AbsolutePath = .root + ) -> GraphDependency { + .target( + name: name, + path: path + ) + } + + public static func testSDK( + name: String = "XCTest.framework", + path: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "XCTest.framework")), + status: SDKStatus = .required, + source: SDKSource = .system + ) -> GraphDependency { + .sdk( + name: name, + path: path, + status: status, + source: source + ) + } + + public static func testLibrary( + path: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "libTuist.a")), + publicHeaders: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "headers")), + linking: BinaryLinking = .dynamic, + architectures: [BinaryArchitecture] = [.armv7], + swiftModuleMap: AbsolutePath? = nil + ) -> GraphDependency { + .library( + path: path, + publicHeaders: publicHeaders, + linking: linking, + architectures: architectures, + swiftModuleMap: swiftModuleMap + ) + } + + public static func testBundle(path: AbsolutePath = .root.appending(component: "test.bundle")) -> GraphDependency { + .bundle(path: path) + } + + public static func testPackageProduct( + path: AbsolutePath = .root, + product: String = "Tuist" + ) -> GraphDependency { + .packageProduct( + path: path, + product: product, + type: .runtime + ) + } + } + + // swiftlint:enable force_try +#endif diff --git a/Sources/XcodeGraph/Graph/GraphTarget.swift b/Sources/XcodeGraph/Graph/GraphTarget.swift index a2126db..71d2563 100644 --- a/Sources/XcodeGraph/Graph/GraphTarget.swift +++ b/Sources/XcodeGraph/Graph/GraphTarget.swift @@ -31,3 +31,19 @@ public struct GraphTarget: Equatable, Hashable, Comparable, CustomDebugStringCon "Target '\(target.name)' at path '\(project.path)'" } } + +#if DEBUG + extension GraphTarget { + public static func test( + path: AbsolutePath = .root, + target: Target = .test(), + project: Project = .test() + ) -> GraphTarget { + GraphTarget( + path: path, + target: target, + project: project + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/AnalyzeAction.swift b/Sources/XcodeGraph/Models/AnalyzeAction.swift index 7f80868..eb63012 100644 --- a/Sources/XcodeGraph/Models/AnalyzeAction.swift +++ b/Sources/XcodeGraph/Models/AnalyzeAction.swift @@ -11,3 +11,11 @@ public struct AnalyzeAction: Equatable, Codable { self.configurationName = configurationName } } + +#if DEBUG + extension AnalyzeAction { + public static func test(configurationName: String = "Beta Release") -> AnalyzeAction { + AnalyzeAction(configurationName: configurationName) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/ArchiveAction.swift b/Sources/XcodeGraph/Models/ArchiveAction.swift index da727bb..a7e1ba6 100644 --- a/Sources/XcodeGraph/Models/ArchiveAction.swift +++ b/Sources/XcodeGraph/Models/ArchiveAction.swift @@ -26,3 +26,23 @@ public struct ArchiveAction: Equatable, Codable { self.postActions = postActions } } + +#if DEBUG + extension ArchiveAction { + public static func test( + configurationName: String = "Beta Release", + revealArchiveInOrganizer: Bool = true, + customArchiveName: String? = nil, + preActions: [ExecutionAction] = [], + postActions: [ExecutionAction] = [] + ) -> ArchiveAction { + ArchiveAction( + configurationName: configurationName, + revealArchiveInOrganizer: revealArchiveInOrganizer, + customArchiveName: customArchiveName, + preActions: preActions, + postActions: postActions + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/Arguments.swift b/Sources/XcodeGraph/Models/Arguments.swift index 8f43b1d..c9aac9e 100644 --- a/Sources/XcodeGraph/Models/Arguments.swift +++ b/Sources/XcodeGraph/Models/Arguments.swift @@ -28,3 +28,17 @@ extension Arguments: Equatable { == rhs.launchArguments.sorted { $0.name == $1.name } } } + +#if DEBUG + extension Arguments { + public static func test( + environmentVariables: [String: EnvironmentVariable] = [:], + launchArguments: [LaunchArgument] = [] + ) -> Arguments { + Arguments( + environmentVariables: environmentVariables, + launchArguments: launchArguments + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/BuildAction.swift b/Sources/XcodeGraph/Models/BuildAction.swift index e539571..161e0d2 100644 --- a/Sources/XcodeGraph/Models/BuildAction.swift +++ b/Sources/XcodeGraph/Models/BuildAction.swift @@ -23,3 +23,16 @@ public struct BuildAction: Equatable, Codable { self.runPostActionsOnFailure = runPostActionsOnFailure } } + +#if DEBUG + extension BuildAction { + public static func test( + // swiftlint:disable:next force_try + targets: [TargetReference] = [TargetReference(projectPath: try! AbsolutePath(validating: "/Project"), name: "App")], + preActions: [ExecutionAction] = [], + postActions: [ExecutionAction] = [] + ) -> BuildAction { + BuildAction(targets: targets, preActions: preActions, postActions: postActions) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/Headers.swift b/Sources/XcodeGraph/Models/Headers.swift index 85e76ea..1a4c4da 100644 --- a/Sources/XcodeGraph/Models/Headers.swift +++ b/Sources/XcodeGraph/Models/Headers.swift @@ -21,3 +21,19 @@ public struct Headers: Equatable, Codable { self.project = project } } + +#if DEBUG + extension Headers { + public static func test( + public: [AbsolutePath] = [], + private: [AbsolutePath] = [], + project: [AbsolutePath] = [] + ) -> Headers { + Headers( + public: `public`, + private: `private`, + project: project + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/IDETemplateMacros.swift b/Sources/XcodeGraph/Models/IDETemplateMacros.swift index 59490b2..3c4df63 100644 --- a/Sources/XcodeGraph/Models/IDETemplateMacros.swift +++ b/Sources/XcodeGraph/Models/IDETemplateMacros.swift @@ -36,3 +36,11 @@ public struct IDETemplateMacros: Codable, Hashable { return fileHeader } } + +#if DEBUG + extension IDETemplateMacros { + public static func test(fileHeader: String? = "Header template") -> IDETemplateMacros { + IDETemplateMacros(fileHeader: fileHeader) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/Metadata/FrameworkMetadata.swift b/Sources/XcodeGraph/Models/Metadata/FrameworkMetadata.swift index d1bf70b..46943cf 100644 --- a/Sources/XcodeGraph/Models/Metadata/FrameworkMetadata.swift +++ b/Sources/XcodeGraph/Models/Metadata/FrameworkMetadata.swift @@ -29,3 +29,29 @@ public struct FrameworkMetadata: Equatable { self.status = status } } + +#if DEBUG + extension FrameworkMetadata { + public static func test( + // swiftlint:disable:next force_try + path: AbsolutePath = try! AbsolutePath(validating: "/Frameworks/TestFramework.xframework"), + // swiftlint:disable:next force_try + binaryPath: AbsolutePath = try! AbsolutePath(validating: "/Frameworks/TestFramework.xframework/TestFramework"), + dsymPath: AbsolutePath? = nil, + bcsymbolmapPaths: [AbsolutePath] = [], + linking: BinaryLinking = .dynamic, + architectures: [BinaryArchitecture] = [.arm64], + status: FrameworkStatus = .required + ) -> FrameworkMetadata { + FrameworkMetadata( + path: path, + binaryPath: binaryPath, + dsymPath: dsymPath, + bcsymbolmapPaths: bcsymbolmapPaths, + linking: linking, + architectures: architectures, + status: status + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/Metadata/LibraryMetadata.swift b/Sources/XcodeGraph/Models/Metadata/LibraryMetadata.swift index c8aad5c..5861b6b 100644 --- a/Sources/XcodeGraph/Models/Metadata/LibraryMetadata.swift +++ b/Sources/XcodeGraph/Models/Metadata/LibraryMetadata.swift @@ -23,3 +23,26 @@ public struct LibraryMetadata: Equatable { self.linking = linking } } + +#if DEBUG + extension LibraryMetadata { + public static func test( + // swiftlint:disable:next force_try + path: AbsolutePath = try! AbsolutePath(validating: "/Libraries/libTest/libTest.a"), + // swiftlint:disable:next force_try + publicHeaders: AbsolutePath = try! AbsolutePath(validating: "/Libraries/libTest/include"), + // swiftlint:disable:next force_try + swiftModuleMap: AbsolutePath? = try! AbsolutePath(validating: "/Libraries/libTest/libTest.swiftmodule"), + architectures: [BinaryArchitecture] = [.arm64], + linking: BinaryLinking = .static + ) -> LibraryMetadata { + LibraryMetadata( + path: path, + publicHeaders: publicHeaders, + swiftModuleMap: swiftModuleMap, + architectures: architectures, + linking: linking + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/Metadata/XCFrameworkMetadata.swift b/Sources/XcodeGraph/Models/Metadata/XCFrameworkMetadata.swift index 707bfa7..4e80a58 100644 --- a/Sources/XcodeGraph/Models/Metadata/XCFrameworkMetadata.swift +++ b/Sources/XcodeGraph/Models/Metadata/XCFrameworkMetadata.swift @@ -29,3 +29,30 @@ public struct XCFrameworkMetadata: Equatable { self.macroPath = macroPath } } + +#if DEBUG + extension XCFrameworkMetadata { + public static func test( + // swiftlint:disable:next force_try + path: AbsolutePath = try! AbsolutePath(validating: "/XCFrameworks/XCFramework.xcframework"), + infoPlist: XCFrameworkInfoPlist = .test(), + primaryBinaryPath: AbsolutePath = + // swiftlint:disable:next force_try + try! AbsolutePath(validating: "/XCFrameworks/XCFramework.xcframework/ios-arm64/XCFramework"), + linking: BinaryLinking = .dynamic, + mergeable: Bool = false, + status: FrameworkStatus = .required, + macroPath: AbsolutePath? = nil + ) -> XCFrameworkMetadata { + XCFrameworkMetadata( + path: path, + infoPlist: infoPlist, + primaryBinaryPath: primaryBinaryPath, + linking: linking, + mergeable: mergeable, + status: status, + macroPath: macroPath + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/PlatformCondition.swift b/Sources/XcodeGraph/Models/PlatformCondition.swift index 9709766..9bfecc0 100644 --- a/Sources/XcodeGraph/Models/PlatformCondition.swift +++ b/Sources/XcodeGraph/Models/PlatformCondition.swift @@ -62,3 +62,11 @@ public struct PlatformCondition: Codable, Hashable, Equatable, Comparable { } } } + +#if DEBUG + extension PlatformCondition { + static func test(_ platformFilters: PlatformFilters) throws -> PlatformCondition? { + .when(platformFilters) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/PluginResourceSynthesizer.swift b/Sources/XcodeGraph/Models/PluginResourceSynthesizer.swift deleted file mode 100644 index 6540994..0000000 --- a/Sources/XcodeGraph/Models/PluginResourceSynthesizer.swift +++ /dev/null @@ -1,18 +0,0 @@ -import Foundation -import Path - -/// Resource synthesizer plugin model -public struct PluginResourceSynthesizer: Equatable { - /// Name of the plugin - public let name: String - /// Path to `ResourceSynthesizers` directory where all resource templates are located - public let path: AbsolutePath - - public init( - name: String, - path: AbsolutePath - ) { - self.name = name - self.path = path - } -} diff --git a/Sources/XcodeGraph/Models/ProfileAction.swift b/Sources/XcodeGraph/Models/ProfileAction.swift index 1069432..d06c143 100644 --- a/Sources/XcodeGraph/Models/ProfileAction.swift +++ b/Sources/XcodeGraph/Models/ProfileAction.swift @@ -1,4 +1,5 @@ import Foundation +import Path public struct ProfileAction: Equatable, Codable { // MARK: - Attributes @@ -25,3 +26,24 @@ public struct ProfileAction: Equatable, Codable { self.arguments = arguments } } + +#if DEBUG + extension ProfileAction { + public static func test( + configurationName: String = "Beta Release", + preActions: [ExecutionAction] = [], + postActions: [ExecutionAction] = [], + // swiftlint:disable:next force_try + executable: TargetReference? = TargetReference(projectPath: try! AbsolutePath(validating: "/Project"), name: "App"), + arguments: Arguments? = Arguments.test() + ) -> ProfileAction { + ProfileAction( + configurationName: configurationName, + preActions: preActions, + postActions: postActions, + executable: executable, + arguments: arguments + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/Project.swift b/Sources/XcodeGraph/Models/Project.swift index 57f95a8..d6cb59f 100644 --- a/Sources/XcodeGraph/Models/Project.swift +++ b/Sources/XcodeGraph/Models/Project.swift @@ -149,3 +149,135 @@ public struct Project: Hashable, Equatable, CustomStringConvertible, CustomDebug return buildConfiguration?.name ?? BuildConfiguration.debug.name } } + +#if DEBUG + extension Project { + public static func test( + path: AbsolutePath = try! AbsolutePath(validating: "/Project"), // swiftlint:disable:this force_try + sourceRootPath: AbsolutePath = try! AbsolutePath(validating: "/Project"), // swiftlint:disable:this force_try + // swiftlint:disable:next force_try + xcodeProjPath: AbsolutePath = try! AbsolutePath(validating: "/Project/Project.xcodeproj"), + name: String = "Project", + organizationName: String? = nil, + defaultKnownRegions: [String]? = nil, + developmentRegion: String? = nil, + options: Options = .test(automaticSchemesOptions: .disabled), + settings: Settings = Settings.test(), + filesGroup: ProjectGroup = .group(name: "Project"), + targets: [Target] = [Target.test()], + packages: [Package] = [], + schemes: [Scheme] = [], + ideTemplateMacros: IDETemplateMacros? = nil, + additionalFiles: [FileElement] = [], + resourceSynthesizers: [ResourceSynthesizer] = [], + lastUpgradeCheck: Version? = nil, + isExternal: Bool = false + ) -> Project { + Project( + path: path, + sourceRootPath: sourceRootPath, + xcodeProjPath: xcodeProjPath, + name: name, + organizationName: organizationName, + defaultKnownRegions: defaultKnownRegions, + developmentRegion: developmentRegion, + options: options, + settings: settings, + filesGroup: filesGroup, + targets: targets, + packages: packages, + schemes: schemes, + ideTemplateMacros: ideTemplateMacros, + additionalFiles: additionalFiles, + resourceSynthesizers: resourceSynthesizers, + lastUpgradeCheck: lastUpgradeCheck, + isExternal: isExternal + ) + } + + public static func empty( + path: AbsolutePath = try! AbsolutePath(validating: "/test/"), // swiftlint:disable:this force_try + sourceRootPath: AbsolutePath = try! AbsolutePath(validating: "/test/"), // swiftlint:disable:this force_try + // swiftlint:disable:next force_try + xcodeProjPath: AbsolutePath = try! AbsolutePath(validating: "/test/text.xcodeproj"), + name: String = "Project", + organizationName: String? = nil, + defaultKnownRegions: [String]? = nil, + developmentRegion: String? = nil, + options: Options = .test(automaticSchemesOptions: .disabled), + settings: Settings = .default, + filesGroup: ProjectGroup = .group(name: "Project"), + targets: [Target] = [], + packages: [Package] = [], + schemes: [Scheme] = [], + ideTemplateMacros: IDETemplateMacros? = nil, + additionalFiles: [FileElement] = [], + resourceSynthesizers: [ResourceSynthesizer] = [], + lastUpgradeCheck: Version? = nil, + isExternal: Bool = false + ) -> Project { + Project( + path: path, + sourceRootPath: sourceRootPath, + xcodeProjPath: xcodeProjPath, + name: name, + organizationName: organizationName, + defaultKnownRegions: defaultKnownRegions, + developmentRegion: developmentRegion, + options: options, + settings: settings, + filesGroup: filesGroup, + targets: targets, + packages: packages, + schemes: schemes, + ideTemplateMacros: ideTemplateMacros, + additionalFiles: additionalFiles, + resourceSynthesizers: resourceSynthesizers, + lastUpgradeCheck: lastUpgradeCheck, + isExternal: isExternal + ) + } + } + + extension Project.Options { + public static func test( + automaticSchemesOptions: AutomaticSchemesOptions = .enabled( + targetSchemesGrouping: .byNameSuffix( + build: ["Implementation", "Interface", "Mocks", "Testing"], + test: ["Tests", "IntegrationTests", "UITests", "SnapshotTests"], + run: ["App", "Demo"] + ), + codeCoverageEnabled: false, + testingOptions: [] + ), + disableBundleAccessors: Bool = false, + disableShowEnvironmentVarsInScriptPhases: Bool = false, + disableSynthesizedResourceAccessors: Bool = false, + textSettings: TextSettings = .init(usesTabs: nil, indentWidth: nil, tabWidth: nil, wrapsLines: nil) + ) -> Self { + .init( + automaticSchemesOptions: automaticSchemesOptions, + disableBundleAccessors: disableBundleAccessors, + disableShowEnvironmentVarsInScriptPhases: disableShowEnvironmentVarsInScriptPhases, + disableSynthesizedResourceAccessors: disableSynthesizedResourceAccessors, + textSettings: textSettings + ) + } + } + + extension Project.Options.TextSettings { + public static func test( + usesTabs: Bool? = true, + indentWidth: UInt? = 2, + tabWidth: UInt? = 2, + wrapsLines: Bool? = true + ) -> Self { + .init( + usesTabs: usesTabs, + indentWidth: indentWidth, + tabWidth: tabWidth, + wrapsLines: wrapsLines + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/ProjectDescriptionHelpersPlugin.swift b/Sources/XcodeGraph/Models/ProjectDescriptionHelpersPlugin.swift deleted file mode 100644 index 2301a32..0000000 --- a/Sources/XcodeGraph/Models/ProjectDescriptionHelpersPlugin.swift +++ /dev/null @@ -1,35 +0,0 @@ -import Foundation -import Path - -/// A model representing a custom `ProjectDescription` helper. -public struct ProjectDescriptionHelpersPlugin: Equatable { - /// Possible locations for a ProjectDescriptionHelpersPlugin - public enum Location: Equatable { - /// A plugin local to the current file system. - case local - /// A plugin on a remote server. - case remote - } - - /// The name of the helper module. - public let name: String - /// The path to `Plugin` manifest for this helper. - public let path: AbsolutePath - /// The type of location for the plugin. - public let location: Location - - /// Creates a `ProjectDescriptionHelpersPlugin`. - /// - Parameters: - /// - name: The name of the helper module. - /// - path: The path to `Plugin` manifest for this helper. - /// - location: The type of location for the plugin. - public init( - name: String, - path: AbsolutePath, - location: Location - ) { - self.name = name - self.path = path - self.location = location - } -} diff --git a/Sources/XcodeGraph/Models/RawScriptBuildPhase.swift b/Sources/XcodeGraph/Models/RawScriptBuildPhase.swift index a158845..808748f 100644 --- a/Sources/XcodeGraph/Models/RawScriptBuildPhase.swift +++ b/Sources/XcodeGraph/Models/RawScriptBuildPhase.swift @@ -38,3 +38,16 @@ public struct RawScriptBuildPhase: Equatable, Codable { self.shellPath = shellPath } } + +#if DEBUG + extension RawScriptBuildPhase { + public static func test( + name: String = "Test", + script: String = "", + showEnvVarsInLog: Bool = false, + hashable: Bool = false + ) -> RawScriptBuildPhase { + RawScriptBuildPhase(name: name, script: script, showEnvVarsInLog: showEnvVarsInLog, hashable: hashable) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/ResourceSynthesizer.swift b/Sources/XcodeGraph/Models/ResourceSynthesizer.swift index 67a5e5a..f1ce4ed 100644 --- a/Sources/XcodeGraph/Models/ResourceSynthesizer.swift +++ b/Sources/XcodeGraph/Models/ResourceSynthesizer.swift @@ -94,3 +94,16 @@ extension ResourceSynthesizer.Parser.Option: ExpressibleByArrayLiteral { self = .init(value: elements) } } + +#if DEBUG + extension XcodeGraph.ResourceSynthesizer { + public static func test( + parser: Parser = .assets, + parserOptions: [String: Parser.Option] = [:], + extensions: Set = ["xcassets"], + template: Template = .defaultTemplate("Assets") + ) -> Self { + ResourceSynthesizer(parser: parser, parserOptions: parserOptions, extensions: extensions, template: template) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/RunAction.swift b/Sources/XcodeGraph/Models/RunAction.swift index a7ac3aa..e6774dd 100644 --- a/Sources/XcodeGraph/Models/RunAction.swift +++ b/Sources/XcodeGraph/Models/RunAction.swift @@ -47,3 +47,41 @@ public struct RunAction: Equatable, Codable { self.launchStyle = launchStyle } } + +#if DEBUG + extension RunAction { + public static func test( + configurationName: String = BuildConfiguration.debug.name, + attachDebugger: Bool = true, + customLLDBInitFile: AbsolutePath? = nil, + preActions: [ExecutionAction] = [], + postActions: [ExecutionAction] = [], + // swiftlint:disable:next force_try + executable: TargetReference? = TargetReference(projectPath: try! AbsolutePath(validating: "/Project"), name: "App"), + filePath: AbsolutePath? = nil, + arguments: Arguments? = Arguments.test(), + options: RunActionOptions = .init(), + diagnosticsOptions: SchemeDiagnosticsOptions = XcodeGraph.SchemeDiagnosticsOptions( + mainThreadCheckerEnabled: true, + performanceAntipatternCheckerEnabled: true + ), + expandVariableFromTarget: TargetReference? = nil, + launchStyle: LaunchStyle = .automatically + ) -> RunAction { + RunAction( + configurationName: configurationName, + attachDebugger: attachDebugger, + customLLDBInitFile: customLLDBInitFile, + preActions: preActions, + postActions: postActions, + executable: executable, + filePath: filePath, + arguments: arguments, + options: options, + diagnosticsOptions: diagnosticsOptions, + expandVariableFromTarget: expandVariableFromTarget, + launchStyle: launchStyle + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/Scheme.swift b/Sources/XcodeGraph/Models/Scheme.swift index 8440cd1..fb40a13 100644 --- a/Sources/XcodeGraph/Models/Scheme.swift +++ b/Sources/XcodeGraph/Models/Scheme.swift @@ -38,3 +38,29 @@ public struct Scheme: Equatable, Codable { self.analyzeAction = analyzeAction } } + +#if DEBUG + extension Scheme { + public static func test( + name: String = "Test", + shared: Bool = false, + buildAction: BuildAction? = BuildAction.test(), + testAction: TestAction? = TestAction.test(), + runAction: RunAction? = RunAction.test(), + archiveAction: ArchiveAction? = ArchiveAction.test(), + profileAction: ProfileAction? = ProfileAction.test(), + analyzeAction: AnalyzeAction? = AnalyzeAction.test() + ) -> Scheme { + Scheme( + name: name, + shared: shared, + buildAction: buildAction, + testAction: testAction, + runAction: runAction, + archiveAction: archiveAction, + profileAction: profileAction, + analyzeAction: analyzeAction + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/Settings.swift b/Sources/XcodeGraph/Models/Settings.swift index 8e103c3..a89d1ed 100644 --- a/Sources/XcodeGraph/Models/Settings.swift +++ b/Sources/XcodeGraph/Models/Settings.swift @@ -199,3 +199,50 @@ extension [String: SettingValue] { } } } + +#if DEBUG + extension Configuration { + public static func test( + settings: SettingsDictionary = [:], + xcconfig: AbsolutePath? = try! AbsolutePath(validating: "/Config.xcconfig") // swiftlint:disable:this force_try + ) -> Configuration { + Configuration(settings: settings, xcconfig: xcconfig) + } + } + + extension Settings { + public static func test( + base: SettingsDictionary, + debug: Configuration, + release: Configuration + ) -> Settings { + Settings( + base: base, + configurations: [.debug: debug, .release: release] + ) + } + + public static func test( + base: SettingsDictionary = [:], + baseDebug: SettingsDictionary = [:], + configurations: [BuildConfiguration: Configuration?] = [:] + ) -> Settings { + Settings( + base: base, + baseDebug: baseDebug, + configurations: configurations + ) + } + + public static func test(defaultSettings: DefaultSettings) -> Settings { + Settings( + base: [:], + configurations: [ + .debug: Configuration(settings: [:]), + .release: Configuration(settings: [:]), + ], + defaultSettings: defaultSettings + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/Target.swift b/Sources/XcodeGraph/Models/Target.swift index ad5ab35..29fd5b9 100644 --- a/Sources/XcodeGraph/Models/Target.swift +++ b/Sources/XcodeGraph/Models/Target.swift @@ -371,3 +371,186 @@ extension Sequence { filter { $0.product == .app || $0.product == .appClip } } } + +#if DEBUG + extension Target { + /// Creates a Target with test data + /// Note: Referenced paths may not exist + public static func test( + name: String = "Target", + destinations: Destinations = [.iPhone, .iPad], + product: Product = .app, + productName: String? = nil, + bundleId: String? = nil, + deploymentTargets: DeploymentTargets = .iOS("13.1"), + infoPlist: InfoPlist? = nil, + entitlements: Entitlements? = nil, + settings: Settings? = Settings.test(), + sources: [SourceFile] = [], + resources: ResourceFileElements = .init([]), + copyFiles: [CopyFilesAction] = [], + coreDataModels: [CoreDataModel] = [], + headers: Headers? = nil, + scripts: [TargetScript] = [], + environmentVariables: [String: EnvironmentVariable] = [:], + filesGroup: ProjectGroup = .group(name: "Project"), + dependencies: [TargetDependency] = [], + rawScriptBuildPhases: [RawScriptBuildPhase] = [], + launchArguments: [LaunchArgument] = [], + playgrounds: [AbsolutePath] = [], + additionalFiles: [FileElement] = [], + prune: Bool = false, + mergedBinaryType: MergedBinaryType = .disabled, + mergeable: Bool = false + ) -> Target { + Target( + name: name, + destinations: destinations, + product: product, + productName: productName, + bundleId: bundleId ?? "io.tuist.\(name)", + deploymentTargets: deploymentTargets, + infoPlist: infoPlist, + entitlements: entitlements, + settings: settings, + sources: sources, + resources: resources, + copyFiles: copyFiles, + headers: headers, + coreDataModels: coreDataModels, + scripts: scripts, + environmentVariables: environmentVariables, + launchArguments: launchArguments, + filesGroup: filesGroup, + dependencies: dependencies, + rawScriptBuildPhases: rawScriptBuildPhases, + playgrounds: playgrounds, + additionalFiles: additionalFiles, + prune: prune, + mergedBinaryType: mergedBinaryType, + mergeable: mergeable + ) + } + + /// Creates a Target with test data + /// Note: Referenced paths may not exist + public static func test( + name: String = "Target", + platform: Platform, + product: Product = .app, + productName: String? = nil, + bundleId: String? = nil, + deploymentTarget: DeploymentTargets = .iOS("13.1"), + infoPlist: InfoPlist? = nil, + entitlements: Entitlements? = nil, + settings: Settings? = Settings.test(), + sources: [SourceFile] = [], + resources: ResourceFileElements = .init([]), + copyFiles: [CopyFilesAction] = [], + coreDataModels: [CoreDataModel] = [], + headers: Headers? = nil, + scripts: [TargetScript] = [], + environmentVariables: [String: EnvironmentVariable] = [:], + filesGroup: ProjectGroup = .group(name: "Project"), + dependencies: [TargetDependency] = [], + rawScriptBuildPhases: [RawScriptBuildPhase] = [], + launchArguments: [LaunchArgument] = [], + playgrounds: [AbsolutePath] = [], + additionalFiles: [FileElement] = [], + prune: Bool = false, + mergedBinaryType: MergedBinaryType = .disabled, + mergeable: Bool = false + ) -> Target { + Target( + name: name, + destinations: destinationsFrom(platform), + product: product, + productName: productName, + bundleId: bundleId ?? "io.tuist.\(name)", + deploymentTargets: deploymentTarget, + infoPlist: infoPlist, + entitlements: entitlements, + settings: settings, + sources: sources, + resources: resources, + copyFiles: copyFiles, + headers: headers, + coreDataModels: coreDataModels, + scripts: scripts, + environmentVariables: environmentVariables, + launchArguments: launchArguments, + filesGroup: filesGroup, + dependencies: dependencies, + rawScriptBuildPhases: rawScriptBuildPhases, + playgrounds: playgrounds, + additionalFiles: additionalFiles, + prune: prune, + mergedBinaryType: mergedBinaryType, + mergeable: mergeable + ) + } + + /// Creates a bare bones Target with as little data as possible + public static func empty( + name: String = "Target", + destinations: Destinations = [.iPhone, .iPad], + product: Product = .app, + productName: String? = nil, + bundleId: String? = nil, + deploymentTargets: DeploymentTargets = .init(), + infoPlist: InfoPlist? = nil, + entitlements: Entitlements? = nil, + settings: Settings? = nil, + sources: [SourceFile] = [], + resources: ResourceFileElements = .init([]), + copyFiles: [CopyFilesAction] = [], + coreDataModels: [CoreDataModel] = [], + headers: Headers? = nil, + scripts: [TargetScript] = [], + environmentVariables: [String: EnvironmentVariable] = [:], + filesGroup: ProjectGroup = .group(name: "Project"), + dependencies: [TargetDependency] = [], + rawScriptBuildPhases: [RawScriptBuildPhase] = [], + onDemandResourcesTags: OnDemandResourcesTags? = nil + ) -> Target { + Target( + name: name, + destinations: destinations, + product: product, + productName: productName, + bundleId: bundleId ?? "io.tuist.\(name)", + deploymentTargets: deploymentTargets, + infoPlist: infoPlist, + entitlements: entitlements, + settings: settings, + sources: sources, + resources: resources, + copyFiles: copyFiles, + headers: headers, + coreDataModels: coreDataModels, + scripts: scripts, + environmentVariables: environmentVariables, + filesGroup: filesGroup, + dependencies: dependencies, + rawScriptBuildPhases: rawScriptBuildPhases, + onDemandResourcesTags: onDemandResourcesTags + ) + } + + // Maps a platform to a set of Destinations. For migration purposes + private static func destinationsFrom(_ platform: Platform) -> Destinations { + switch platform { + case .iOS: + return .iOS + case .macOS: + return .macOS + case .tvOS: + return .tvOS + case .watchOS: + return .watchOS + case .visionOS: + return .visionOS + } + } + } +#endif diff --git a/Sources/XcodeGraph/Models/TestAction.swift b/Sources/XcodeGraph/Models/TestAction.swift index 501251a..8575a4f 100644 --- a/Sources/XcodeGraph/Models/TestAction.swift +++ b/Sources/XcodeGraph/Models/TestAction.swift @@ -56,3 +56,47 @@ public struct TestAction: Equatable, Codable { self.skippedTests = skippedTests } } + +#if DEBUG + extension TestAction { + public static func test( + targets: [TestableTarget] = [TestableTarget(target: TargetReference( + // swiftlint:disable:next force_try + projectPath: try! AbsolutePath(validating: "/Project"), + name: "AppTests" + ))], + arguments: Arguments? = Arguments.test(), + configurationName: String = BuildConfiguration.debug.name, + attachDebugger: Bool = true, + coverage: Bool = false, + codeCoverageTargets: [TargetReference] = [], + expandVariableFromTarget: TargetReference? = nil, + preActions: [ExecutionAction] = [], + postActions: [ExecutionAction] = [], + diagnosticsOptions: SchemeDiagnosticsOptions = SchemeDiagnosticsOptions(mainThreadCheckerEnabled: true), + language: String? = nil, + region: String? = nil, + preferredScreenCaptureFormat: ScreenCaptureFormat? = nil, + testPlans: [TestPlan]? = nil, + skippedTests: [String]? = nil + ) -> TestAction { + TestAction( + targets: targets, + arguments: arguments, + configurationName: configurationName, + attachDebugger: attachDebugger, + coverage: coverage, + codeCoverageTargets: codeCoverageTargets, + expandVariableFromTarget: expandVariableFromTarget, + preActions: preActions, + postActions: postActions, + diagnosticsOptions: diagnosticsOptions, + language: language, + region: region, + preferredScreenCaptureFormat: preferredScreenCaptureFormat, + testPlans: testPlans, + skippedTests: skippedTests + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/TestableTarget.swift b/Sources/XcodeGraph/Models/TestableTarget.swift index b53e609..c6522ab 100644 --- a/Sources/XcodeGraph/Models/TestableTarget.swift +++ b/Sources/XcodeGraph/Models/TestableTarget.swift @@ -1,4 +1,5 @@ import Foundation +import Path /// Testable target describe target and tests information. public struct TestableTarget: Equatable, Hashable, Codable { @@ -27,3 +28,24 @@ public struct TestableTarget: Equatable, Hashable, Codable { self.simulatedLocation = simulatedLocation } } + +#if DEBUG + extension TestableTarget { + public static func test( + // swiftlint:disable:next force_try + target: TargetReference = TargetReference(projectPath: try! AbsolutePath(validating: "/Project"), name: "App"), + skipped: Bool = false, + parallelizable: Bool = false, + randomExecutionOrdering: Bool = false, + simulatedLocation: SimulatedLocation? = nil + ) -> TestableTarget { + TestableTarget( + target: target, + skipped: skipped, + parallelizable: parallelizable, + randomExecutionOrdering: randomExecutionOrdering, + simulatedLocation: simulatedLocation + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/Workspace.swift b/Sources/XcodeGraph/Models/Workspace.swift index e66ea8c..4fc7f6f 100644 --- a/Sources/XcodeGraph/Models/Workspace.swift +++ b/Sources/XcodeGraph/Models/Workspace.swift @@ -147,3 +147,50 @@ extension Workspace { } } } + +#if DEBUG + extension Workspace { + public static func test( + path: AbsolutePath = try! AbsolutePath(validating: "/"), // swiftlint:disable:this force_try + xcWorkspacePath: AbsolutePath = try! AbsolutePath(validating: "/"), // swiftlint:disable:this force_try + name: String = "test", + projects: [AbsolutePath] = [], + schemes: [Scheme] = [], + ideTemplateMacros: IDETemplateMacros? = nil, + additionalFiles: [FileElement] = [], + generationOptions: GenerationOptions = .test() + ) -> Workspace { + Workspace( + path: path, + xcWorkspacePath: xcWorkspacePath, + name: name, + projects: projects, + schemes: schemes, + generationOptions: generationOptions, + ideTemplateMacros: ideTemplateMacros, + additionalFiles: additionalFiles + ) + } + } + + extension Workspace.GenerationOptions { + public static func test( + enableAutomaticXcodeSchemes: Bool? = false, + autogeneratedWorkspaceSchemes: AutogeneratedWorkspaceSchemes = .enabled( + codeCoverageMode: .disabled, + testingOptions: [], + testLanguage: nil, + testRegion: nil, + testScreenCaptureFormat: nil + ), + lastXcodeUpgradeCheck: Version? = nil + ) -> Self { + .init( + enableAutomaticXcodeSchemes: enableAutomaticXcodeSchemes, + autogeneratedWorkspaceSchemes: autogeneratedWorkspaceSchemes, + lastXcodeUpgradeCheck: lastXcodeUpgradeCheck, + renderMarkdownReadme: false + ) + } + } +#endif diff --git a/Sources/XcodeGraph/Models/XCFrameworkInfoPlist.swift b/Sources/XcodeGraph/Models/XCFrameworkInfoPlist.swift index 27b56a1..41767bb 100644 --- a/Sources/XcodeGraph/Models/XCFrameworkInfoPlist.swift +++ b/Sources/XcodeGraph/Models/XCFrameworkInfoPlist.swift @@ -70,3 +70,28 @@ public struct XCFrameworkInfoPlist: Codable, Hashable, Equatable { /// List of libraries that are part of the .xcframework. public let libraries: [Library] } + +#if DEBUG + extension XCFrameworkInfoPlist { + public static func test(libraries: [XCFrameworkInfoPlist.Library] = [.test()]) -> XCFrameworkInfoPlist { + XCFrameworkInfoPlist(libraries: libraries) + } + } + + extension XCFrameworkInfoPlist.Library { + public static func test( + identifier: String = "test", + // swiftlint:disable:next force_try + path: RelativePath = try! RelativePath(validating: "relative/to/library"), + mergeable: Bool = false, + architectures: [BinaryArchitecture] = [.i386] + ) -> XCFrameworkInfoPlist.Library { + XCFrameworkInfoPlist.Library( + identifier: identifier, + path: path, + mergeable: mergeable, + architectures: architectures + ) + } + } +#endif diff --git a/Sources/XcodeGraphTesting/DependenciesGraph/DependenciesGraph+TestData.swift b/Sources/XcodeGraphTesting/DependenciesGraph/DependenciesGraph+TestData.swift deleted file mode 100644 index fe51b9b..0000000 --- a/Sources/XcodeGraphTesting/DependenciesGraph/DependenciesGraph+TestData.swift +++ /dev/null @@ -1,176 +0,0 @@ -import Foundation -import Path -import XcodeGraph - -extension DependenciesGraph { - public static func test( - externalDependencies: [String: [TargetDependency]] = [:], - externalProjects: [AbsolutePath: Project] = [:] - ) -> Self { - .init(externalDependencies: externalDependencies, externalProjects: externalProjects) - } - - public static func testXCFramework( - name: String = "Test", - // swiftlint:disable:next force_try - path: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "Test.xcframework")), - status: FrameworkStatus = .required - ) -> DependenciesGraph { - let externalDependencies = [name: [TargetDependency.xcframework(path: path, status: status)]] - - return .init( - externalDependencies: externalDependencies, - externalProjects: [:] - ) - } - - public static func test( - packageFolder: AbsolutePath - ) -> Self { - let externalDependencies = [ - "Tuist": [ - TargetDependency.project( - target: "Tuist", - path: packageFolder - ), - ], - ] - - return .init( - externalDependencies: externalDependencies, - externalProjects: [:] - ) - } - - public static func aDependency( - packageFolder: AbsolutePath - ) -> Self { - let externalDependencies = [ - "ALibrary": [ - TargetDependency.project( - target: "ALibrary", - path: packageFolder - ), - ], - ] - - return .init( - externalDependencies: externalDependencies, - externalProjects: [:] - ) - } - - public static func anotherDependency( - packageFolder: AbsolutePath - ) -> Self { - let externalDependencies = [ - "AnotherLibrary": [ - TargetDependency.project( - target: "AnotherLibrary", - path: packageFolder - ), - ], - ] - - return .init( - externalDependencies: externalDependencies, - externalProjects: [:] - ) - } - - public static func alamofire( - packageFolder: AbsolutePath - ) -> Self { - let externalDependencies = [ - "Alamofire": [ - TargetDependency.project( - target: "Alamofire", - path: packageFolder - ), - ], - ] - - return .init( - externalDependencies: externalDependencies, - externalProjects: [:] - ) - } - - public static func googleAppMeasurement( - packageFolder: AbsolutePath - ) -> Self { - let externalDependencies = [ - "GoogleAppMeasurement": [ - TargetDependency.project( - target: "GoogleAppMeasurementTarget", - path: packageFolder - ), - ], - "GoogleAppMeasurementWithoutAdIdSupport": [ - TargetDependency.project( - target: "GoogleAppMeasurementWithoutAdIdSupportTarget", - path: packageFolder - ), - ], - ] - - return .init( - externalDependencies: externalDependencies, - externalProjects: [:] - ) - } - - public static func googleUtilities( - packageFolder: AbsolutePath - ) -> Self { - let externalDependencies = [ - "GULAppDelegateSwizzler": [ - TargetDependency.project( - target: "GULAppDelegateSwizzler", - path: packageFolder - ), - ], - "GULMethodSwizzler": [ - TargetDependency.project( - target: "GULMethodSwizzler", - path: packageFolder - ), - ], - "GULNSData": [ - TargetDependency.project( - target: "GULNSData", - path: packageFolder - ), - ], - "GULNetwork": [ - TargetDependency.project( - target: "GULNetwork", - path: packageFolder - ), - ], - ] - - return .init( - externalDependencies: externalDependencies, - externalProjects: [:] - ) - } - - public static func nanopb( - packageFolder: AbsolutePath - ) -> Self { - let externalDependencies = [ - "nanopb": [ - TargetDependency.project( - target: "nanopb", - path: packageFolder - ), - ], - ] - - return .init( - externalDependencies: externalDependencies, - externalProjects: [:] - ) - } -} diff --git a/Sources/XcodeGraphTesting/Graph/Graph+TestData.swift b/Sources/XcodeGraphTesting/Graph/Graph+TestData.swift deleted file mode 100644 index 266b1c0..0000000 --- a/Sources/XcodeGraphTesting/Graph/Graph+TestData.swift +++ /dev/null @@ -1,25 +0,0 @@ -import Foundation -import Path -import XcodeGraph - -extension Graph { - public static func test( - name: String = "graph", - path: AbsolutePath = .root, - workspace: Workspace = .test(), - projects: [AbsolutePath: Project] = [:], - packages: [AbsolutePath: [String: Package]] = [:], - dependencies: [GraphDependency: Set] = [:], - dependencyConditions: [GraphEdge: PlatformCondition] = [:] - ) -> Graph { - Graph( - name: name, - path: path, - workspace: workspace, - projects: projects, - packages: packages, - dependencies: dependencies, - dependencyConditions: dependencyConditions - ) - } -} diff --git a/Sources/XcodeGraphTesting/Graph/GraphDependency+TestData.swift b/Sources/XcodeGraphTesting/Graph/GraphDependency+TestData.swift deleted file mode 100644 index 8373926..0000000 --- a/Sources/XcodeGraphTesting/Graph/GraphDependency+TestData.swift +++ /dev/null @@ -1,113 +0,0 @@ -import Foundation -import Path - -@testable import XcodeGraph - -// swiftlint:disable force_try - -extension GraphDependency { - public static func testFramework( - path: AbsolutePath = AbsolutePath.root.appending(component: "Test.framework"), - binaryPath: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "Test.framework/Test")), - dsymPath: AbsolutePath? = nil, - bcsymbolmapPaths: [AbsolutePath] = [], - linking: BinaryLinking = .dynamic, - architectures: [BinaryArchitecture] = [.armv7], - status: FrameworkStatus = .required - ) -> GraphDependency { - GraphDependency.framework( - path: path, - binaryPath: binaryPath, - dsymPath: dsymPath, - bcsymbolmapPaths: bcsymbolmapPaths, - linking: linking, - architectures: architectures, - status: status - ) - } - - public static func testMacro( - path: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "macro")) - ) -> GraphDependency { - .macro(path: path) - } - - public static func testXCFramework( - path: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "Test.xcframework")), - infoPlist: XCFrameworkInfoPlist = .test(), - primaryBinaryPath: AbsolutePath = AbsolutePath.root - .appending(try! RelativePath(validating: "Test.xcframework/Test")), - linking: BinaryLinking = .dynamic, - status: FrameworkStatus = .required, - macroPath: AbsolutePath? = nil - ) -> GraphDependency { - .xcframework( - GraphDependency.XCFramework( - path: path, - infoPlist: infoPlist, - primaryBinaryPath: primaryBinaryPath, - linking: linking, - mergeable: false, - status: status, - macroPath: macroPath - ) - ) - } - - public static func testTarget( - name: String = "Test", - path: AbsolutePath = .root - ) -> GraphDependency { - .target( - name: name, - path: path - ) - } - - public static func testSDK( - name: String = "XCTest.framework", - path: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "XCTest.framework")), - status: SDKStatus = .required, - source: SDKSource = .system - ) -> GraphDependency { - .sdk( - name: name, - path: path, - status: status, - source: source - ) - } - - public static func testLibrary( - path: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "libTuist.a")), - publicHeaders: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "headers")), - linking: BinaryLinking = .dynamic, - architectures: [BinaryArchitecture] = [.armv7], - swiftModuleMap: AbsolutePath? = nil - ) -> GraphDependency { - .library( - path: path, - publicHeaders: publicHeaders, - linking: linking, - architectures: architectures, - swiftModuleMap: swiftModuleMap - ) - } - - public static func testBundle(path: AbsolutePath = .root.appending(component: "test.bundle")) -> GraphDependency { - .bundle(path: path) - } - - public static func testPackageProduct( - path: AbsolutePath = .root, - product: String = "Tuist" - ) -> GraphDependency { - .packageProduct( - path: path, - product: product, - type: .runtime - ) - } -} - -// swiftlint:enable force_try diff --git a/Sources/XcodeGraphTesting/Graph/GraphTarget+TestData.swift b/Sources/XcodeGraphTesting/Graph/GraphTarget+TestData.swift deleted file mode 100644 index 5bf7fc6..0000000 --- a/Sources/XcodeGraphTesting/Graph/GraphTarget+TestData.swift +++ /dev/null @@ -1,18 +0,0 @@ -import Foundation -import Path - -@testable import XcodeGraph - -extension GraphTarget { - public static func test( - path: AbsolutePath = .root, - target: Target = .test(), - project: Project = .test() - ) -> GraphTarget { - GraphTarget( - path: path, - target: target, - project: project - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/AnalyzeAction+TestData.swift b/Sources/XcodeGraphTesting/Models/AnalyzeAction+TestData.swift deleted file mode 100644 index 28e1b7e..0000000 --- a/Sources/XcodeGraphTesting/Models/AnalyzeAction+TestData.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension AnalyzeAction { - public static func test(configurationName: String = "Beta Release") -> AnalyzeAction { - AnalyzeAction(configurationName: configurationName) - } -} diff --git a/Sources/XcodeGraphTesting/Models/ArchiveAction+TestData.swift b/Sources/XcodeGraphTesting/Models/ArchiveAction+TestData.swift deleted file mode 100644 index 0e1e915..0000000 --- a/Sources/XcodeGraphTesting/Models/ArchiveAction+TestData.swift +++ /dev/null @@ -1,21 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension ArchiveAction { - public static func test( - configurationName: String = "Beta Release", - revealArchiveInOrganizer: Bool = true, - customArchiveName: String? = nil, - preActions: [ExecutionAction] = [], - postActions: [ExecutionAction] = [] - ) -> ArchiveAction { - ArchiveAction( - configurationName: configurationName, - revealArchiveInOrganizer: revealArchiveInOrganizer, - customArchiveName: customArchiveName, - preActions: preActions, - postActions: postActions - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/Arguments+TestData.swift b/Sources/XcodeGraphTesting/Models/Arguments+TestData.swift deleted file mode 100644 index ed2d6c9..0000000 --- a/Sources/XcodeGraphTesting/Models/Arguments+TestData.swift +++ /dev/null @@ -1,15 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension Arguments { - public static func test( - environmentVariables: [String: EnvironmentVariable] = [:], - launchArguments: [LaunchArgument] = [] - ) -> Arguments { - Arguments( - environmentVariables: environmentVariables, - launchArguments: launchArguments - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/BuildAction+TestData.swift b/Sources/XcodeGraphTesting/Models/BuildAction+TestData.swift deleted file mode 100644 index 62a4b15..0000000 --- a/Sources/XcodeGraphTesting/Models/BuildAction+TestData.swift +++ /dev/null @@ -1,14 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension BuildAction { - public static func test( - // swiftlint:disable:next force_try - targets: [TargetReference] = [TargetReference(projectPath: try! AbsolutePath(validating: "/Project"), name: "App")], - preActions: [ExecutionAction] = [], - postActions: [ExecutionAction] = [] - ) -> BuildAction { - BuildAction(targets: targets, preActions: preActions, postActions: postActions) - } -} diff --git a/Sources/XcodeGraphTesting/Models/Condition+TestData.swift b/Sources/XcodeGraphTesting/Models/Condition+TestData.swift deleted file mode 100644 index 6500e4a..0000000 --- a/Sources/XcodeGraphTesting/Models/Condition+TestData.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Foundation -import XcodeGraph -import XCTest - -extension PlatformCondition { - static func test(_ platformFilters: PlatformFilters) throws -> PlatformCondition { - try XCTUnwrap(.when(platformFilters)) - } -} diff --git a/Sources/XcodeGraphTesting/Models/Headers+TestData.swift b/Sources/XcodeGraphTesting/Models/Headers+TestData.swift deleted file mode 100644 index 4a6641b..0000000 --- a/Sources/XcodeGraphTesting/Models/Headers+TestData.swift +++ /dev/null @@ -1,17 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension Headers { - public static func test( - public: [AbsolutePath] = [], - private: [AbsolutePath] = [], - project: [AbsolutePath] = [] - ) -> Headers { - Headers( - public: `public`, - private: `private`, - project: project - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/IDETemplateMacros+TestData.swift b/Sources/XcodeGraphTesting/Models/IDETemplateMacros+TestData.swift deleted file mode 100644 index 1fb4e8c..0000000 --- a/Sources/XcodeGraphTesting/Models/IDETemplateMacros+TestData.swift +++ /dev/null @@ -1,8 +0,0 @@ -import Foundation -import XcodeGraph - -extension IDETemplateMacros { - public static func test(fileHeader: String? = "Header template") -> IDETemplateMacros { - IDETemplateMacros(fileHeader: fileHeader) - } -} diff --git a/Sources/XcodeGraphTesting/Models/Metadata/FrameworkMetadata+TestData.swift b/Sources/XcodeGraphTesting/Models/Metadata/FrameworkMetadata+TestData.swift deleted file mode 100644 index 87e19e9..0000000 --- a/Sources/XcodeGraphTesting/Models/Metadata/FrameworkMetadata+TestData.swift +++ /dev/null @@ -1,27 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension FrameworkMetadata { - public static func test( - // swiftlint:disable:next force_try - path: AbsolutePath = try! AbsolutePath(validating: "/Frameworks/TestFramework.xframework"), - // swiftlint:disable:next force_try - binaryPath: AbsolutePath = try! AbsolutePath(validating: "/Frameworks/TestFramework.xframework/TestFramework"), - dsymPath: AbsolutePath? = nil, - bcsymbolmapPaths: [AbsolutePath] = [], - linking: BinaryLinking = .dynamic, - architectures: [BinaryArchitecture] = [.arm64], - status: FrameworkStatus = .required - ) -> FrameworkMetadata { - FrameworkMetadata( - path: path, - binaryPath: binaryPath, - dsymPath: dsymPath, - bcsymbolmapPaths: bcsymbolmapPaths, - linking: linking, - architectures: architectures, - status: status - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/Metadata/LibraryMetadata+TestData.swift b/Sources/XcodeGraphTesting/Models/Metadata/LibraryMetadata+TestData.swift deleted file mode 100644 index 4d0e275..0000000 --- a/Sources/XcodeGraphTesting/Models/Metadata/LibraryMetadata+TestData.swift +++ /dev/null @@ -1,24 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension LibraryMetadata { - public static func test( - // swiftlint:disable:next force_try - path: AbsolutePath = try! AbsolutePath(validating: "/Libraries/libTest/libTest.a"), - // swiftlint:disable:next force_try - publicHeaders: AbsolutePath = try! AbsolutePath(validating: "/Libraries/libTest/include"), - // swiftlint:disable:next force_try - swiftModuleMap: AbsolutePath? = try! AbsolutePath(validating: "/Libraries/libTest/libTest.swiftmodule"), - architectures: [BinaryArchitecture] = [.arm64], - linking: BinaryLinking = .static - ) -> LibraryMetadata { - LibraryMetadata( - path: path, - publicHeaders: publicHeaders, - swiftModuleMap: swiftModuleMap, - architectures: architectures, - linking: linking - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/Metadata/XCFrameworkMetadata+TestData.swift b/Sources/XcodeGraphTesting/Models/Metadata/XCFrameworkMetadata+TestData.swift deleted file mode 100644 index dbff736..0000000 --- a/Sources/XcodeGraphTesting/Models/Metadata/XCFrameworkMetadata+TestData.swift +++ /dev/null @@ -1,28 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension XCFrameworkMetadata { - public static func test( - // swiftlint:disable:next force_try - path: AbsolutePath = try! AbsolutePath(validating: "/XCFrameworks/XCFramework.xcframework"), - infoPlist: XCFrameworkInfoPlist = .test(), - primaryBinaryPath: AbsolutePath = - // swiftlint:disable:next force_try - try! AbsolutePath(validating: "/XCFrameworks/XCFramework.xcframework/ios-arm64/XCFramework"), - linking: BinaryLinking = .dynamic, - mergeable: Bool = false, - status: FrameworkStatus = .required, - macroPath: AbsolutePath? = nil - ) -> XCFrameworkMetadata { - XCFrameworkMetadata( - path: path, - infoPlist: infoPlist, - primaryBinaryPath: primaryBinaryPath, - linking: linking, - mergeable: mergeable, - status: status, - macroPath: macroPath - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/ProfileAction+TestData.swift b/Sources/XcodeGraphTesting/Models/ProfileAction+TestData.swift deleted file mode 100644 index 12332ba..0000000 --- a/Sources/XcodeGraphTesting/Models/ProfileAction+TestData.swift +++ /dev/null @@ -1,22 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension ProfileAction { - public static func test( - configurationName: String = "Beta Release", - preActions: [ExecutionAction] = [], - postActions: [ExecutionAction] = [], - // swiftlint:disable:next force_try - executable: TargetReference? = TargetReference(projectPath: try! AbsolutePath(validating: "/Project"), name: "App"), - arguments: Arguments? = Arguments.test() - ) -> ProfileAction { - ProfileAction( - configurationName: configurationName, - preActions: preActions, - postActions: postActions, - executable: executable, - arguments: arguments - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/Project+TestData.swift b/Sources/XcodeGraphTesting/Models/Project+TestData.swift deleted file mode 100644 index 2409d8e..0000000 --- a/Sources/XcodeGraphTesting/Models/Project+TestData.swift +++ /dev/null @@ -1,90 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension Project { - public static func test( - path: AbsolutePath = try! AbsolutePath(validating: "/Project"), // swiftlint:disable:this force_try - sourceRootPath: AbsolutePath = try! AbsolutePath(validating: "/Project"), // swiftlint:disable:this force_try - // swiftlint:disable:next force_try - xcodeProjPath: AbsolutePath = try! AbsolutePath(validating: "/Project/Project.xcodeproj"), - name: String = "Project", - organizationName: String? = nil, - defaultKnownRegions: [String]? = nil, - developmentRegion: String? = nil, - options: Options = .test(automaticSchemesOptions: .disabled), - settings: Settings = Settings.test(), - filesGroup: ProjectGroup = .group(name: "Project"), - targets: [Target] = [Target.test()], - packages: [Package] = [], - schemes: [Scheme] = [], - ideTemplateMacros: IDETemplateMacros? = nil, - additionalFiles: [FileElement] = [], - resourceSynthesizers: [ResourceSynthesizer] = [], - lastUpgradeCheck: Version? = nil, - isExternal: Bool = false - ) -> Project { - Project( - path: path, - sourceRootPath: sourceRootPath, - xcodeProjPath: xcodeProjPath, - name: name, - organizationName: organizationName, - defaultKnownRegions: defaultKnownRegions, - developmentRegion: developmentRegion, - options: options, - settings: settings, - filesGroup: filesGroup, - targets: targets, - packages: packages, - schemes: schemes, - ideTemplateMacros: ideTemplateMacros, - additionalFiles: additionalFiles, - resourceSynthesizers: resourceSynthesizers, - lastUpgradeCheck: lastUpgradeCheck, - isExternal: isExternal - ) - } - - public static func empty( - path: AbsolutePath = try! AbsolutePath(validating: "/test/"), // swiftlint:disable:this force_try - sourceRootPath: AbsolutePath = try! AbsolutePath(validating: "/test/"), // swiftlint:disable:this force_try - xcodeProjPath: AbsolutePath = try! AbsolutePath(validating: "/test/text.xcodeproj"), // swiftlint:disable:this force_try - name: String = "Project", - organizationName: String? = nil, - defaultKnownRegions: [String]? = nil, - developmentRegion: String? = nil, - options: Options = .test(automaticSchemesOptions: .disabled), - settings: Settings = .default, - filesGroup: ProjectGroup = .group(name: "Project"), - targets: [Target] = [], - packages: [Package] = [], - schemes: [Scheme] = [], - ideTemplateMacros: IDETemplateMacros? = nil, - additionalFiles: [FileElement] = [], - resourceSynthesizers: [ResourceSynthesizer] = [], - lastUpgradeCheck: Version? = nil, - isExternal: Bool = false - ) -> Project { - Project( - path: path, - sourceRootPath: sourceRootPath, - xcodeProjPath: xcodeProjPath, - name: name, - organizationName: organizationName, - defaultKnownRegions: defaultKnownRegions, - developmentRegion: developmentRegion, - options: options, - settings: settings, - filesGroup: filesGroup, - targets: targets, - packages: packages, - schemes: schemes, - ideTemplateMacros: ideTemplateMacros, - additionalFiles: additionalFiles, - resourceSynthesizers: resourceSynthesizers, - lastUpgradeCheck: lastUpgradeCheck, - isExternal: isExternal - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/ProjectOptions+TestData.swift b/Sources/XcodeGraphTesting/Models/ProjectOptions+TestData.swift deleted file mode 100644 index 1c71d38..0000000 --- a/Sources/XcodeGraphTesting/Models/ProjectOptions+TestData.swift +++ /dev/null @@ -1,44 +0,0 @@ -import Foundation -@testable import XcodeGraph - -extension Project.Options { - public static func test( - automaticSchemesOptions: AutomaticSchemesOptions = .enabled( - targetSchemesGrouping: .byNameSuffix( - build: ["Implementation", "Interface", "Mocks", "Testing"], - test: ["Tests", "IntegrationTests", "UITests", "SnapshotTests"], - run: ["App", "Demo"] - ), - codeCoverageEnabled: false, - testingOptions: [] - ), - disableBundleAccessors: Bool = false, - disableShowEnvironmentVarsInScriptPhases: Bool = false, - disableSynthesizedResourceAccessors: Bool = false, - textSettings: TextSettings = .init(usesTabs: nil, indentWidth: nil, tabWidth: nil, wrapsLines: nil) - ) -> Self { - .init( - automaticSchemesOptions: automaticSchemesOptions, - disableBundleAccessors: disableBundleAccessors, - disableShowEnvironmentVarsInScriptPhases: disableShowEnvironmentVarsInScriptPhases, - disableSynthesizedResourceAccessors: disableSynthesizedResourceAccessors, - textSettings: textSettings - ) - } -} - -extension Project.Options.TextSettings { - public static func test( - usesTabs: Bool? = true, - indentWidth: UInt? = 2, - tabWidth: UInt? = 2, - wrapsLines: Bool? = true - ) -> Self { - .init( - usesTabs: usesTabs, - indentWidth: indentWidth, - tabWidth: tabWidth, - wrapsLines: wrapsLines - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/RawScriptBuildPhase+TestData.swift b/Sources/XcodeGraphTesting/Models/RawScriptBuildPhase+TestData.swift deleted file mode 100644 index 4ed9931..0000000 --- a/Sources/XcodeGraphTesting/Models/RawScriptBuildPhase+TestData.swift +++ /dev/null @@ -1,14 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension RawScriptBuildPhase { - public static func test( - name: String = "Test", - script: String = "", - showEnvVarsInLog: Bool = false, - hashable: Bool = false - ) -> RawScriptBuildPhase { - RawScriptBuildPhase(name: name, script: script, showEnvVarsInLog: showEnvVarsInLog, hashable: hashable) - } -} diff --git a/Sources/XcodeGraphTesting/Models/ResourceSynthesizerPlugin+TestData.swift b/Sources/XcodeGraphTesting/Models/ResourceSynthesizerPlugin+TestData.swift deleted file mode 100644 index a2e33ac..0000000 --- a/Sources/XcodeGraphTesting/Models/ResourceSynthesizerPlugin+TestData.swift +++ /dev/null @@ -1,15 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension PluginResourceSynthesizer { - public static func test( - name: String = "Plugin", - path: AbsolutePath = try! AbsolutePath(validating: "/test") // swiftlint:disable:this force_try - ) -> Self { - .init( - name: name, - path: path - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/ResourceSynthesizers+TestData.swift b/Sources/XcodeGraphTesting/Models/ResourceSynthesizers+TestData.swift deleted file mode 100644 index e7f8898..0000000 --- a/Sources/XcodeGraphTesting/Models/ResourceSynthesizers+TestData.swift +++ /dev/null @@ -1,13 +0,0 @@ -import Foundation -@testable import XcodeGraph - -extension XcodeGraph.ResourceSynthesizer { - public static func test( - parser: Parser = .assets, - parserOptions: [String: Parser.Option] = [:], - extensions: Set = ["xcassets"], - template: Template = .defaultTemplate("Assets") - ) -> Self { - ResourceSynthesizer(parser: parser, parserOptions: parserOptions, extensions: extensions, template: template) - } -} diff --git a/Sources/XcodeGraphTesting/Models/RunAction+TestData.swift b/Sources/XcodeGraphTesting/Models/RunAction+TestData.swift deleted file mode 100644 index 7212910..0000000 --- a/Sources/XcodeGraphTesting/Models/RunAction+TestData.swift +++ /dev/null @@ -1,39 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension RunAction { - public static func test( - configurationName: String = BuildConfiguration.debug.name, - attachDebugger: Bool = true, - customLLDBInitFile: AbsolutePath? = nil, - preActions: [ExecutionAction] = [], - postActions: [ExecutionAction] = [], - // swiftlint:disable:next force_try - executable: TargetReference? = TargetReference(projectPath: try! AbsolutePath(validating: "/Project"), name: "App"), - filePath: AbsolutePath? = nil, - arguments: Arguments? = Arguments.test(), - options: RunActionOptions = .init(), - diagnosticsOptions: SchemeDiagnosticsOptions = XcodeGraph.SchemeDiagnosticsOptions( - mainThreadCheckerEnabled: true, - performanceAntipatternCheckerEnabled: true - ), - expandVariableFromTarget: TargetReference? = nil, - launchStyle: LaunchStyle = .automatically - ) -> RunAction { - RunAction( - configurationName: configurationName, - attachDebugger: attachDebugger, - customLLDBInitFile: customLLDBInitFile, - preActions: preActions, - postActions: postActions, - executable: executable, - filePath: filePath, - arguments: arguments, - options: options, - diagnosticsOptions: diagnosticsOptions, - expandVariableFromTarget: expandVariableFromTarget, - launchStyle: launchStyle - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/Scheme+TestData.swift b/Sources/XcodeGraphTesting/Models/Scheme+TestData.swift deleted file mode 100644 index 4a9b51f..0000000 --- a/Sources/XcodeGraphTesting/Models/Scheme+TestData.swift +++ /dev/null @@ -1,27 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension Scheme { - public static func test( - name: String = "Test", - shared: Bool = false, - buildAction: BuildAction? = BuildAction.test(), - testAction: TestAction? = TestAction.test(), - runAction: RunAction? = RunAction.test(), - archiveAction: ArchiveAction? = ArchiveAction.test(), - profileAction: ProfileAction? = ProfileAction.test(), - analyzeAction: AnalyzeAction? = AnalyzeAction.test() - ) -> Scheme { - Scheme( - name: name, - shared: shared, - buildAction: buildAction, - testAction: testAction, - runAction: runAction, - archiveAction: archiveAction, - profileAction: profileAction, - analyzeAction: analyzeAction - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/Settings+TestData.swift b/Sources/XcodeGraphTesting/Models/Settings+TestData.swift deleted file mode 100644 index 950a79a..0000000 --- a/Sources/XcodeGraphTesting/Models/Settings+TestData.swift +++ /dev/null @@ -1,48 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension Configuration { - public static func test( - settings: SettingsDictionary = [:], - xcconfig: AbsolutePath? = try! AbsolutePath(validating: "/Config.xcconfig") // swiftlint:disable:this force_try - ) -> Configuration { - Configuration(settings: settings, xcconfig: xcconfig) - } -} - -extension Settings { - public static func test( - base: SettingsDictionary, - debug: Configuration, - release: Configuration - ) -> Settings { - Settings( - base: base, - configurations: [.debug: debug, .release: release] - ) - } - - public static func test( - base: SettingsDictionary = [:], - baseDebug: SettingsDictionary = [:], - configurations: [BuildConfiguration: Configuration?] = [:] - ) -> Settings { - Settings( - base: base, - baseDebug: baseDebug, - configurations: configurations - ) - } - - public static func test(defaultSettings: DefaultSettings) -> Settings { - Settings( - base: [:], - configurations: [ - .debug: Configuration(settings: [:]), - .release: Configuration(settings: [:]), - ], - defaultSettings: defaultSettings - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/Target+TestData.swift b/Sources/XcodeGraphTesting/Models/Target+TestData.swift deleted file mode 100644 index ca648e6..0000000 --- a/Sources/XcodeGraphTesting/Models/Target+TestData.swift +++ /dev/null @@ -1,184 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension Target { - /// Creates a Target with test data - /// Note: Referenced paths may not exist - public static func test( - name: String = "Target", - destinations: Destinations = [.iPhone, .iPad], - product: Product = .app, - productName: String? = nil, - bundleId: String? = nil, - deploymentTargets: DeploymentTargets = .iOS("13.1"), - infoPlist: InfoPlist? = nil, - entitlements: Entitlements? = nil, - settings: Settings? = Settings.test(), - sources: [SourceFile] = [], - resources: ResourceFileElements = .init([]), - copyFiles: [CopyFilesAction] = [], - coreDataModels: [CoreDataModel] = [], - headers: Headers? = nil, - scripts: [TargetScript] = [], - environmentVariables: [String: EnvironmentVariable] = [:], - filesGroup: ProjectGroup = .group(name: "Project"), - dependencies: [TargetDependency] = [], - rawScriptBuildPhases: [RawScriptBuildPhase] = [], - launchArguments: [LaunchArgument] = [], - playgrounds: [AbsolutePath] = [], - additionalFiles: [FileElement] = [], - prune: Bool = false, - mergedBinaryType: MergedBinaryType = .disabled, - mergeable: Bool = false - ) -> Target { - Target( - name: name, - destinations: destinations, - product: product, - productName: productName, - bundleId: bundleId ?? "io.tuist.\(name)", - deploymentTargets: deploymentTargets, - infoPlist: infoPlist, - entitlements: entitlements, - settings: settings, - sources: sources, - resources: resources, - copyFiles: copyFiles, - headers: headers, - coreDataModels: coreDataModels, - scripts: scripts, - environmentVariables: environmentVariables, - launchArguments: launchArguments, - filesGroup: filesGroup, - dependencies: dependencies, - rawScriptBuildPhases: rawScriptBuildPhases, - playgrounds: playgrounds, - additionalFiles: additionalFiles, - prune: prune, - mergedBinaryType: mergedBinaryType, - mergeable: mergeable - ) - } - - /// Creates a Target with test data - /// Note: Referenced paths may not exist - public static func test( - name: String = "Target", - platform: Platform, - product: Product = .app, - productName: String? = nil, - bundleId: String? = nil, - deploymentTarget: DeploymentTargets = .iOS("13.1"), - infoPlist: InfoPlist? = nil, - entitlements: Entitlements? = nil, - settings: Settings? = Settings.test(), - sources: [SourceFile] = [], - resources: ResourceFileElements = .init([]), - copyFiles: [CopyFilesAction] = [], - coreDataModels: [CoreDataModel] = [], - headers: Headers? = nil, - scripts: [TargetScript] = [], - environmentVariables: [String: EnvironmentVariable] = [:], - filesGroup: ProjectGroup = .group(name: "Project"), - dependencies: [TargetDependency] = [], - rawScriptBuildPhases: [RawScriptBuildPhase] = [], - launchArguments: [LaunchArgument] = [], - playgrounds: [AbsolutePath] = [], - additionalFiles: [FileElement] = [], - prune: Bool = false, - mergedBinaryType: MergedBinaryType = .disabled, - mergeable: Bool = false - ) -> Target { - Target( - name: name, - destinations: destinationsFrom(platform), - product: product, - productName: productName, - bundleId: bundleId ?? "io.tuist.\(name)", - deploymentTargets: deploymentTarget, - infoPlist: infoPlist, - entitlements: entitlements, - settings: settings, - sources: sources, - resources: resources, - copyFiles: copyFiles, - headers: headers, - coreDataModels: coreDataModels, - scripts: scripts, - environmentVariables: environmentVariables, - launchArguments: launchArguments, - filesGroup: filesGroup, - dependencies: dependencies, - rawScriptBuildPhases: rawScriptBuildPhases, - playgrounds: playgrounds, - additionalFiles: additionalFiles, - prune: prune, - mergedBinaryType: mergedBinaryType, - mergeable: mergeable - ) - } - - /// Creates a bare bones Target with as little data as possible - public static func empty( - name: String = "Target", - destinations: Destinations = [.iPhone, .iPad], - product: Product = .app, - productName: String? = nil, - bundleId: String? = nil, - deploymentTargets: DeploymentTargets = .init(), - infoPlist: InfoPlist? = nil, - entitlements: Entitlements? = nil, - settings: Settings? = nil, - sources: [SourceFile] = [], - resources: ResourceFileElements = .init([]), - copyFiles: [CopyFilesAction] = [], - coreDataModels: [CoreDataModel] = [], - headers: Headers? = nil, - scripts: [TargetScript] = [], - environmentVariables: [String: EnvironmentVariable] = [:], - filesGroup: ProjectGroup = .group(name: "Project"), - dependencies: [TargetDependency] = [], - rawScriptBuildPhases: [RawScriptBuildPhase] = [], - onDemandResourcesTags: OnDemandResourcesTags? = nil - ) -> Target { - Target( - name: name, - destinations: destinations, - product: product, - productName: productName, - bundleId: bundleId ?? "io.tuist.\(name)", - deploymentTargets: deploymentTargets, - infoPlist: infoPlist, - entitlements: entitlements, - settings: settings, - sources: sources, - resources: resources, - copyFiles: copyFiles, - headers: headers, - coreDataModels: coreDataModels, - scripts: scripts, - environmentVariables: environmentVariables, - filesGroup: filesGroup, - dependencies: dependencies, - rawScriptBuildPhases: rawScriptBuildPhases, - onDemandResourcesTags: onDemandResourcesTags - ) - } - - // Maps a platform to a set of Destinations. For migration purposes - private static func destinationsFrom(_ platform: Platform) -> Destinations { - switch platform { - case .iOS: - return .iOS - case .macOS: - return .macOS - case .tvOS: - return .tvOS - case .watchOS: - return .watchOS - case .visionOS: - return .visionOS - } - } -} diff --git a/Sources/XcodeGraphTesting/Models/TestAction+TestData.swift b/Sources/XcodeGraphTesting/Models/TestAction+TestData.swift deleted file mode 100644 index 4612126..0000000 --- a/Sources/XcodeGraphTesting/Models/TestAction+TestData.swift +++ /dev/null @@ -1,45 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension TestAction { - public static func test( - targets: [TestableTarget] = [TestableTarget(target: TargetReference( - // swiftlint:disable:next force_try - projectPath: try! AbsolutePath(validating: "/Project"), - name: "AppTests" - ))], - arguments: Arguments? = Arguments.test(), - configurationName: String = BuildConfiguration.debug.name, - attachDebugger: Bool = true, - coverage: Bool = false, - codeCoverageTargets: [TargetReference] = [], - expandVariableFromTarget: TargetReference? = nil, - preActions: [ExecutionAction] = [], - postActions: [ExecutionAction] = [], - diagnosticsOptions: SchemeDiagnosticsOptions = SchemeDiagnosticsOptions(mainThreadCheckerEnabled: true), - language: String? = nil, - region: String? = nil, - preferredScreenCaptureFormat: ScreenCaptureFormat? = nil, - testPlans: [TestPlan]? = nil, - skippedTests: [String]? = nil - ) -> TestAction { - TestAction( - targets: targets, - arguments: arguments, - configurationName: configurationName, - attachDebugger: attachDebugger, - coverage: coverage, - codeCoverageTargets: codeCoverageTargets, - expandVariableFromTarget: expandVariableFromTarget, - preActions: preActions, - postActions: postActions, - diagnosticsOptions: diagnosticsOptions, - language: language, - region: region, - preferredScreenCaptureFormat: preferredScreenCaptureFormat, - testPlans: testPlans, - skippedTests: skippedTests - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/TestableTarget+TestData.swift b/Sources/XcodeGraphTesting/Models/TestableTarget+TestData.swift deleted file mode 100644 index d8ca9a1..0000000 --- a/Sources/XcodeGraphTesting/Models/TestableTarget+TestData.swift +++ /dev/null @@ -1,21 +0,0 @@ -import Path -import XcodeGraph - -extension TestableTarget { - public static func test( - // swiftlint:disable:next force_try - target: TargetReference = TargetReference(projectPath: try! AbsolutePath(validating: "/Project"), name: "App"), - skipped: Bool = false, - parallelizable: Bool = false, - randomExecutionOrdering: Bool = false, - simulatedLocation: SimulatedLocation? = nil - ) -> TestableTarget { - TestableTarget( - target: target, - skipped: skipped, - parallelizable: parallelizable, - randomExecutionOrdering: randomExecutionOrdering, - simulatedLocation: simulatedLocation - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/Workspace+TestData.swift b/Sources/XcodeGraphTesting/Models/Workspace+TestData.swift deleted file mode 100644 index 6176285..0000000 --- a/Sources/XcodeGraphTesting/Models/Workspace+TestData.swift +++ /dev/null @@ -1,48 +0,0 @@ -import Foundation -import Path -@testable import XcodeGraph - -extension Workspace { - public static func test( - path: AbsolutePath = try! AbsolutePath(validating: "/"), // swiftlint:disable:this force_try - xcWorkspacePath: AbsolutePath = try! AbsolutePath(validating: "/"), // swiftlint:disable:this force_try - name: String = "test", - projects: [AbsolutePath] = [], - schemes: [Scheme] = [], - ideTemplateMacros: IDETemplateMacros? = nil, - additionalFiles: [FileElement] = [], - generationOptions: GenerationOptions = .test() - ) -> Workspace { - Workspace( - path: path, - xcWorkspacePath: xcWorkspacePath, - name: name, - projects: projects, - schemes: schemes, - generationOptions: generationOptions, - ideTemplateMacros: ideTemplateMacros, - additionalFiles: additionalFiles - ) - } -} - -extension Workspace.GenerationOptions { - public static func test( - enableAutomaticXcodeSchemes: Bool? = false, - autogeneratedWorkspaceSchemes: AutogeneratedWorkspaceSchemes = .enabled( - codeCoverageMode: .disabled, - testingOptions: [], - testLanguage: nil, - testRegion: nil, - testScreenCaptureFormat: nil - ), - lastXcodeUpgradeCheck: Version? = nil - ) -> Self { - .init( - enableAutomaticXcodeSchemes: enableAutomaticXcodeSchemes, - autogeneratedWorkspaceSchemes: autogeneratedWorkspaceSchemes, - lastXcodeUpgradeCheck: lastXcodeUpgradeCheck, - renderMarkdownReadme: false - ) - } -} diff --git a/Sources/XcodeGraphTesting/Models/XCFrameworkInfoPlist+TestData.swift b/Sources/XcodeGraphTesting/Models/XCFrameworkInfoPlist+TestData.swift deleted file mode 100644 index 832f09e..0000000 --- a/Sources/XcodeGraphTesting/Models/XCFrameworkInfoPlist+TestData.swift +++ /dev/null @@ -1,27 +0,0 @@ -import Foundation -import Path - -@testable import XcodeGraph - -extension XCFrameworkInfoPlist { - public static func test(libraries: [XCFrameworkInfoPlist.Library] = [.test()]) -> XCFrameworkInfoPlist { - XCFrameworkInfoPlist(libraries: libraries) - } -} - -extension XCFrameworkInfoPlist.Library { - public static func test( - identifier: String = "test", - // swiftlint:disable:next force_try - path: RelativePath = try! RelativePath(validating: "relative/to/library"), - mergeable: Bool = false, - architectures: [BinaryArchitecture] = [.i386] - ) -> XCFrameworkInfoPlist.Library { - XCFrameworkInfoPlist.Library( - identifier: identifier, - path: path, - mergeable: mergeable, - architectures: architectures - ) - } -} diff --git a/Tests/XcodeGraphTests/Models/ProjectTests.swift b/Tests/XcodeGraphTests/Models/ProjectTests.swift index a4864ad..163f831 100644 --- a/Tests/XcodeGraphTests/Models/ProjectTests.swift +++ b/Tests/XcodeGraphTests/Models/ProjectTests.swift @@ -1,6 +1,5 @@ import Foundation import Path -import XcodeGraphTesting import XCTest @testable import XcodeGraph diff --git a/Tests/XcodeGraphTests/Models/TargetTests.swift b/Tests/XcodeGraphTests/Models/TargetTests.swift index 4fdd0b3..4b9c9d0 100644 --- a/Tests/XcodeGraphTests/Models/TargetTests.swift +++ b/Tests/XcodeGraphTests/Models/TargetTests.swift @@ -2,7 +2,6 @@ import Foundation import Path import XCTest @testable import XcodeGraph -@testable import XcodeGraphTesting final class TargetTests: XCTestCase { func test_codable() { diff --git a/Tuist/ProjectDescriptionHelpers/Module.swift b/Tuist/ProjectDescriptionHelpers/Module.swift index 7b14d8b..c6c1c37 100644 --- a/Tuist/ProjectDescriptionHelpers/Module.swift +++ b/Tuist/ProjectDescriptionHelpers/Module.swift @@ -18,8 +18,7 @@ public enum Module: String, CaseIterable { targets.append(target( name: acceptanceTestsTargetName, product: .unitTests, - dependencies: acceptanceTestDependencies, - isTestingTarget: false + dependencies: acceptanceTestDependencies )) } @@ -34,8 +33,7 @@ public enum Module: String, CaseIterable { target( name: unitTestsTargetName, product: .unitTests, - dependencies: unitTestDependencies, - isTestingTarget: false + dependencies: unitTestDependencies ) ) } @@ -45,8 +43,7 @@ public enum Module: String, CaseIterable { target( name: integrationTestsTargetName, product: .unitTests, - dependencies: integrationTestsDependencies, - isTestingTarget: false + dependencies: integrationTestsDependencies ) ) } @@ -59,30 +56,15 @@ public enum Module: String, CaseIterable { } public var targets: [Target] { - var targets: [Target] = sourceTargets - - if let testingTargetName { - targets.append( - target( - name: testingTargetName, - product: product, - dependencies: testingDependencies, - isTestingTarget: true - ) - ) - } - - return targets + testTargets + return sourceTargets + testTargets } public var sourceTargets: [Target] { - let isStaticProduct = product == .staticLibrary || product == .staticFramework return [ target( name: targetName, product: product, - dependencies: dependencies, - isTestingTarget: false + dependencies: dependencies ), ] } @@ -94,13 +76,6 @@ public enum Module: String, CaseIterable { } } - public var testingTargetName: String? { - switch self { - default: - return "\(rawValue)Testing" - } - } - public var unitTestsTargetName: String? { switch self { default: @@ -159,9 +134,6 @@ public enum Module: String, CaseIterable { ] } dependencies = dependencies + [.target(name: targetName)] - if let testingTargetName { - dependencies.append(.target(name: testingTargetName)) - } return dependencies } @@ -180,17 +152,13 @@ public enum Module: String, CaseIterable { [] } dependencies.append(.target(name: targetName)) - if let testingTargetName { - dependencies.append(contentsOf: [.target(name: testingTargetName)]) - } return dependencies } fileprivate func target( name: String, product: Product, - dependencies: [TargetDependency], - isTestingTarget: Bool + dependencies: [TargetDependency] ) -> Target { let rootFolder: String switch product { @@ -201,10 +169,6 @@ public enum Module: String, CaseIterable { } var debugSettings: ProjectDescription.SettingsDictionary = ["SWIFT_ACTIVE_COMPILATION_CONDITIONS": "$(inherited) MOCKING"] var releaseSettings: ProjectDescription.SettingsDictionary = [:] - if isTestingTarget { - debugSettings["ENABLE_TESTING_SEARCH_PATHS"] = "YES" - releaseSettings["ENABLE_TESTING_SEARCH_PATHS"] = "YES" - } if let strictConcurrencySetting, product == .framework { debugSettings["SWIFT_STRICT_CONCURRENCY"] = .string(strictConcurrencySetting)