use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration in project intellij by bazelbuild.
the class BlazeCoverageProgramRunner method doExecute.
@Nullable
@Override
protected RunContentDescriptor doExecute(RunProfileState profile, ExecutionEnvironment env) throws ExecutionException {
WorkspaceRoot root = WorkspaceRoot.fromProjectSafe(env.getProject());
if (root == null) {
return null;
}
RunContentDescriptor result = super.doExecute(profile, env);
if (result == null) {
return null;
}
// remove any old copy of the coverage data
// retrieve coverage data and copy locally
BlazeCommandRunConfiguration blazeConfig = (BlazeCommandRunConfiguration) env.getRunProfile();
BlazeCoverageEnabledConfiguration config = (BlazeCoverageEnabledConfiguration) CoverageEnabledConfiguration.getOrCreate(blazeConfig);
String coverageFilePath = config.getCoverageFilePath();
File blazeOutputFile = CoverageUtils.getOutputFile(root);
ProcessHandler handler = result.getProcessHandler();
if (handler != null) {
ProcessHandler wrappedHandler = new ProcessHandlerWrapper(handler, exitCode -> copyCoverageOutput(blazeOutputFile, coverageFilePath, exitCode));
CoverageHelper.attachToProcess(blazeConfig, wrappedHandler, env.getRunnerSettings());
}
return result;
}
use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration in project intellij by bazelbuild.
the class BlazeJavaAbstractTestCaseConfigurationProducer method chooseSubclass.
@VisibleForTesting
static void chooseSubclass(ConfigurationFromContext configuration, ConfigurationContext context, Runnable startRunnable) {
RunConfiguration config = configuration.getConfiguration();
if (!(config instanceof BlazeCommandRunConfiguration)) {
return;
}
AbstractTestLocation location = locationFromConfiguration(configuration);
if (location == null) {
return;
}
SubclassTestChooser.chooseSubclass(context, location.abstractClass, (psiClass) -> {
if (psiClass != null) {
setupContext((BlazeCommandRunConfiguration) config, psiClass, location.method);
}
startRunnable.run();
});
}
use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration in project intellij by bazelbuild.
the class BlazeJavaDebuggerRunner method canRun.
@Override
public boolean canRun(final String executorId, final RunProfile profile) {
if (!executorId.equals(DefaultDebugExecutor.EXECUTOR_ID) || !(profile instanceof BlazeCommandRunConfiguration)) {
return false;
}
BlazeCommandRunConfiguration configuration = (BlazeCommandRunConfiguration) profile;
Kind kind = configuration.getTargetKind();
if (kind == null || !BlazeJavaRunConfigurationHandlerProvider.supportsKind(kind)) {
return false;
}
return canDebug(configuration.getHandler().getCommandName());
}
use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration in project intellij by bazelbuild.
the class TestRecorderBlazeCommandRunConfigurationTest method testLaunchActivityClass.
@Test
public void testLaunchActivityClass() {
BlazeCommandRunConfiguration blazeConfiguration = BlazeCommandRunConfigurationType.getInstance().getFactory().createTemplateConfiguration(getProject());
blazeConfiguration.setTarget(Label.create("//label:android_binary_rule"));
BlazeAndroidBinaryRunConfigurationState configurationState = ((BlazeAndroidBinaryRunConfigurationHandler) blazeConfiguration.getHandler()).getState();
configurationState.setMode(BlazeAndroidBinaryRunConfigurationState.LAUNCH_SPECIFIC_ACTIVITY);
configurationState.setActivityClass("MyAppMainActivity");
TestRecorderRunConfigurationProxy proxy = TestRecorderRunConfigurationProxy.getInstance(blazeConfiguration);
assertThat(proxy).isNotNull();
assertThat(proxy.getLaunchActivityClass()).isEqualTo("MyAppMainActivity");
}
use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration in project intellij by bazelbuild.
the class BlazePyTestConfigurationProducerTest method testProducedFromTestCase.
@Test
public void testProducedFromTestCase() {
PsiFile pyFile = createAndIndexFile(new WorkspacePath("py/test/unittest.py"), "class UnitTest(googletest.TestCase):", " def testSomething():", " return");
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setKind("py_test").setLabel("//py/test:unittests").addSource(sourceRoot("py/test/unittest.py")).build()).build());
registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
PyFunction function = PsiUtils.findFirstChildOfClassRecursive(pyFile, PyFunction.class);
assertThat(function).isNotNull();
ConfigurationContext context = createContextFromPsi(function);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazePyTestConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//py/test:unittests"));
assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=UnitTest.testSomething");
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
Aggregations