Search in sources :

Example 1 with TestProvider

use of com.google.devtools.build.lib.rules.test.TestProvider in project bazel by bazelbuild.

the class RuleConfiguredTargetBuilder method initializeTestProvider.

private TestProvider initializeTestProvider(FilesToRunProvider filesToRunProvider) {
    int explicitShardCount = ruleContext.attributes().get("shard_count", Type.INTEGER);
    if (explicitShardCount < 0 && ruleContext.getRule().isAttributeValueExplicitlySpecified("shard_count")) {
        ruleContext.attributeError("shard_count", "Must not be negative.");
    }
    if (explicitShardCount > 50) {
        ruleContext.attributeError("shard_count", "Having more than 50 shards is indicative of poor test organization. " + "Please reduce the number of shards.");
    }
    TestActionBuilder testActionBuilder = new TestActionBuilder(ruleContext).setInstrumentedFiles(providersBuilder.getProvider(InstrumentedFilesProvider.class));
    TestEnvironmentProvider environmentProvider = (TestEnvironmentProvider) skylarkDeclaredProviders.build().get(TestEnvironmentProvider.SKYLARK_CONSTRUCTOR.getKey());
    if (environmentProvider != null) {
        testActionBuilder.addExtraEnv(environmentProvider.getEnvironment());
    }
    TestParams testParams = testActionBuilder.setFilesToRunProvider(filesToRunProvider).setExecutionRequirements((ExecutionInfoProvider) skylarkDeclaredProviders.build().get(ExecutionInfoProvider.SKYLARK_CONSTRUCTOR.getKey())).setShardCount(explicitShardCount).build();
    ImmutableList<String> testTags = ImmutableList.copyOf(ruleContext.getRule().getRuleTags());
    return new TestProvider(testParams, testTags);
}
Also used : TestProvider(com.google.devtools.build.lib.rules.test.TestProvider) TestActionBuilder(com.google.devtools.build.lib.rules.test.TestActionBuilder) InstrumentedFilesProvider(com.google.devtools.build.lib.rules.test.InstrumentedFilesProvider) TestParams(com.google.devtools.build.lib.rules.test.TestProvider.TestParams) TestEnvironmentProvider(com.google.devtools.build.lib.rules.test.TestEnvironmentProvider)

Example 2 with TestProvider

use of com.google.devtools.build.lib.rules.test.TestProvider in project bazel by bazelbuild.

the class TestResultAnalyzerTest method makeTestSummaryBuilder.

private TestSummary.Builder makeTestSummaryBuilder() {
    // a lot of mocks to mock out fetching the TestTimeout configuration needed by
    //  {@link TestResultAnalyzer#shouldEmitTestSizeWarningInSummary(...)
    TestParams mockParams = mock(TestParams.class);
    when(mockParams.getTimeout()).thenReturn(TestTimeout.LONG);
    TestProvider testProvider = new TestProvider(mockParams, ImmutableList.<String>of());
    ConfiguredTarget mockTarget = mock(ConfiguredTarget.class);
    when(mockTarget.getProvider(TestProvider.class)).thenReturn(testProvider);
    return TestSummary.newBuilder().setStatus(BlazeTestStatus.PASSED).setTarget(mockTarget);
}
Also used : TestProvider(com.google.devtools.build.lib.rules.test.TestProvider) TestParams(com.google.devtools.build.lib.rules.test.TestProvider.TestParams) ConfiguredTarget(com.google.devtools.build.lib.analysis.ConfiguredTarget)

Aggregations

TestProvider (com.google.devtools.build.lib.rules.test.TestProvider)2 TestParams (com.google.devtools.build.lib.rules.test.TestProvider.TestParams)2 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)1 InstrumentedFilesProvider (com.google.devtools.build.lib.rules.test.InstrumentedFilesProvider)1 TestActionBuilder (com.google.devtools.build.lib.rules.test.TestActionBuilder)1 TestEnvironmentProvider (com.google.devtools.build.lib.rules.test.TestEnvironmentProvider)1