aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
diff options
context:
space:
mode:
authorGravatar Florian Weikert <fwe@google.com>2016-05-10 08:24:58 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-05-10 11:34:30 +0000
commitf0e03820b7db2f225c67904fc819fbbcdf011742 (patch)
treee9b0c35d6354cf4d6c68ad15262c91df0036190f /src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
parent0d24e2b69789ea54762ab034fdafc205cdcecea5 (diff)
Refactoring: Created BuildViewTestCase.checkLoadingPhaseError() for commonly used error checks.
This is partly motivated by unknown commit which moves the computation of default attribute values from analysis to loading phase. Consequently, checkError() can no longer be used for the affected tests. Instead, we will be using checkLoadingPhaseError(). -- MOS_MIGRATED_REVID=121922683
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
index 64b706e6ce..92f979753e 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
@@ -776,6 +776,27 @@ public abstract class BuildViewTestCase extends FoundationTestCase {
}
/**
+ * Checks whether loading the given target results in the specified error message.
+ *
+ * @param target the name of the target.
+ * @param expectedErrorMessage the expected error message.
+ */
+ protected void checkLoadingPhaseError(String target, String expectedErrorMessage) {
+ reporter.removeHandler(failFastHandler);
+ try {
+ // The error happens during the loading of the Skylark file so checkError doesn't work here
+ getTarget(target);
+ fail(
+ String.format(
+ "checkLoadingPhaseError(): expected an error with '%s' when loading target '%s'.",
+ expectedErrorMessage,
+ target));
+ } catch (Exception e) {
+ assertContainsEvent(expectedErrorMessage);
+ }
+ }
+
+ /**
* Check that configuration of the target named 'ruleName' in the
* specified BUILD file reports a warning message ending in
* 'expectedWarningMessage', and that no errors were reported.