Search in sources :

Example 51 with ConfigurationFromContext

use of com.intellij.execution.actions.ConfigurationFromContext in project intellij by bazelbuild.

the class JavascriptTestContextProviderTest method testMultipleBrowsers.

@Test
public void testMultipleBrowsers() throws Throwable {
    PsiFile jsTestFile = configure(ImmutableList.of("chrome-linux", "firefox-linux"), "function testFoo() {}");
    ConfigurationContext context = createContextFromPsi(jsTestFile);
    ConfigurationFromContext configurationFromContext = getConfigurationFromContext(context);
    BlazeCommandRunConfiguration configuration = getBlazeRunConfiguration(configurationFromContext);
    assertThat(configuration.getPendingContext()).isNotNull();
    assertThat(configuration.getPendingContext()).isInstanceOf(PendingWebTestContext.class);
    PendingWebTestContext testContext = (PendingWebTestContext) configuration.getPendingContext();
    testContext.updateContextAndRerun(configuration, TargetInfo.builder(Label.create("//foo/bar:foo_test_firefox-linux"), "js_web_test").build(), () -> {
    });
    assertThat(configuration.getTargetKind()).isEqualTo(Kind.fromRuleName("js_web_test"));
    assertThat(configuration.getTargets()).containsExactly(TargetExpression.fromStringSafe("//foo/bar:foo_test_firefox-linux"));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) PendingWebTestContext(com.google.idea.blaze.base.run.producers.PendingWebTestContext) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) PsiFile(com.intellij.psi.PsiFile) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) Test(org.junit.Test)

Example 52 with ConfigurationFromContext

use of com.intellij.execution.actions.ConfigurationFromContext in project intellij by bazelbuild.

the class OldJavascriptTestContextProviderTest method testClosureTestSuite.

@Test
public void testClosureTestSuite() throws Throwable {
    PsiFile jsTestFile = configure(ImmutableList.of("chrome-linux"), "goog.module('foo.bar.fooTest');", "goog.setTestOnly();", "const testSuite = goog.require('goog.testing.testSuite');", "testSuite({", "  testFoo() {},", "});");
    ConfigurationContext context = createContextFromPsi(jsTestFile);
    ConfigurationFromContext configurationFromContext = getConfigurationFromContext(context);
    BlazeCommandRunConfiguration configuration = getBlazeRunConfiguration(configurationFromContext);
    assertThat(configuration.getTargetKind()).isEqualTo(RuleTypes.WEB_TEST.getKind());
    assertThat(configuration.getTargets()).containsExactly(TargetExpression.fromStringSafe("//foo/bar:foo_test_chrome-linux"));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) PsiFile(com.intellij.psi.PsiFile) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) Test(org.junit.Test)

Example 53 with ConfigurationFromContext

use of com.intellij.execution.actions.ConfigurationFromContext in project intellij by bazelbuild.

the class OldJavascriptTestContextProviderTest method testMultipleBrowsers.

@Test
public void testMultipleBrowsers() throws Throwable {
    PsiFile jsTestFile = configure(ImmutableList.of("chrome-linux", "firefox-linux"), "function testFoo() {}");
    ConfigurationContext context = createContextFromPsi(jsTestFile);
    ConfigurationFromContext configurationFromContext = getConfigurationFromContext(context);
    BlazeCommandRunConfiguration configuration = getBlazeRunConfiguration(configurationFromContext);
    assertThat(configuration.getPendingContext()).isNotNull();
    assertThat(configuration.getPendingContext()).isInstanceOf(PendingWebTestContext.class);
    PendingWebTestContext testContext = (PendingWebTestContext) configuration.getPendingContext();
    testContext.updateContextAndRerun(configuration, TargetInfo.builder(Label.create("//foo/bar:foo_test_firefox-linux"), "web_test").build(), () -> {
    });
    assertThat(configuration.getTargetKind()).isEqualTo(RuleTypes.WEB_TEST.getKind());
    assertThat(configuration.getTargets()).containsExactly(TargetExpression.fromStringSafe("//foo/bar:foo_test_firefox-linux"));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) PendingWebTestContext(com.google.idea.blaze.base.run.producers.PendingWebTestContext) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) PsiFile(com.intellij.psi.PsiFile) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) Test(org.junit.Test)

Example 54 with ConfigurationFromContext

use of com.intellij.execution.actions.ConfigurationFromContext in project intellij by bazelbuild.

the class OldJavascriptTestContextProviderTest method testOldStyleClosureTestSuite.

@Test
public void testOldStyleClosureTestSuite() throws Throwable {
    createAndIndexFile(WorkspacePath.createIfValid("javascript/closure/testing/testsuite.js"), "goog.provide('goog.testing.testSuite');", "goog.setTestOnly('goog.testing.testSuite');", "goog.testing.testSuite = function(obj, opt_options) {}");
    PsiFile jsTestFile = configure(ImmutableList.of("chrome-linux"), "goog.require('goog.testing.testSuite');", "goog.testing.testSuite({", "  testFoo() {},", "});");
    ConfigurationContext context = createContextFromPsi(jsTestFile);
    ConfigurationFromContext configurationFromContext = getConfigurationFromContext(context);
    BlazeCommandRunConfiguration configuration = getBlazeRunConfiguration(configurationFromContext);
    assertThat(configuration.getTargetKind()).isEqualTo(RuleTypes.WEB_TEST.getKind());
    assertThat(configuration.getTargets()).containsExactly(TargetExpression.fromStringSafe("//foo/bar:foo_test_chrome-linux"));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) PsiFile(com.intellij.psi.PsiFile) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) Test(org.junit.Test)

Example 55 with ConfigurationFromContext

use of com.intellij.execution.actions.ConfigurationFromContext in project intellij by bazelbuild.

the class OldJavascriptTestContextProviderTest method testTopLevelFunctions.

@Test
public void testTopLevelFunctions() throws Throwable {
    PsiFile jsTestFile = configure(ImmutableList.of("chrome-linux"), "function testFoo() {}");
    ConfigurationContext context = createContextFromPsi(jsTestFile);
    ConfigurationFromContext configurationFromContext = getConfigurationFromContext(context);
    BlazeCommandRunConfiguration configuration = getBlazeRunConfiguration(configurationFromContext);
    assertThat(configuration.getTargetKind()).isEqualTo(RuleTypes.WEB_TEST.getKind());
    assertThat(configuration.getTargets()).containsExactly(TargetExpression.fromStringSafe("//foo/bar:foo_test_chrome-linux"));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) PsiFile(com.intellij.psi.PsiFile) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) Test(org.junit.Test)

Aggregations

ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)76 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)69 Test (org.junit.Test)61 PsiFile (com.intellij.psi.PsiFile)56 BlazeCommandRunConfiguration (com.google.idea.blaze.base.run.BlazeCommandRunConfiguration)54 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)50 MockBlazeProjectDataBuilder (com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder)38 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)38 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)13 PsiClass (com.intellij.psi.PsiClass)13 PsiDirectory (com.intellij.psi.PsiDirectory)10 PyFunction (com.jetbrains.python.psi.PyFunction)8 PsiElement (com.intellij.psi.PsiElement)6 TestContextRunConfigurationProducer (com.google.idea.blaze.base.run.producers.TestContextRunConfigurationProducer)4 DataContext (com.intellij.openapi.actionSystem.DataContext)4 Project (com.intellij.openapi.project.Project)4 FuncallExpression (com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression)3 RunConfigurationProducer (com.intellij.execution.actions.RunConfigurationProducer)3 BallerinaApplicationConfiguration (org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationConfiguration)3 BallerinaApplicationRunConfigurationProducer (org.ballerinalang.plugins.idea.runconfig.application.BallerinaApplicationRunConfigurationProducer)3