Skip to content

Commit

Permalink
parsing: Don't warn when re-discovering the same package.xml (RobotLo…
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnimmer-tri authored Sep 21, 2020
1 parent da323a9 commit 996d08b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions multibody/parsing/package_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,13 @@ void PackageMap::AddPackageIfNew(const string& package_name,
if (!Contains(package_name)) {
Add(package_name, path);
} else {
drake::log()->warn("Package \"{}\" was found more than once in the "
"search space.", package_name);
const string existing_path = GetPath(package_name);
if (path != existing_path) {
drake::log()->warn(
"PackageMap is ignoring newly-found path \"{}\" for package \"{}\""
" and will continue using the previously-known path at \"{}\".",
path, package_name, existing_path);
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions multibody/parsing/package_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ class PackageMap {
void CrawlForPackages(const std::string& path);

// This method is the same as Add() except it first checks to ensure that
// package_name is not already in this PackageMap. If it is not, this
// method prints a warning and returns.
// package_name is not already in this PackageMap. If it was already present
// with a different path, then this method prints a warning and returns
// without adding the new path.
void AddPackageIfNew(const std::string& package_name,
const std::string& path);

Expand Down
4 changes: 4 additions & 0 deletions multibody/parsing/test/package_map_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ GTEST_TEST(PackageMapTest, TestPopulateUpstreamToDrake) {
};

VerifyMatch(package_map, expected_packages);

// Call it again to exercise the "don't add things twice" code.
package_map.PopulateUpstreamToDrake(sdf_file_name);
VerifyMatch(package_map, expected_packages);
}

// Tests that PackageMap can be populated from an env var.
Expand Down

0 comments on commit 996d08b

Please sign in to comment.