Skip to content

Commit

Permalink
Finish early instead of failing when testing a scheme with no tests (t…
Browse files Browse the repository at this point in the history
…uist#6398)

* Finish early instead of failing when running a scheme with no tests

* Remove scheme print

* Remove redundant test action check
  • Loading branch information
fortmarek authored Jun 12, 2024
1 parent afc5078 commit 2fd3481
Show file tree
Hide file tree
Showing 10 changed files with 582 additions and 508 deletions.
2 changes: 2 additions & 0 deletions Sources/TuistAutomation/Utilities/BuildGraphInspector.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Foundation
import Mockable
import Path
import TuistCore
import TuistSupport
import XcodeGraph

@Mockable
public protocol BuildGraphInspecting {
/// Returns the build arguments to be used with the given target.
/// - Parameter project: Project whose build arguments will be returned.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class TrackableCommand: TrackableParametersDelegate {
public func run() async throws {
let runId: String
let timer = clock.startTimer()
if var command = command as? HasTrackableParameters & ParsableCommand {
if let command = command as? HasTrackableParameters & ParsableCommand {
type(of: command).analyticsDelegate = self
runId = command.runId
self.command = command
Expand Down
2 changes: 2 additions & 0 deletions Sources/TuistKit/Generator/Generator.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import Mockable
import Path
import ProjectDescription
import TuistCore
Expand All @@ -9,6 +10,7 @@ import TuistPlugin
import TuistSupport
import XcodeGraph

@Mockable
public protocol Generating {
@discardableResult
func load(path: AbsolutePath) async throws -> Graph
Expand Down
4 changes: 3 additions & 1 deletion Sources/TuistKit/Services/TestService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ final class TestService { // swiftlint:disable:this type_body_length
}

if let schemeName {
guard let scheme = testableSchemes.first(where: { $0.name == schemeName })
guard let scheme = graphTraverser.schemes().first(where: { $0.name == schemeName })
else {
throw TestServiceError.schemeNotFound(
scheme: schemeName,
Expand All @@ -254,6 +254,8 @@ final class TestService { // swiftlint:disable:this type_body_length
}

switch (testPlanConfiguration?.testPlan, scheme.testAction?.targets.isEmpty, scheme.testAction?.testPlans?.isEmpty) {
case (_, false, _):
break
case (nil, true, _), (nil, nil, _):
logger.log(level: .info, "The scheme \(schemeName)'s test action has no tests to run, finishing early.")
return
Expand Down
72 changes: 0 additions & 72 deletions Tests/TuistKitTests/Generator/Mocks/MockGenerator.swift

This file was deleted.

Loading

0 comments on commit 2fd3481

Please sign in to comment.