Skip to content

Make sure that a package location is associated with the diagnostics emitted from PackageBuilder for a particular package #2945

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
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
29 changes: 14 additions & 15 deletions Sources/PackageGraph/PackageGraphLoader.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This source file is part of the Swift.org open source project

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

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

// Create a package from the manifest and sources.
let builder = PackageBuilder(
manifest: manifest,
productFilter: node.productFilter,
path: packagePath,
additionalFileRules: additionalFileRules,
remoteArtifacts: remoteArtifacts,
xcTestMinimumDeploymentTargets: xcTestMinimumDeploymentTargets,
fileSystem: fileSystem,
diagnostics: diagnostics,
shouldCreateMultipleTestProducts: shouldCreateMultipleTestProducts,
createREPLProduct: manifest.packageKind == .root ? createREPLProduct : false
)

let packageLocation = PackageLocation.Local(name: manifest.name, packagePath: packagePath)
diagnostics.with(location: packageLocation) { diagnostics in
diagnostics.wrap {
// Create a package from the manifest and sources.
let builder = PackageBuilder(
manifest: manifest,
productFilter: node.productFilter,
path: packagePath,
additionalFileRules: additionalFileRules,
remoteArtifacts: remoteArtifacts,
xcTestMinimumDeploymentTargets: xcTestMinimumDeploymentTargets,
fileSystem: fileSystem,
diagnostics: diagnostics,
shouldCreateMultipleTestProducts: shouldCreateMultipleTestProducts,
createREPLProduct: manifest.packageKind == .root ? createREPLProduct : false
)
let package = try builder.construct()
manifestToPackage[manifest] = package

Expand Down
2 changes: 1 addition & 1 deletion Tests/PackageGraphTests/PackageGraphTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ class PackageGraphTests: XCTestCase {
)

DiagnosticsEngineTester(diagnostics) { result in
result.check(diagnostic: "Source files for target Bar should be located under /Bar/Sources/Bar", behavior: .warning)
result.check(diagnostic: "Source files for target Bar should be located under /Bar/Sources/Bar", behavior: .warning, location: "'Bar' /Bar")
result.check(diagnostic: "target 'Bar' referenced in product 'Bar' is empty", behavior: .error, location: "'Bar' /Bar")
}
}
Expand Down