aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/analysis
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-03-17 15:56:41 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-03-18 12:45:07 +0000
commit1d4c9d2418a2f1ee01484008efa87a1bab53372c (patch)
tree0c94d2c35f7deb2b6f4f5bdddf6ce92c9546c336 /src/test/java/com/google/devtools/build/lib/analysis
parent09a1b51d004225649aa7f6d4ac0061acd0cb7ef9 (diff)
Set maximum limit on the number of actifacts shown in the output caused by conflicting actions.
Currently Blaze outputs all mandatory inputs diffs between two actions if they result in conflictions. It is useful debugging information however could be quite large. This change sets the maximum number of records in the diff list to 5. -- MOS_MIGRATED_REVID=117449664
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/analysis')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java
index 84049bdc67..857a01f23e 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.fail;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.analysis.util.AnalysisCachingTestBase;
+import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider;
import com.google.devtools.build.lib.testutil.Suite;
import com.google.devtools.build.lib.testutil.TestSpec;
@@ -33,6 +34,8 @@ import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Analysis caching tests.
@@ -205,6 +208,58 @@ public class AnalysisCachingTest extends AnalysisCachingTestBase {
"//conflict:x", "//conflict:_objs/x/conflict/foo.pic.o");
assertNoEvents();
}
+
+ /**
+ * For two conflicting actions whose primary inputs are different, no list diff detail should be
+ * part of the output.
+ */
+ @Test
+ public void testConflictingArtifactsErrorWithNoListDetail() throws Exception {
+ scratch.file(
+ "conflict/BUILD",
+ "cc_library(name='x', srcs=['foo.cc'])",
+ "cc_binary(name='_objs/x/conflict/foo.pic.o', srcs=['bar.cc'])");
+ reporter.removeHandler(failFastHandler); // expect errors
+ update(
+ defaultFlags().with(Flag.KEEP_GOING),
+ "//conflict:x",
+ "//conflict:_objs/x/conflict/foo.pic.o");
+
+ assertContainsEvent("file 'conflict/_objs/x/conflict/foo.pic.o' " + CONFLICT_MSG);
+ assertDoesNotContainEvent("MandatoryInputs");
+ assertDoesNotContainEvent("Outputs");
+ }
+
+ /**
+ * For two conflicted actions whose primary inputs are the same, list diff (max 5) should be part
+ * of the output.
+ */
+ @Test
+ public void testConflictingArtifactsWithListDetail() throws Exception {
+ scratch.file(
+ "conflict/BUILD",
+ "cc_library(name='x', srcs=['foo1.cc', 'foo2.cc', 'foo3.cc', 'foo4.cc', 'foo5.cc'"
+ + ", 'foo6.cc'])",
+ "genrule(name = 'foo', outs=['_objs/x/conflict/foo1.pic.o'], srcs=['foo1.cc', 'foo2.cc', "
+ + "'foo3.cc', 'foo4.cc', 'foo5.cc', 'foo6.cc'], cmd='', output_to_bindir=1)");
+ reporter.removeHandler(failFastHandler); // expect errors
+ update(defaultFlags().with(Flag.KEEP_GOING), "//conflict:x", "//conflict:foo");
+
+ Event event =
+ assertContainsEvent("file 'conflict/_objs/x/conflict/foo1.pic.o' " + CONFLICT_MSG);
+ assertContainsEvent("MandatoryInputs");
+ assertContainsEvent("Outputs");
+
+ // Validate that maximum of 5 artifacts in MandatoryInputs are part of output.
+ Pattern pattern = Pattern.compile("\tconflict\\/foo[1-6].cc");
+ Matcher matcher = pattern.matcher(event.getMessage());
+ int matchCount = 0;
+ while (matcher.find()) {
+ matchCount++;
+ }
+
+ assertEquals(5, matchCount);
+ }
/**
* The current action conflict detection code will only mark one of the targets as having an