Skip to content

Commit

Permalink
Remove package name from error message
Browse files Browse the repository at this point in the history
This makes the affected error message more symmetric with other related errors that do not include the package name. The package name should be added somewhere higher up in the handling logic anyway.

Work toward #19922. (Drive-by fix)

PiperOrigin-RevId: 596041531
Change-Id: Ibfc3731f941de3a5020d751d46ac33f77e7d2019
  • Loading branch information
brandjon authored and copybara-github committed Jan 5, 2024
1 parent 9ae2cda commit 4ad1809
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1863,10 +1863,6 @@ private static NameConflictException nameConflict(Target added, Target existing)
String subject = String.format("%s '%s'", added.getTargetKind(), added.getName());
if (added instanceof OutputFile) {
subject += " in rule '" + ((OutputFile) added).getGeneratingRule().getName() + "'";
} else {
// TODO(#19922): This case is unnecessary. The package name context information should be
// added elsewhere.
subject += " in package '" + added.getLabel().getPackageName() + "'";
}

String object =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ public void testExportsFilesAndRuleNameConflict() throws Exception {
"exports_files(['foo'])",
"genrule(name = 'foo', srcs = ['bar'], outs = [], cmd = '/bin/true')");
assertThat(getTarget("//pkg2:foo")).isInstanceOf(InputFile.class);
assertContainsEvent("rule 'foo' in package 'pkg2' conflicts with existing source file");
assertContainsEvent("rule 'foo' conflicts with existing source file");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ public void testDuplicateRuleName() throws Exception {
"x = 1//0"); // not reached
Package pkg = loadPackage("duplicaterulename");
assertContainsEvent(
"cc_library rule 'spellcheck_proto' in package 'duplicaterulename' conflicts with"
+ " existing proto_library rule");
"cc_library rule 'spellcheck_proto' conflicts with" + " existing proto_library rule");
assertDoesNotContainEvent("division by zero");
assertThat(pkg.containsErrors()).isTrue();
}
Expand Down Expand Up @@ -325,8 +324,7 @@ public void testDuplicateRuleIsNotAddedToPackage() throws Exception {
"cc_library(name = 'dup_proto',",
" srcs = ['dup.pb.cc', 'dup.pb.h'])");
Package pkg = loadPackage("dup");
assertContainsEvent(
"cc_library rule 'dup_proto' in package 'dup' conflicts with existing proto_library rule");
assertContainsEvent("cc_library rule 'dup_proto' conflicts with existing proto_library rule");
assertThat(pkg.containsErrors()).isTrue();

Rule dupProto = pkg.getRule("dup_proto");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4592,8 +4592,8 @@ public void testAnalysisTestDuplicateName_samePackage() throws Exception {
getConfiguredTarget("//p:my_test_target");

ev.assertContainsError(
"Error in analysis_test: my_test_target_test rule 'my_test_target' in package 'p' conflicts"
+ " with existing my_test_target_test rule");
"Error in analysis_test: my_test_target_test rule 'my_test_target' conflicts with existing"
+ " my_test_target_test rule");
}

// Regression test for b/291752414 (Digest for Starlark-defined rules is wrong for analysis_test).
Expand Down

0 comments on commit 4ad1809

Please sign in to comment.