diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/AllTests.java | 6 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/testutil/BazelTestSuiteBuilder.java (renamed from src/test/java/com/google/devtools/build/lib/testutil/BlazeTestSuiteBuilder.java) | 4 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/testutil/TestSuiteBuilder.java | 16 |
3 files changed, 20 insertions, 6 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/AllTests.java b/src/test/java/com/google/devtools/build/lib/AllTests.java index 78d6cc8e56..d3c745d94b 100644 --- a/src/test/java/com/google/devtools/build/lib/AllTests.java +++ b/src/test/java/com/google/devtools/build/lib/AllTests.java @@ -13,7 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib; -import com.google.devtools.build.lib.testutil.BlazeTestSuiteBuilder; +import com.google.devtools.build.lib.testutil.BazelTestSuiteBuilder; import com.google.devtools.build.lib.testutil.CustomSuite; import org.junit.runner.RunWith; @@ -24,11 +24,11 @@ import java.util.Set; * General test suite with defaults suitable for most of our tests. */ @RunWith(CustomSuite.class) -public class AllTests extends BlazeTestSuiteBuilder { +public class AllTests extends BazelTestSuiteBuilder { public static Set<Class<?>> suite() { return new AllTests() .getBuilder() - .matchClasses(BlazeTestSuiteBuilder.TEST_SUPPORTS_CURRENT_OS) + .matchClasses(BazelTestSuiteBuilder.TEST_SUPPORTS_CURRENT_OS) .create(); } } diff --git a/src/test/java/com/google/devtools/build/lib/testutil/BlazeTestSuiteBuilder.java b/src/test/java/com/google/devtools/build/lib/testutil/BazelTestSuiteBuilder.java index 3c645f0200..df638ffc2c 100644 --- a/src/test/java/com/google/devtools/build/lib/testutil/BlazeTestSuiteBuilder.java +++ b/src/test/java/com/google/devtools/build/lib/testutil/BazelTestSuiteBuilder.java @@ -25,10 +25,10 @@ import java.util.Set; * A base class for constructing test suites by searching the classpath for * tests, possibly restricted to a predicate. */ -public class BlazeTestSuiteBuilder { +public class BazelTestSuiteBuilder { /** - * @return a TestSuiteBuilder configured for Blaze. + * @return a TestSuiteBuilder configured for Bazel. */ protected TestSuiteBuilder getBuilder() { return new TestSuiteBuilder() diff --git a/src/test/java/com/google/devtools/build/lib/testutil/TestSuiteBuilder.java b/src/test/java/com/google/devtools/build/lib/testutil/TestSuiteBuilder.java index f6588cbdb0..59a5d8583c 100644 --- a/src/test/java/com/google/devtools/build/lib/testutil/TestSuiteBuilder.java +++ b/src/test/java/com/google/devtools/build/lib/testutil/TestSuiteBuilder.java @@ -35,6 +35,20 @@ public final class TestSuiteBuilder { private Set<Class<?>> testClasses = Sets.newTreeSet(new TestClassNameComparator()); private Predicate<Class<?>> matchClassPredicate = Predicates.alwaysTrue(); + private final boolean tolerateEmptyTestSuites; + + public TestSuiteBuilder() { + tolerateEmptyTestSuites = false; + } + + /** + * @param tolerateEmptyTestSuites set this to true to add an empty test which passes to the suite. + * Its better for Test Suites to fail when they create an empty set of classes to test, so new + * suites should avoid setting this to true. + */ + public TestSuiteBuilder(boolean tolerateEmptyTestSuites) { + this.tolerateEmptyTestSuites = tolerateEmptyTestSuites; + } /** * Adds the tests found (directly) in class {@code c} to the set of tests @@ -84,7 +98,7 @@ public final class TestSuiteBuilder { for (Class<?> testClass : Iterables.filter(testClasses, matchClassPredicate)) { result.add(testClass); } - if (result.isEmpty()) { + if (tolerateEmptyTestSuites && result.isEmpty()) { // We have some cases where the resulting test suite is empty, which some of our test // infrastructure treats as an error. result.add(TautologyTest.class); |