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, getTargetGraphOnlyDeps
equals, getBuildTarget, getDependencies, getProjectFilesystem, getSourcePathOutputs, getType, hasBuildSteps, hashCode, injectFields, isCacheable, toString, updateBuildRuleResolver
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compareTo, getBuildDeps, getBuildTarget, getFullyQualifiedName, getProjectFilesystem, hasBuildSteps, isCacheable, outputFileCanBeCopied, shouldRespectInputSizeLimitForRemoteExecution, toString, updateBuildRuleResolver
getDependencies, getSourcePathOutputs
getType
public 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 TestRule
protected 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 TestRule
public Callable<TestResults> interpretTestResults(ExecutionContext context, SourcePathResolverAdapter pathResolver, boolean isUsingTestSelectors)
interpretTestResults
in interface TestRule
public com.google.common.collect.ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext)
getBuildSteps
in interface BuildRule
@Nullable public SourcePath getSourcePathToOutput()
getSourcePathToOutput
in interface BuildRule
public com.google.common.collect.ImmutableSet<SourcePath> getTransitiveClasspaths()
getTransitiveClasspaths
in interface HasClasspathEntries
javac
's -classpath
flag
in order to build a jar associated with this rule.public com.google.common.collect.ImmutableSet<JavaLibrary> getTransitiveClasspathDeps()
getTransitiveClasspathDeps
in interface HasClasspathEntries
public com.google.common.collect.ImmutableSet<SourcePath> getImmediateClasspaths()
HasClasspathEntries
Used to generate the value of HasClasspathEntries.getTransitiveClasspaths()
.
getImmediateClasspaths
in interface HasClasspathEntries
public com.google.common.collect.ImmutableSet<SourcePath> getOutputClasspaths()
getOutputClasspaths
in interface HasClasspathEntries
javac
'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 ExportDependencies
public SortedSet<BuildRule> getExportedProvidedDeps()
getExportedProvidedDeps
in interface ExportDependencies
public boolean runTestSeparately()
runTestSeparately
in interface TestRule
public ForkMode forkMode()
public java.util.stream.Stream<BuildTarget> getRuntimeDeps(BuildRuleResolver buildRuleResolver)
getRuntimeDeps
in interface HasRuntimeDeps
public boolean supportsStreamingTests()
supportsStreamingTests
in interface TestRule
runTests()
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 ExternalTestRunnerRule
public void onPreTest(BuildContext buildContext) throws IOException
onPreTest
in interface ExternalTestRunnerRule
IOException
public com.google.common.collect.ImmutableList<Step> getPostBuildSteps(BuildContext buildContext)
getPostBuildSteps
in interface HasPostBuildSteps
Step
s 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)