use of com.google.idea.blaze.clwb.run.test.GoogleTestLocation in project intellij by bazelbuild.
the class BlazeCidrTestConfigurationProducer method doSetupConfigFromContext.
@Override
protected boolean doSetupConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
PsiElement element = selectedPsiElement(context);
if (element == null) {
return false;
}
GoogleTestLocation test = GoogleTestLocation.findGoogleTest(element);
if (test == null) {
return false;
}
TargetInfo target = getTestTarget(test.getPsiElement());
if (target == null) {
return false;
}
sourceElement.set(test.getPsiElement());
configuration.setTargetInfo(target);
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
handlerState.getCommandState().setCommand(BlazeCommandName.TEST);
ImmutableList.Builder<String> flags = ImmutableList.builder();
String testFilter = test.getTestFilterFlag();
if (testFilter != null) {
flags.add(testFilter);
}
flags.addAll(handlerState.getBlazeFlagsState().getRawFlags());
handlerState.getBlazeFlagsState().setRawFlags(flags.build());
configuration.setName(String.format("%s test: %s", Blaze.buildSystemName(configuration.getProject()), getTestName(target.label, test.gtest)));
return true;
}
use of com.google.idea.blaze.clwb.run.test.GoogleTestLocation in project intellij by bazelbuild.
the class BlazeCidrTestConfigurationProducer method doIsConfigFromContext.
@Override
protected boolean doIsConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context) {
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
if (!Objects.equals(handlerState.getCommandState().getCommand(), BlazeCommandName.TEST)) {
return false;
}
PsiElement element = selectedPsiElement(context);
if (element == null) {
return false;
}
GoogleTestLocation test = GoogleTestLocation.findGoogleTest(element);
if (test == null) {
return false;
}
TargetInfo target = getTestTarget(test.getPsiElement());
if (target == null) {
return false;
}
return target.label.equals(configuration.getTarget()) && Objects.equals(handlerState.getTestFilterFlag(), test.getTestFilterFlag());
}
Aggregations