Skip to content

Commit cadaa5a

Browse files
authored
Merge pull request #2945 from abertelrud/eng/packagegraphloader-diagnostics-should-be-tagged-with-package
Make sure that a package location is associated with the diagnostics emitted from PackageBuilder for a particular package
2 parents 395c4a9 + 1da2500 commit cadaa5a

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

Sources/PackageGraph/PackageGraphLoader.swift

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
4+
Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See http://swift.org/LICENSE.txt for license information
@@ -189,23 +189,22 @@ public struct PackageGraphLoader {
189189
// FIXME: Lift this out of the manifest.
190190
let packagePath = manifest.path.parentDirectory
191191

192-
// Create a package from the manifest and sources.
193-
let builder = PackageBuilder(
194-
manifest: manifest,
195-
productFilter: node.productFilter,
196-
path: packagePath,
197-
additionalFileRules: additionalFileRules,
198-
remoteArtifacts: remoteArtifacts,
199-
xcTestMinimumDeploymentTargets: xcTestMinimumDeploymentTargets,
200-
fileSystem: fileSystem,
201-
diagnostics: diagnostics,
202-
shouldCreateMultipleTestProducts: shouldCreateMultipleTestProducts,
203-
createREPLProduct: manifest.packageKind == .root ? createREPLProduct : false
204-
)
205-
206192
let packageLocation = PackageLocation.Local(name: manifest.name, packagePath: packagePath)
207193
diagnostics.with(location: packageLocation) { diagnostics in
208194
diagnostics.wrap {
195+
// Create a package from the manifest and sources.
196+
let builder = PackageBuilder(
197+
manifest: manifest,
198+
productFilter: node.productFilter,
199+
path: packagePath,
200+
additionalFileRules: additionalFileRules,
201+
remoteArtifacts: remoteArtifacts,
202+
xcTestMinimumDeploymentTargets: xcTestMinimumDeploymentTargets,
203+
fileSystem: fileSystem,
204+
diagnostics: diagnostics,
205+
shouldCreateMultipleTestProducts: shouldCreateMultipleTestProducts,
206+
createREPLProduct: manifest.packageKind == .root ? createREPLProduct : false
207+
)
209208
let package = try builder.construct()
210209
manifestToPackage[manifest] = package
211210

Tests/PackageGraphTests/PackageGraphTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ class PackageGraphTests: XCTestCase {
529529
)
530530

531531
DiagnosticsEngineTester(diagnostics) { result in
532-
result.check(diagnostic: "Source files for target Bar should be located under /Bar/Sources/Bar", behavior: .warning)
532+
result.check(diagnostic: "Source files for target Bar should be located under /Bar/Sources/Bar", behavior: .warning, location: "'Bar' /Bar")
533533
result.check(diagnostic: "target 'Bar' referenced in product 'Bar' is empty", behavior: .error, location: "'Bar' /Bar")
534534
}
535535
}

0 commit comments

Comments
 (0)