Skip to content

Breaking - Delete XcodeGraphTesting #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ var targets: [Target] = [
"Path",
]
),
.target(
name: "XcodeGraphTesting",
dependencies: [
"XcodeGraph",
"AnyCodable",
],
linkerSettings: [.linkedFramework("XCTest")]
),
]

let package = Package(
Expand All @@ -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")),
Expand Down
18 changes: 0 additions & 18 deletions Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
175 changes: 175 additions & 0 deletions Sources/XcodeGraph/DependenciesGraph/DependenciesGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,178 @@ public struct DependenciesGraph: Equatable, Codable {
/// An empty `DependenciesGraph`.
public static let none: DependenciesGraph = .init(externalDependencies: [:], externalProjects: [:])
}

#if DEBUG
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of following the Mockable convention and hiding this behind the MOCKING compiler directive? That way, these symbols won't be available in non-test code that would only fail to build once you tried to build your tool in the release mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the MOCKING directive is bound to to the Debug configuration, so practically, the effect is the same as if I directly use the compiler directive associated to that configuration, DEBUG.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the MOCKING compiler directive should only be set in the test targets 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, it wouldn't work because the test data and mocks are generated when compiling the source target, not the test target.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, let's keep things as-is then 👍

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
24 changes: 24 additions & 0 deletions Sources/XcodeGraph/Graph/Graph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<GraphDependency>] = [:],
dependencyConditions: [GraphEdge: PlatformCondition] = [:]
) -> Graph {
Graph(
name: name,
path: path,
workspace: workspace,
projects: projects,
packages: packages,
dependencies: dependencies,
dependencyConditions: dependencyConditions
)
}
}
#endif
Loading
Loading