aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar kush <kush@google.com>2017-03-30 18:48:10 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2017-03-31 17:10:22 +0200
commit20c41d03ea798ced1e9f873e040a52b28974bb18 (patch)
treef7d452464dd875ccd283b4e454577322fcec802e /src
parent9175f07151c3ea0870d29643e1b68c9b5f6479a4 (diff)
Change the tag experimental_testrunner into a couple of flags.
Note 1) Explanation of the flags: --explicit_java_test_deps: This is a flag independent of the others, and forces users to specify the JUnit deps. We should try to make this flag default to true in a future release, irrespective of the work around persistent java tests. --experimental_testrunner: Bazel-only flag affecting switching from the BazelTestRunner to the ExperimentalTestRunner which will run the tests in a separate classloader. --explicit_java_test_deps is desired for this to ensure once we split the classpaths of the TestRunner and the TestTarget, the TestTarget does not hit a ClassNotFoundException, due to missing JUnit deps. --test_strategy=experimental_worker: This is the existing flag, which in turn depends on --experimental_testrunner flag, since only the ExperimentalTestRunner is capable to running java tests persistently. Note 2) There was no clean way to check for the flags defined in JavaOptions within TestActionBuilder (as I was checking the "tag=experimental_testrunner" before), without making TeasActionBuilder's build rules depend on java rules (yikes!). Hence, I created a new method compatibleWithStrategy() within each fragment, so I could check if WorkerTestStrategy could be compatible with the user specified flags. Thanks to Greg for suggesting this approach! RELNOTES: None PiperOrigin-RevId: 151729869
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java23
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java36
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java28
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java18
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/test/TestActionBuilder.java11
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/test/TestRunnerAction.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/worker/WorkerTestStrategy.java9
-rwxr-xr-xsrc/test/shell/bazel/bazel_java_test.sh14
-rwxr-xr-xsrc/test/shell/bazel/persistent_test_runner_test.sh47
9 files changed, 139 insertions, 57 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
index 6efa2d1c6e..9561e2324d 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
@@ -16,6 +16,7 @@ package com.google.devtools.build.lib.analysis.config;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
+import com.google.common.base.Predicate;
import com.google.common.base.Splitter;
import com.google.common.base.Verify;
import com.google.common.collect.ArrayListMultimap;
@@ -193,6 +194,14 @@ public final class BuildConfiguration {
public ImmutableSet<String> configurationEnabledFeatures(RuleContext ruleContext) {
return ImmutableSet.of();
}
+
+ /**
+ * @return false if a Fragment understands that it won't be able to work with a given strategy,
+ * or true otherwise.
+ */
+ public boolean compatibleWithStrategy(String strategyName) {
+ return true;
+ }
}
private static final Label convertLabel(String input) throws OptionsParsingException {
@@ -1304,6 +1313,20 @@ public final class BuildConfiguration {
}
/**
+ * @return false if any of the fragments don't work well with the supplied strategy.
+ */
+ public boolean compatibleWithStrategy(final String strategyName) {
+ return Iterables.all(
+ fragments.values(),
+ new Predicate<Fragment>() {
+ @Override
+ public boolean apply(@Nullable Fragment fragment) {
+ return fragment.compatibleWithStrategy(strategyName);
+ }
+ });
+ }
+
+ /**
* Compute the shell environment, which, at configuration level, is a pair consisting of the
* statically set environment variables with their values and the set of environment variables to
* be inherited from the client environment.
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java
index d51a0efbdb..5f398560d5 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java
@@ -37,6 +37,7 @@ import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.bazel.rules.BazelConfiguration;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
+import com.google.devtools.build.lib.collect.nestedset.Order;
import com.google.devtools.build.lib.packages.BuildType;
import com.google.devtools.build.lib.packages.TargetUtils;
import com.google.devtools.build.lib.rules.java.DeployArchiveBuilder;
@@ -93,7 +94,6 @@ public class BazelJavaSemantics implements JavaSemantics {
"com.google.testing.junit.runner.BazelTestRunner";
private static final String EXPERIMENTAL_TEST_RUNNER_MAIN_CLASS =
"com.google.testing.junit.runner.ExperimentalTestRunner";
- private static final String EXPERIMENTAL_TESTRUNNER_TAG = "experimental_testrunner";
private BazelJavaSemantics() {
}
@@ -144,8 +144,7 @@ public class BazelJavaSemantics implements JavaSemantics {
}
} else {
if (ruleContext.attributes().get("use_testrunner", Type.BOOLEAN)) {
- List<String> tags = ruleContext.attributes().get("tags", Type.STRING_LIST);
- return tags.contains(EXPERIMENTAL_TESTRUNNER_TAG)
+ return ruleContext.getFragment(JavaConfiguration.class).useExperimentalTestRunner()
? EXPERIMENTAL_TEST_RUNNER_MAIN_CLASS
: BAZEL_TEST_RUNNER_MAIN_CLASS;
}
@@ -265,13 +264,26 @@ public class BazelJavaSemantics implements JavaSemantics {
arguments.add(Substitution.of("%needs_runfiles%",
ruleContext.getFragment(Jvm.class).getJavaExecutable().isAbsolute() ? "0" : "1"));
- NestedSet<Artifact> classpath = javaCommon.getRuntimeClasspath();
+ TransitiveInfoCollection testSupport = getTestSupport(ruleContext);
+ NestedSet<Artifact> testSupportJars =
+ testSupport == null
+ ? NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER)
+ : getRuntimeJarsForTargets(testSupport);
+
+ NestedSetBuilder<Artifact> classpathBuilder = NestedSetBuilder.naiveLinkOrder();
+ classpathBuilder.addTransitive(javaCommon.getRuntimeClasspath());
+ if (enforceExplicitJavaTestDeps(ruleContext)) {
+ // Currently, this is only needed when --explicit_java_test_deps=true, as otherwise the
+ // testSupport classpath is wrongly present in the javaCommon.getRuntimeClasspath().
+ classpathBuilder.addTransitive(testSupportJars);
+ }
+ NestedSet<Artifact> classpath = classpathBuilder.build();
+
if (isExperimentalJavaTest(ruleContext)) {
if (!isRunfilesEnabled) {
ruleContext.ruleError(
"ExperimentalTestRunner can't work on Windows since Windows doesn't support runfiles.");
}
- TransitiveInfoCollection testSupport = getTestSupport(ruleContext);
if (testSupport == null) {
// This may happen when the user sets use_testrunner=0 and manually chooses
// main_class=ExperimentalTestRunner.
@@ -280,7 +292,7 @@ public class BazelJavaSemantics implements JavaSemantics {
// Keep only the locations containing the classes to start the test runner itself within,
// classpath variable, and place all the paths required for the test run in a classpaths file,
// so that the classes for the test target may be loaded by a separate ClassLoader.
- classpath = getRuntimeJarsForTargets(testSupport);
+ classpath = testSupportJars;
}
arguments.add(new ComputedClasspathSubstitution(classpath, workspacePrefix, isRunfilesEnabled));
@@ -333,6 +345,10 @@ public class BazelJavaSemantics implements JavaSemantics {
}
}
+ private static boolean enforceExplicitJavaTestDeps(RuleContext ruleContext) {
+ return ruleContext.getFragment(JavaConfiguration.class).explicitJavaTestDeps();
+ }
+
/**
* Substitutes the placeholder with {@link File#pathSeparatorChar} separated relative classpaths.
*/
@@ -431,12 +447,12 @@ public class BazelJavaSemantics implements JavaSemantics {
RuleContext ruleContext,
ImmutableList.Builder<TransitiveInfoCollection> builder,
ClasspathType type) {
- if (type == ClasspathType.COMPILE_ONLY && isExperimentalJavaTest(ruleContext)) {
+ if (type == ClasspathType.COMPILE_ONLY && enforceExplicitJavaTestDeps(ruleContext)) {
// We add the test support below, but the test framework's deps are not relevant for
// COMPILE_ONLY, hence we return here.
- // TODO(bazel-team): Ideally we should be returning here irrespective of
- // useExperimentalTestRunner, since the testSupport deps don't belong to the COMPILE_ONLY
- // classpath, but since many targets may break, we are keeping it behind this condition.
+ // TODO(bazel-team): Ideally enforceExplicitJavaTestDeps should be the default behaviour,
+ // since the testSupport deps don't belong to the COMPILE_ONLY classpath, but since many
+ // targets may break, we are keeping it behind this flag.
return;
}
TransitiveInfoCollection testSupport = getTestSupport(ruleContext);
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java
index 748258cd56..03ae91dd8f 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java
@@ -146,6 +146,8 @@ public final class JavaConfiguration extends Fragment {
private final JavaOptimizationMode javaOptimizationMode;
private final ImmutableMap<String, Optional<Label>> bytecodeOptimizers;
private final Label javaToolchain;
+ private final boolean explicitJavaTestDeps;
+ private final boolean experimentalTestRunner;
// TODO(dmarting): remove once we have a proper solution for #2539
private final boolean legacyBazelJavaTest;
@@ -177,6 +179,8 @@ public final class JavaConfiguration extends Fragment {
this.legacyBazelJavaTest = javaOptions.legacyBazelJavaTest;
this.strictDepsJavaProtos = javaOptions.strictDepsJavaProtos;
this.enforceOneVersion = javaOptions.enforceOneVersion;
+ this.explicitJavaTestDeps = javaOptions.explicitJavaTestDeps;
+ this.experimentalTestRunner = javaOptions.experimentalTestRunner;
ImmutableList.Builder<Label> translationsBuilder = ImmutableList.builder();
for (String s : javaOptions.translationTargets) {
@@ -222,6 +226,14 @@ public final class JavaConfiguration extends Fragment {
globalMakeEnvBuilder.put("JAVA_TRANSLATIONS", buildTranslations() ? "1" : "0");
}
+ @Override
+ public boolean compatibleWithStrategy(String strategyName) {
+ if (strategyName.equals("experimental_worker")) {
+ return explicitJavaTestDeps() && useExperimentalTestRunner();
+ }
+ return true;
+ }
+
/**
* Returns true iff Java compilation should use ijars.
*/
@@ -356,6 +368,22 @@ public final class JavaConfiguration extends Fragment {
}
/**
+ * Returns true if we should be the ExperimentalTestRunner instead of the BazelTestRunner for
+ * bazel's java_test runs.
+ */
+ public boolean useExperimentalTestRunner() {
+ return experimentalTestRunner;
+ }
+
+ /**
+ * Make it mandatory for java_test targets to explicitly declare any JUnit or Hamcrest
+ * dependencies instead of accidentally obtaining them from the TestRunner's dependencies.
+ */
+ public boolean explicitJavaTestDeps() {
+ return explicitJavaTestDeps;
+ }
+
+ /**
* Returns true if Bazel should attempt to enforce one-version correctness on java_binary rules
* using the 'oneversion' tool in the java_toolchain. One-version correctness will inspect for
* multiple non-identical versions of java classes in the transitive dependencies for a
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
index b489c21022..1fa3fbf228 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
@@ -178,6 +178,24 @@ public class JavaOptions extends FragmentOptions {
)
public StrictDepsMode strictJavaDeps;
+ // TODO(bazel-team): This flag should ideally default to true (and eventually removed). We have
+ // been accidentally supplying JUnit and Hamcrest deps to java_test targets indirectly via the
+ // BazelTestRunner, and setting this flag to true fixes that behaviour.
+ @Option(name = "explicit_java_test_deps",
+ defaultValue = "false",
+ category = "semantics",
+ help = "Explicitly specify a dependency to JUnit or Hamcrest in a java_test instead of "
+ + " accidentally obtaining from the TestRunner's deps. Only works for bazel right now.")
+ public boolean explicitJavaTestDeps;
+
+ @Option(name = "experimental_testrunner",
+ defaultValue = "false",
+ category = "undocumented",
+ help = "Use the experimental test runner in bazel which runs the tests under a separate "
+ + "classloader. We must set the --explicit_java_test_deps flag with this to ensure "
+ + "the test targets have their dependencies right.")
+ public boolean experimentalTestRunner;
+
@Option(
name = "javabuilder_top",
defaultValue = "null",
diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/TestActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/test/TestActionBuilder.java
index 547d5bad79..da7963576e 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/test/TestActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/test/TestActionBuilder.java
@@ -250,14 +250,9 @@ public final class TestActionBuilder {
List<Artifact> results = Lists.newArrayListWithCapacity(runsPerTest * shardRuns);
ImmutableList.Builder<Artifact> coverageArtifacts = ImmutableList.builder();
- boolean useExperimentalTestRunner = false;
+ boolean useTestRunner = false;
if (ruleContext.attributes().has("use_testrunner", Type.BOOLEAN)) {
- useExperimentalTestRunner =
- ruleContext.attributes().get("use_testrunner", Type.BOOLEAN)
- && ruleContext
- .attributes()
- .get("tags", Type.STRING_LIST)
- .contains("experimental_testrunner");
+ useTestRunner = ruleContext.attributes().get("use_testrunner", Type.BOOLEAN);
}
for (int run = 0; run < runsPerTest; run++) {
@@ -299,7 +294,7 @@ public final class TestActionBuilder {
coverageArtifact, microCoverageArtifact,
testProperties, testEnv, executionSettings,
shard, run, config, ruleContext.getWorkspaceName(),
- useExperimentalTestRunner));
+ useTestRunner));
results.add(cacheStatus);
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/TestRunnerAction.java b/src/main/java/com/google/devtools/build/lib/rules/test/TestRunnerAction.java
index 644bd0ad63..01ea45134a 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/test/TestRunnerAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/test/TestRunnerAction.java
@@ -92,7 +92,7 @@ public class TestRunnerAction extends AbstractAction implements NotifyOnActionCa
private final int shardNum;
private final int runNumber;
private final String workspaceName;
- private final boolean useExperimentalTestRunner;
+ private final boolean useTestRunner;
// Mutable state related to test caching.
private Boolean unconditionalExecution; // lazily initialized: null indicates unknown
@@ -131,7 +131,7 @@ public class TestRunnerAction extends AbstractAction implements NotifyOnActionCa
int runNumber,
BuildConfiguration configuration,
String workspaceName,
- boolean useExperimentalTestRunner) {
+ boolean useTestRunner) {
super(owner, inputs,
// Note that this action only cares about the runfiles, not the mapping.
new RunfilesSupplierImpl(new PathFragment("runfiles"), executionSettings.getRunfiles()),
@@ -171,7 +171,7 @@ public class TestRunnerAction extends AbstractAction implements NotifyOnActionCa
this.undeclaredOutputsAnnotationsPath = undeclaredOutputsAnnotationsDir.getChild("ANNOTATIONS");
this.testInfrastructureFailure = baseDir.getChild("test.infrastructure_failure");
this.workspaceName = workspaceName;
- this.useExperimentalTestRunner = useExperimentalTestRunner;
+ this.useTestRunner = useTestRunner;
Map<String, String> mergedTestEnv = new HashMap<>(configuration.getTestEnv());
mergedTestEnv.putAll(extraTestEnv);
@@ -610,8 +610,8 @@ public class TestRunnerAction extends AbstractAction implements NotifyOnActionCa
return executionSettings;
}
- public boolean useExperimentalTestRunner() {
- return useExperimentalTestRunner;
+ public boolean useTestRunner() {
+ return useTestRunner;
}
public boolean isSharded() {
diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerTestStrategy.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerTestStrategy.java
index 82634a5068..7e665a1285 100644
--- a/src/main/java/com/google/devtools/build/lib/worker/WorkerTestStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerTestStrategy.java
@@ -83,7 +83,14 @@ public class WorkerTestStrategy extends StandaloneTestStrategy {
Spawn spawn,
ActionExecutionContext actionExecutionContext)
throws ExecException, InterruptedException, IOException {
- if (!action.useExperimentalTestRunner()) {
+ if (!action.getConfiguration().compatibleWithStrategy("experimental_worker")) {
+ throw new UserExecException(
+ "Build configuration not compatible with experimental_worker "
+ + "strategy. Make sure you set the explicit_java_test_deps and "
+ + "experimental_testrunner flags to true.");
+ }
+
+ if (!action.useTestRunner()) {
throw new UserExecException(
"Tests that do not use the experimental test runner are incompatible with the persistent"
+ " worker test strategy. Please use another test strategy");
diff --git a/src/test/shell/bazel/bazel_java_test.sh b/src/test/shell/bazel/bazel_java_test.sh
index 691511c041..8cbfc12ada 100755
--- a/src/test/shell/bazel/bazel_java_test.sh
+++ b/src/test/shell/bazel/bazel_java_test.sh
@@ -656,7 +656,7 @@ EOF
expect_log "Test message"
}
-function test_junit_deps_enforced_with_experimental_testrunner() {
+function test_explicit_java_test_deps_flag() {
setup_javatest_support
mkdir -p java/testrunners || fail "mkdir failed"
@@ -677,25 +677,25 @@ public class Tests {
}
EOF
- # With experimental_testrunner, we fail without explicitly specifying the JUnit deps.
+ # With explicit_java_test_deps, we fail without explicitly specifying the JUnit deps.
cat > java/testrunners/BUILD <<EOF
java_test(name = "Tests",
srcs = ['Tests.java'],
- tags = ['experimental_testrunner'],
)
EOF
- bazel test --test_output=streamed //java/testrunners:Tests &> "$TEST_log" && fail "Expected Failure" || true
+ bazel test --test_output=streamed --explicit_java_test_deps //java/testrunners:Tests \
+ &> "$TEST_log" && fail "Expected Failure" || true
expect_log "cannot find symbol"
- # We start passing again with experimental_testrunner once we explicitly specify the deps.
+ # We start passing again with explicit_java_test_deps once we explicitly specify the deps.
cat > java/testrunners/BUILD <<EOF
java_test(name = "Tests",
srcs = ['Tests.java'],
- tags = ['experimental_testrunner'],
deps = ['//third_party:junit4'],
)
EOF
- bazel test --test_output=streamed //java/testrunners:Tests &> "$TEST_log" || fail "Expected success"
+ bazel test --test_output=streamed --explicit_java_test_deps //java/testrunners:Tests \
+ &> "$TEST_log" || fail "Expected success"
expect_log "testTest was run"
}
diff --git a/src/test/shell/bazel/persistent_test_runner_test.sh b/src/test/shell/bazel/persistent_test_runner_test.sh
index bb01d497ef..76494f0b53 100755
--- a/src/test/shell/bazel/persistent_test_runner_test.sh
+++ b/src/test/shell/bazel/persistent_test_runner_test.sh
@@ -70,21 +70,20 @@ EOF
java_test(name = "TestsPass",
srcs = ['TestsPass.java'],
deps = ['//third_party:junit4'],
- tags = ["experimental_testrunner"],
)
java_test(name = "TestsFail",
srcs = ['TestsFail.java'],
deps = ['//third_party:junit4'],
- tags = ["experimental_testrunner"],
)
EOF
- bazel test --test_strategy=experimental_worker //java/testrunners:TestsPass \
- || fail "Test fails unexpectedly"
+ bazel test --explicit_java_test_deps --experimental_testrunner --test_strategy=experimental_worker \
+ //java/testrunners:TestsPass || fail "Test fails unexpectedly"
- bazel test --test_strategy=experimental_worker --test_output=all \
- //java/testrunners:TestsFail &> $TEST_log && fail "Test passes unexpectedly" || true
+ bazel test --explicit_java_test_deps --experimental_testrunner --test_strategy=experimental_worker \
+ --test_output=all //java/testrunners:TestsFail &> $TEST_log \
+ && fail "Test passes unexpectedly" || true
expect_log "Test is supposed to fail"
}
@@ -113,13 +112,12 @@ EOF
cat > java/testrunners/BUILD <<EOF
java_test(name = "Tests",
srcs = ['Tests.java'],
- tags = ["experimental_testrunner"],
deps = ['//third_party:junit4'],
)
EOF
- bazel test --test_strategy=experimental_worker //java/testrunners:Tests &> $TEST_log \
- || fail "Test fails unexpectedly"
+ bazel test --explicit_java_test_deps --experimental_testrunner --test_strategy=experimental_worker \
+ //java/testrunners:Tests &> $TEST_log || fail "Test fails unexpectedly"
# Now get the test to fail.
cat > java/testrunners/Tests.java <<EOF
@@ -140,8 +138,9 @@ public class Tests {
}
EOF
- bazel test --test_strategy=experimental_worker --test_output=all --no_cache_test_results \
- //java/testrunners:Tests &> $TEST_log && fail "Test passes unexpectedly" || true
+ bazel test --explicit_java_test_deps --experimental_testrunner --test_strategy=experimental_worker \
+ --test_output=all --no_cache_test_results //java/testrunners:Tests &> $TEST_log \
+ && fail "Test passes unexpectedly" || true
expect_log "Test is supposed to fail now"
}
@@ -171,13 +170,12 @@ EOF
cat > java/testrunners/BUILD <<EOF
java_test(name = "Tests",
srcs = ['Tests.java'],
- tags = ["experimental_testrunner"],
deps = ['//third_party:junit4'],
)
EOF
- bazel test --test_strategy=experimental_worker //java/testrunners:Tests &> $TEST_log \
- || fail "Test fails unexpectedly"
+ bazel test --explicit_java_test_deps --experimental_testrunner --test_strategy=experimental_worker \
+ //java/testrunners:Tests &> $TEST_log || fail "Test fails unexpectedly"
# Create a library to add a dep.
cat > java/testrunners/TrueVal.java <<EOF
@@ -217,7 +215,6 @@ java_library(name = "trueval",
java_test(name = "Tests",
srcs = ['Tests.java'],
- tags = ["experimental_testrunner"],
deps = [
':trueval',
'//third_party:junit4'
@@ -225,8 +222,9 @@ java_test(name = "Tests",
)
EOF
- bazel test --test_strategy=experimental_worker --test_output=all --no_cache_test_results \
- //java/testrunners:Tests &> $TEST_log && fail "Test passes unexpectedly" || true
+ bazel test --explicit_java_test_deps --experimental_testrunner --test_strategy=experimental_worker \
+ --test_output=all --no_cache_test_results //java/testrunners:Tests &> $TEST_log \
+ && fail "Test passes unexpectedly" || true
expect_log "Supposed to fail now."
}
@@ -246,18 +244,16 @@ EOF
java_test(name = "TestWithoutRunner",
srcs = ['TestWithoutRunner.java'],
use_testrunner = 0,
- tags = ["experimental_testrunner"],
main_class = "testrunners.TestWithoutRunner"
)
EOF
- bazel test --no_cache_test_results //java/testrunners:TestWithoutRunner >& $TEST_log \
- || fail "Normal test execution should pass."
+ bazel test --explicit_java_test_deps --experimental_testrunner --no_cache_test_results \
+ //java/testrunners:TestWithoutRunner >& $TEST_log || fail "Normal test execution should pass."
- bazel test --no_cache_test_results --test_strategy=experimental_worker >& $TEST_log \
- //java/testrunners:TestWithoutRunner \
- && fail "Test should have failed when running with an experimental runner." \
- || true
+ bazel test --explicit_java_test_deps --experimental_testrunner --no_cache_test_results \
+ --test_strategy=experimental_worker >& $TEST_log //java/testrunners:TestWithoutRunner \
+ && fail "Test should have failed when running with an experimental runner." || true
expect_log \
"Tests that do not use the experimental test runner are incompatible with the persistent worker"
@@ -299,8 +295,7 @@ EOF
&& fail "Test should have failed when running with an experimental runner." \
|| true
- expect_log \
- "Tests that do not use the experimental test runner are incompatible with the persistent worker"
+ expect_log "Build configuration not compatible with experimental_worker"
}
run_suite "Persistent Test Runner tests"