Skip to content

Commit 9c803dc

Browse files
John ButeJohn Bute
authored andcommitted
formatting
1 parent a7f9698 commit 9c803dc

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

Sources/PackageLoading/ManifestLoader+Validation.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ extension Basics.Diagnostic {
310310
}
311311

312312
static func invalidDependencyOnTestTarget(dependency: String, targetName: String) -> Self {
313-
return .error("Invalid dependency: '\(targetName)' cannot depend on test target dependency '\(dependency)'. Only test targets can depend on other test targets")
313+
.error(
314+
"Invalid dependency: '\(targetName)' cannot depend on test target dependency '\(dependency)'. Only test targets can depend on other test targets"
315+
)
314316
}
315317

316318
static func invalidBinaryLocation(targetName: String) -> Self {

Sources/PackageLoading/PackageBuilder.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -948,17 +948,20 @@ public final class PackageBuilder {
948948
))
949949
}
950950
}
951-
951+
952952
// Ensure non-test targets do not depend on test targets.
953953
// Only test targets are allowed to have dependencies on other test targets.
954954
if !potentialModule.isTest {
955955
for dependency in dependencies {
956956
if let depTarget = dependency.module, depTarget.type == .test {
957-
self.observabilityScope.emit(.invalidDependencyOnTestTarget(dependency: dependency.name, targetName: potentialModule.name))
957+
self.observabilityScope.emit(.invalidDependencyOnTestTarget(
958+
dependency: dependency.name,
959+
targetName: potentialModule.name
960+
))
958961
}
959962
}
960963
}
961-
964+
962965
// Create the build setting assignment table for this target.
963966
let buildSettings = try self.buildSettings(
964967
for: manifestTarget,

Tests/PackageGraphTests/ModulesGraphTests.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -409,17 +409,16 @@ final class ModulesGraphTests: XCTestCase {
409409
result.check(modules: "Bar", "Baz", "Foo")
410410
}
411411
}
412-
412+
413413
func testLibraryInvalidDependencyOnTestTarget() throws {
414-
415414
let fs = InMemoryFileSystem(
416415
emptyFiles:
417416
"/Foo/Sources/Foo/Foo.swift",
418417
"/Foo/Tests/FooTest/FooTest.swift"
419418
)
420-
419+
421420
let observability = ObservabilitySystem.makeForTesting()
422-
421+
423422
let _ = try loadModulesGraph(
424423
fileSystem: fs,
425424
manifests: [
@@ -432,30 +431,30 @@ final class ModulesGraphTests: XCTestCase {
432431
],
433432
targets: [
434433
TargetDescription(name: "Foo", dependencies: ["FooTest"]),
435-
TargetDescription(name: "FooTest", type: .test)
434+
TargetDescription(name: "FooTest", type: .test),
436435
]
437436
),
438437
],
439-
observabilityScope: observability.topScope)
440-
438+
observabilityScope: observability.topScope
439+
)
440+
441441
testDiagnostics(observability.diagnostics) { result in
442442
result.check(
443443
diagnostic: "Invalid dependency: 'Foo' cannot depend on test target dependency 'FooTest'. Only test targets can depend on other test targets",
444444
severity: .error
445445
)
446446
}
447447
}
448-
448+
449449
func testValidDependencyOnTestTarget() throws {
450-
451450
let fs = InMemoryFileSystem(
452451
emptyFiles:
453452
"/Foo/Tests/Foo/Foo.swift",
454453
"/Foo/Tests/FooTest/FooTest.swift"
455454
)
456-
455+
457456
let observability = ObservabilitySystem.makeForTesting()
458-
457+
459458
let _ = try loadModulesGraph(
460459
fileSystem: fs,
461460
manifests: [
@@ -467,15 +466,16 @@ final class ModulesGraphTests: XCTestCase {
467466
],
468467
targets: [
469468
TargetDescription(name: "Foo", dependencies: ["FooTest"], type: .test),
470-
TargetDescription(name: "FooTest", type: .test)
469+
TargetDescription(name: "FooTest", type: .test),
471470
]
472471
),
473472
],
474-
observabilityScope: observability.topScope)
475-
473+
observabilityScope: observability.topScope
474+
)
475+
476476
XCTAssertNoDiagnostics(observability.diagnostics)
477477
}
478-
478+
479479
// Make sure there is no error when we reference Test targets in a package and then
480480
// use it as a dependency to another package. SR-2353
481481
func testTestTargetDeclInExternalPackage() throws {

0 commit comments

Comments
 (0)