public class JavaTest extends AbstractBuildRuleWithDeclaredAndExtraDeps implements TestRule, HasClasspathEntries, HasRuntimeDeps, HasPostBuildSteps, ExternalTestRunnerRule, ExportDependencies
| Modifier and Type | Class and Description |
|---|---|
static interface |
JavaTest.AdditionalClasspathEntriesProvider |
TestRule.TestReportingCallback| Modifier and Type | Field and Description |
|---|---|
static Flavor |
COMPILED_TESTS_LIBRARY_FLAVOR |
NOOP_REPORTING_CALLBACK| Constructor and Description |
|---|
JavaTest(BuildTarget buildTarget,
ProjectFilesystem projectFilesystem,
BuildRuleParams params,
JavaLibrary compiledTestsLibrary,
Optional<JavaTest.AdditionalClasspathEntriesProvider> additionalClasspathEntriesProvider,
Set<String> labels,
Set<String> contacts,
TestType testType,
String targetLevel,
Tool javaRuntimeLauncher,
List<Arg> vmArgs,
Map<String,String> nativeLibsEnvironment,
Optional<Long> testRuleTimeoutMs,
Optional<Long> testCaseTimeoutMs,
com.google.common.collect.ImmutableMap<String,Arg> env,
boolean runTestSeparately,
ForkMode forkMode,
Optional<Level> stdOutLogLevel,
Optional<Level> stdErrLogLevel,
Optional<SourcePath> unbundledResourcesRoot) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addPreTestSteps(BuildContext buildContext,
com.google.common.collect.ImmutableList.Builder<Step> stepsBuilder) |
ForkMode |
forkMode() |
protected com.google.common.collect.ImmutableSet<Path> |
getBootClasspathEntries() |
com.google.common.collect.ImmutableList<Step> |
getBuildSteps(BuildContext context,
BuildableContext buildableContext) |
JavaLibrary |
getCompiledTestsLibrary()
Returns the underlying java library containing the compiled tests.
|
com.google.common.collect.ImmutableSet<String> |
getContacts() |
SortedSet<BuildRule> |
getExportedDeps() |
SortedSet<BuildRule> |
getExportedProvidedDeps() |
ExternalTestSpec |
getExternalTestRunnerSpec(ExecutionContext executionContext,
TestRunningOptions options,
BuildContext buildContext) |
com.google.common.collect.ImmutableSet<SourcePath> |
getImmediateClasspaths()
Returns the classpaths for only this rule, not its deps.
|
com.google.common.collect.ImmutableSet<String> |
getLabels() |
com.google.common.collect.ImmutableSet<SourcePath> |
getOutputClasspaths() |
Path |
getPathToTestOutputDirectory() |
com.google.common.collect.ImmutableList<Step> |
getPostBuildSteps(BuildContext buildContext) |
protected com.google.common.collect.ImmutableSet<Path> |
getRuntimeClasspath(BuildContext buildContext) |
java.util.stream.Stream<BuildTarget> |
getRuntimeDeps(BuildRuleResolver buildRuleResolver) |
SourcePath |
getSourcePathToOutput() |
com.google.common.collect.ImmutableSet<JavaLibrary> |
getTransitiveClasspathDeps() |
com.google.common.collect.ImmutableSet<SourcePath> |
getTransitiveClasspaths() |
Callable<TestResults> |
interpretTestResults(ExecutionContext context,
SourcePathResolverAdapter pathResolver,
boolean isUsingTestSelectors) |
protected void |
onAmendVmArgs(com.google.common.collect.ImmutableList.Builder<String> vmArgsBuilder,
SourcePathResolverAdapter pathResolver,
Optional<TargetDevice> targetDevice)
Override this method if you need to amend vm args.
|
void |
onPreTest(BuildContext buildContext) |
com.google.common.collect.ImmutableList<Step> |
runTests(ExecutionContext executionContext,
TestRunningOptions options,
BuildContext buildContext,
TestRule.TestReportingCallback testReportingCallback)
Runs the tests specified by the "srcs" of this class.
|
boolean |
runTestSeparately() |
boolean |
supportsStreamingTests() |
deprecatedGetExtraDeps, getBuildDeps, getDeclaredDeps, getTargetGraphOnlyDepsequals, getBuildTarget, getDependencies, getProjectFilesystem, getSourcePathOutputs, getType, hasBuildSteps, hashCode, injectFields, isCacheable, toString, updateBuildRuleResolverclone, finalize, getClass, notify, notifyAll, wait, wait, waitcompareTo, getBuildDeps, getBuildTarget, getFullyQualifiedName, getProjectFilesystem, hasBuildSteps, isCacheable, outputFileCanBeCopied, shouldRespectInputSizeLimitForRemoteExecution, toString, updateBuildRuleResolvergetDependencies, getSourcePathOutputsgetTypepublic static final Flavor COMPILED_TESTS_LIBRARY_FLAVOR
public JavaTest(BuildTarget buildTarget, ProjectFilesystem projectFilesystem, BuildRuleParams params, JavaLibrary compiledTestsLibrary, Optional<JavaTest.AdditionalClasspathEntriesProvider> additionalClasspathEntriesProvider, Set<String> labels, Set<String> contacts, TestType testType, String targetLevel, Tool javaRuntimeLauncher, List<Arg> vmArgs, Map<String,String> nativeLibsEnvironment, Optional<Long> testRuleTimeoutMs, Optional<Long> testCaseTimeoutMs, com.google.common.collect.ImmutableMap<String,Arg> env, boolean runTestSeparately, ForkMode forkMode, Optional<Level> stdOutLogLevel, Optional<Level> stdErrLogLevel, Optional<SourcePath> unbundledResourcesRoot)
public com.google.common.collect.ImmutableSet<String> getLabels()
public com.google.common.collect.ImmutableSet<String> getContacts()
getContacts in interface TestRuleprotected com.google.common.collect.ImmutableSet<Path> getBootClasspathEntries()
public JavaLibrary getCompiledTestsLibrary()
protected void addPreTestSteps(BuildContext buildContext, com.google.common.collect.ImmutableList.Builder<Step> stepsBuilder)
public com.google.common.collect.ImmutableList<Step> runTests(ExecutionContext executionContext, TestRunningOptions options, BuildContext buildContext, TestRule.TestReportingCallback testReportingCallback)
java_test() rules, then they will be run separately.protected void onAmendVmArgs(com.google.common.collect.ImmutableList.Builder<String> vmArgsBuilder, SourcePathResolverAdapter pathResolver, Optional<TargetDevice> targetDevice)
public Path getPathToTestOutputDirectory()
getPathToTestOutputDirectory in interface TestRulepublic Callable<TestResults> interpretTestResults(ExecutionContext context, SourcePathResolverAdapter pathResolver, boolean isUsingTestSelectors)
interpretTestResults in interface TestRulepublic com.google.common.collect.ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext)
getBuildSteps in interface BuildRule@Nullable public SourcePath getSourcePathToOutput()
getSourcePathToOutput in interface BuildRulepublic com.google.common.collect.ImmutableSet<SourcePath> getTransitiveClasspaths()
getTransitiveClasspaths in interface HasClasspathEntriesjavac's -classpath flag
in order to build a jar associated with this rule.public com.google.common.collect.ImmutableSet<JavaLibrary> getTransitiveClasspathDeps()
getTransitiveClasspathDeps in interface HasClasspathEntriespublic com.google.common.collect.ImmutableSet<SourcePath> getImmediateClasspaths()
HasClasspathEntriesUsed to generate the value of HasClasspathEntries.getTransitiveClasspaths().
getImmediateClasspaths in interface HasClasspathEntriespublic com.google.common.collect.ImmutableSet<SourcePath> getOutputClasspaths()
getOutputClasspaths in interface HasClasspathEntriesjavac's
-classpath flag in order to compile rules that depend on this rule. This is a
superset of getImmediateClasspaths which also contains the classpath entries of any
exported deps.public SortedSet<BuildRule> getExportedDeps()
getExportedDeps in interface ExportDependenciespublic SortedSet<BuildRule> getExportedProvidedDeps()
getExportedProvidedDeps in interface ExportDependenciespublic boolean runTestSeparately()
runTestSeparately in interface TestRulepublic ForkMode forkMode()
public java.util.stream.Stream<BuildTarget> getRuntimeDeps(BuildRuleResolver buildRuleResolver)
getRuntimeDeps in interface HasRuntimeDepspublic boolean supportsStreamingTests()
supportsStreamingTests in interface TestRulerunTests() on this rule invokes the callbacks in testReportingCallback as the tests run, false otherwise.public ExternalTestSpec getExternalTestRunnerSpec(ExecutionContext executionContext, TestRunningOptions options, BuildContext buildContext)
getExternalTestRunnerSpec in interface ExternalTestRunnerRulepublic void onPreTest(BuildContext buildContext) throws IOException
onPreTest in interface ExternalTestRunnerRuleIOExceptionpublic com.google.common.collect.ImmutableList<Step> getPostBuildSteps(BuildContext buildContext)
getPostBuildSteps in interface HasPostBuildStepsSteps that run after the build regardless of whether this build rule
actually ran or hit in the cache.protected com.google.common.collect.ImmutableSet<Path> getRuntimeClasspath(BuildContext buildContext)