Search in sources :

Example 1 with GoogleTestLocation

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;
}
Also used : BlazeCommandRunConfigurationCommonState(com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState) TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) GoogleTestLocation(com.google.idea.blaze.clwb.run.test.GoogleTestLocation) ImmutableList(com.google.common.collect.ImmutableList) PsiElement(com.intellij.psi.PsiElement)

Example 2 with GoogleTestLocation

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());
}
Also used : BlazeCommandRunConfigurationCommonState(com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState) TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) GoogleTestLocation(com.google.idea.blaze.clwb.run.test.GoogleTestLocation) PsiElement(com.intellij.psi.PsiElement)

Aggregations

TargetInfo (com.google.idea.blaze.base.dependencies.TargetInfo)2 BlazeCommandRunConfigurationCommonState (com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState)2 GoogleTestLocation (com.google.idea.blaze.clwb.run.test.GoogleTestLocation)2 PsiElement (com.intellij.psi.PsiElement)2 ImmutableList (com.google.common.collect.ImmutableList)1