Test platform
This commit is contained in:
parent
37f729a351
commit
499e806a59
15
.jazzy.yaml
15
.jazzy.yaml
|
@ -16,4 +16,17 @@ custom_categories:
|
|||
- CommandRegistry
|
||||
- DumpCommand
|
||||
- UpdateCommand
|
||||
- CommandsContext
|
||||
- CommandsContext
|
||||
- name: Models
|
||||
children:
|
||||
- BuildConfiguration
|
||||
- BuildFiles
|
||||
- Target
|
||||
- Config
|
||||
- Workspace
|
||||
- Scheme
|
||||
- Project
|
||||
- Settings
|
||||
- Platform
|
||||
- BuildPhase
|
||||
- Product
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
B95895F9208A2B7C00F00ACF /* TargetGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = B95895F8208A2B7C00F00ACF /* TargetGenerator.swift */; };
|
||||
B95895FB208A2FFB00F00ACF /* WorkspaceGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = B95895FA208A2FFB00F00ACF /* WorkspaceGenerator.swift */; };
|
||||
B95895FD208A361D00F00ACF /* GraphLoadingErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B95895FC208A361D00F00ACF /* GraphLoadingErrorTests.swift */; };
|
||||
B9589600208A37B700F00ACF /* GraphJSONInitiatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = B95895FE208A37B300F00ACF /* GraphJSONInitiatable.swift */; };
|
||||
B9589602208A3CBA00F00ACF /* PlatformTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9589601208A3CBA00F00ACF /* PlatformTests.swift */; };
|
||||
B98313782065432A00D2D656 /* Sentry.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B98313772065432A00D2D656 /* Sentry.framework */; };
|
||||
B98313792065433500D2D656 /* Sentry.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = B98313772065432A00D2D656 /* Sentry.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
B983137F2065473800D2D656 /* Sentry.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B98313772065432A00D2D656 /* Sentry.framework */; };
|
||||
|
@ -234,6 +236,8 @@
|
|||
B95895F8208A2B7C00F00ACF /* TargetGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TargetGenerator.swift; sourceTree = "<group>"; };
|
||||
B95895FA208A2FFB00F00ACF /* WorkspaceGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkspaceGenerator.swift; sourceTree = "<group>"; };
|
||||
B95895FC208A361D00F00ACF /* GraphLoadingErrorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GraphLoadingErrorTests.swift; sourceTree = "<group>"; };
|
||||
B95895FE208A37B300F00ACF /* GraphJSONInitiatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GraphJSONInitiatable.swift; sourceTree = "<group>"; };
|
||||
B9589601208A3CBA00F00ACF /* PlatformTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlatformTests.swift; sourceTree = "<group>"; };
|
||||
B98313772065432A00D2D656 /* Sentry.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sentry.framework; sourceTree = "<group>"; };
|
||||
B9B6299D20864E2300EE9E07 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
|
||||
B9B629A220864E3A00EE9E07 /* Logger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
|
||||
|
@ -437,6 +441,7 @@
|
|||
B9287D0520808FFF002DEFEE /* BuildConfigurationTests.swift */,
|
||||
B92BF9F220755A2C00EE4EBD /* Config+TestData.swift */,
|
||||
B92BF9F420755A5B00EE4EBD /* Project+TestData.swift */,
|
||||
B9589601208A3CBA00F00ACF /* PlatformTests.swift */,
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
|
@ -608,6 +613,7 @@
|
|||
B9FB2DD22086538E00BC2FB3 /* GraphLoader.swift */,
|
||||
B9FB2DD32086538E00BC2FB3 /* GraphLoaderContext.swift */,
|
||||
B9FB2DD42086538E00BC2FB3 /* GraphLoaderCache.swift */,
|
||||
B95895FE208A37B300F00ACF /* GraphJSONInitiatable.swift */,
|
||||
);
|
||||
path = Loader;
|
||||
sourceTree = "<group>";
|
||||
|
@ -912,6 +918,7 @@
|
|||
B9B629AE20864E3A00EE9E07 /* App.swift in Sources */,
|
||||
B9FB2DE62086544900BC2FB3 /* Scheme.swift in Sources */,
|
||||
B95895FB208A2FFB00F00ACF /* WorkspaceGenerator.swift in Sources */,
|
||||
B9589600208A37B700F00ACF /* GraphJSONInitiatable.swift in Sources */,
|
||||
B9B6299F20864E2300EE9E07 /* Constants.swift in Sources */,
|
||||
B9FB2DCA2086527B00BC2FB3 /* BuildFiles.swift in Sources */,
|
||||
B9FB2DE1208653F500BC2FB3 /* GraphController.swift in Sources */,
|
||||
|
@ -941,6 +948,7 @@
|
|||
B9E2DC9F20872D450061DF86 /* MockLogger.swift in Sources */,
|
||||
B9E2DCBB2088E0B50061DF86 /* UpdateCommandTests.swift in Sources */,
|
||||
66F6DC2FC19AB1F6D332D8E8 /* ArgumentParserResult+TestData.swift in Sources */,
|
||||
B9589602208A3CBA00F00ACF /* PlatformTests.swift in Sources */,
|
||||
B95895FD208A361D00F00ACF /* GraphLoadingErrorTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import Basic
|
||||
import Foundation
|
||||
|
||||
/// The objects that conform this protocol are nodes that can be initialized with its JSON representation, the project path, and the graph loader context.
|
||||
protocol GraphJSONInitiatable: AnyObject {
|
||||
/// Default constructor.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - json: json representation of the object that is going to be initialized.
|
||||
/// - projectPath: path to the folder where the project's definition that contains this object is.
|
||||
/// - context: graph loader context.
|
||||
/// - Throws: an error when the object cannot be initialized
|
||||
init(json: JSON,
|
||||
projectPath: AbsolutePath,
|
||||
context: GraphLoaderContexting) throws
|
||||
}
|
|
@ -2,6 +2,10 @@ import Foundation
|
|||
|
||||
// MARK: - BuildConfiguration
|
||||
|
||||
/// Build configuration.
|
||||
///
|
||||
/// - debug: debug build configuration.
|
||||
/// - release: release build configuration.
|
||||
enum BuildConfiguration: String {
|
||||
case debug
|
||||
case release
|
||||
|
@ -10,6 +14,7 @@ enum BuildConfiguration: String {
|
|||
// MARK: - BuildConfiguration (Xcode)
|
||||
|
||||
extension BuildConfiguration: XcodeRepresentable {
|
||||
/// Returns the Xcode value for the build configuration.
|
||||
var xcodeValue: String {
|
||||
switch self {
|
||||
case .debug: return "Debug"
|
||||
|
|
|
@ -3,14 +3,25 @@ import Foundation
|
|||
|
||||
// MARK: - BuildFiles
|
||||
|
||||
class BuildFiles {
|
||||
class BuildFiles: GraphJSONInitiatable {
|
||||
/// Files.
|
||||
let files: Set<AbsolutePath>
|
||||
|
||||
/// Initializes the object with a set of build files.
|
||||
///
|
||||
/// - Parameter files: build files.
|
||||
init(files: Set<AbsolutePath> = Set()) {
|
||||
self.files = files
|
||||
}
|
||||
|
||||
init(json: JSON, projectPath: AbsolutePath, context: GraphLoaderContexting) throws {
|
||||
/// Initializes the build files from its JSON representation.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - json: build files JSON representation.
|
||||
/// - projectPath: path to the folder that contains the project's manifest.
|
||||
/// - context: graph loader context.
|
||||
/// - Throws: an error if build files cannot be parsed.
|
||||
required init(json: JSON, projectPath: AbsolutePath, context: GraphLoaderContexting) throws {
|
||||
if case let JSON.array(buildFilesArray) = json {
|
||||
var included: [AbsolutePath] = []
|
||||
var excluded: [AbsolutePath] = []
|
||||
|
@ -38,6 +49,12 @@ class BuildFiles {
|
|||
// MARK: - BuildFiles (Equatable)
|
||||
|
||||
extension BuildFiles: Equatable {
|
||||
/// Compares two build files.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - lhs: first build file to be compared.
|
||||
/// - rhs: second build file to be compared.
|
||||
/// - Returns: true if the two objects are the same.
|
||||
static func == (lhs: BuildFiles, rhs: BuildFiles) -> Bool {
|
||||
return lhs.files == rhs.files
|
||||
}
|
||||
|
|
|
@ -1,8 +1,46 @@
|
|||
import Foundation
|
||||
|
||||
/// Target platform.
|
||||
///
|
||||
/// - ios: iOS.
|
||||
/// - macos: macOS.
|
||||
/// - watchos: watchOS.
|
||||
/// - tvos: tvOS.
|
||||
enum Platform: String {
|
||||
case ios
|
||||
case macos
|
||||
case watchos
|
||||
case tvos
|
||||
}
|
||||
|
||||
// MARK: - Platform extension.
|
||||
|
||||
extension Platform {
|
||||
/// Returns Xcode SDKROOT value.
|
||||
var xcodeSdkRoot: String {
|
||||
switch self {
|
||||
case .macos:
|
||||
return "macosx"
|
||||
case .ios:
|
||||
return "iphoneos"
|
||||
case .tvos:
|
||||
return "appletvos"
|
||||
case .watchos:
|
||||
return "watchos"
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns Xcode SUPPORTED_PLATFORMS value.
|
||||
var xcodeSupportedPlatforms: String {
|
||||
switch self {
|
||||
case .tvos:
|
||||
return "appletvsimulator appletvos"
|
||||
case .watchos:
|
||||
return "watchsimulator watchos"
|
||||
case .ios:
|
||||
return "iphonesimulator iphoneos"
|
||||
case .macos:
|
||||
return "macosx"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,39 @@
|
|||
import Basic
|
||||
import Foundation
|
||||
|
||||
class Target {
|
||||
/// Project target.
|
||||
class Target: GraphJSONInitiatable {
|
||||
/// Target name.
|
||||
let name: String
|
||||
|
||||
/// Platform
|
||||
let platform: Platform
|
||||
|
||||
/// Target product type.
|
||||
let product: Product
|
||||
|
||||
/// Target info plist path.
|
||||
let infoPlist: AbsolutePath
|
||||
|
||||
/// Target entitlements path.
|
||||
let entitlements: AbsolutePath?
|
||||
|
||||
/// Target build settings.
|
||||
let settings: Settings?
|
||||
|
||||
/// Target build phases.
|
||||
let buildPhases: [BuildPhase]
|
||||
|
||||
/// List of dependencies (JSON representations)
|
||||
let dependencies: [JSON]
|
||||
|
||||
/// Initializes the target from its JSON representation.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - json: target JSON representation.
|
||||
/// - projectPath: path to the folder that contains the project's manifest.
|
||||
/// - context: graph loader context.
|
||||
/// - Throws: an error if build files cannot be parsed.
|
||||
required init(json: JSON, projectPath: AbsolutePath, context: GraphLoaderContexting) throws {
|
||||
name = try json.get("name")
|
||||
let platformString: String = try json.get("platform")
|
||||
|
@ -19,8 +42,14 @@ class Target {
|
|||
product = Product(rawValue: productString)!
|
||||
let infoPlistPath: String = try json.get("info_plist")
|
||||
infoPlist = projectPath.appending(component: infoPlistPath)
|
||||
if !context.fileHandler.exists(infoPlist) {
|
||||
throw GraphLoadingError.missingFile(infoPlist)
|
||||
}
|
||||
let entitlementsPath: String? = json.get("entitlements")
|
||||
entitlements = entitlementsPath.map({ projectPath.appending(component: $0) })
|
||||
if let entitlements = entitlements, !context.fileHandler.exists(entitlements) {
|
||||
throw GraphLoadingError.missingFile(entitlements)
|
||||
}
|
||||
let settingsJSON: JSON? = try json.get("settings")
|
||||
settings = try settingsJSON.map({ try Settings(json: $0, projectPath: projectPath, context: context) })
|
||||
let buildPhasesJSONs: [JSON] = try json.get("build_phases")
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
import Foundation
|
||||
@testable import xcbuddykit
|
||||
import XCTest
|
||||
|
||||
final class PlatformTests: XCTestCase {
|
||||
func test_xcodeSdkRoot_returns_the_right_value() {
|
||||
XCTAssertEqual(Platform.macos.xcodeSdkRoot, "macosx")
|
||||
XCTAssertEqual(Platform.ios.xcodeSdkRoot, "iphoneos")
|
||||
XCTAssertEqual(Platform.tvos.xcodeSdkRoot, "appletvos")
|
||||
XCTAssertEqual(Platform.watchos.xcodeSdkRoot, "watchos")
|
||||
}
|
||||
|
||||
func test_xcodeSupportedPLatforms_returns_the_right_value() {
|
||||
XCTAssertEqual(Platform.macos.xcodeSupportedPlatforms, "macosx")
|
||||
XCTAssertEqual(Platform.ios.xcodeSupportedPlatforms, "iphonesimulator iphoneos")
|
||||
XCTAssertEqual(Platform.tvos.xcodeSupportedPlatforms, "appletvsimulator appletvos")
|
||||
XCTAssertEqual(Platform.watchos.xcodeSupportedPlatforms, "watchsimulator watchos")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue