From f2146acdfac04caadfdc97eb8be8cbb620a4ce60 Mon Sep 17 00:00:00 2001 From: tomer doron Date: Wed, 10 Feb 2021 22:29:34 -0800 Subject: [PATCH] improve error message for deduced executableTarget (#3254) motivation: include the name of the target in the warning so its more actionable changes: add the target name in the "use executableTarget in 5.4" warning rdar://74045851 --- Sources/PackageLoading/PackageBuilder.swift | 2 +- Tests/PackageLoadingTests/PackageBuilderTests.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/PackageLoading/PackageBuilder.swift b/Sources/PackageLoading/PackageBuilder.swift index 8d66b587dd5..aeeb86eaaa9 100644 --- a/Sources/PackageLoading/PackageBuilder.swift +++ b/Sources/PackageLoading/PackageBuilder.swift @@ -752,7 +752,7 @@ public final class PackageBuilder { default: targetType = sources.computeTargetType() if targetType == .executable && manifest.toolsVersion >= .v5_4 && warnAboutImplicitExecutableTargets { - diagnostics.emit(warning: "in tools version \(ToolsVersion.v5_4) and later, use 'executableTarget()' to declare executable targets") + diagnostics.emit(warning: "'\(potentialModule.name)' was identified as an executable target given the presence of a 'main.swift' file. Starting with tools version \(ToolsVersion.v5_4) executable targets should be declared as 'executableTarget()'") } } diff --git a/Tests/PackageLoadingTests/PackageBuilderTests.swift b/Tests/PackageLoadingTests/PackageBuilderTests.swift index 61025587ba2..33806f22732 100644 --- a/Tests/PackageLoadingTests/PackageBuilderTests.swift +++ b/Tests/PackageLoadingTests/PackageBuilderTests.swift @@ -482,7 +482,7 @@ class PackageBuilderTests: XCTestCase { ] ) PackageBuilderTester(manifest, in: fs) { package, diagnostics in - diagnostics.check(diagnostic: "in tools version 5.4.0 and later, use 'executableTarget()' to declare executable targets", behavior: .warning) + diagnostics.check(diagnostic: "'exec2' was identified as an executable target given the presence of a 'main.swift' file. Starting with tools version 5.4.0 executable targets should be declared as 'executableTarget()'", behavior: .warning) package.checkModule("lib") { _ in } package.checkModule("exec2") { _ in } package.checkProduct("exec2") { product in