Search in sources :

Example 96 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-plugins by JetBrains.

the class CfmlRunConfigurationTest method getContextRunConfiguration.

private static CfmlRunConfiguration getContextRunConfiguration(Editor editor) {
    final DataContext dataContext = DataManager.getInstance().getDataContext(editor.getComponent());
    final ConfigurationContext configurationContext = ConfigurationContext.getFromContext(dataContext);
    //this block emulates RunContextAction.perform()
    RunnerAndConfigurationSettings configuration = configurationContext.findExisting();
    if (configuration == null) {
        configuration = configurationContext.getConfiguration();
        if (configuration == null) {
            return null;
        }
        ((RunManagerEx) configurationContext.getRunManager()).setTemporaryConfiguration(configuration);
    }
    //end of the emulated block
    return (CfmlRunConfiguration) configuration.getConfiguration();
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) RunManagerEx(com.intellij.execution.RunManagerEx) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) CfmlRunConfiguration(com.intellij.coldFusion.UI.runner.CfmlRunConfiguration)

Example 97 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-plugins by JetBrains.

the class CfmlRunConfigurationTest method generateNonDefaultRunConfiguration.

public void generateNonDefaultRunConfiguration() throws IOException, ConfigurationException {
    final CfmlRunConfiguration defaultCfmlRunConfiguration = getDefaultCfmlRunConfiguration();
    final CfmlRunConfiguration clonedConfiguration = (CfmlRunConfiguration) defaultCfmlRunConfiguration.clone();
    clonedConfiguration.getRunnerParameters().setUrl("http://4.4.4.4/src/index.cfm");
    final RunnerAndConfigurationSettings runnerAndConfigurationSettings = RunManager.getInstance(getProject()).createConfiguration(clonedConfiguration, CfmlRunConfigurationType.getInstance().getConfigurationFactories()[0]);
    RunManager.getInstance(getProject()).addConfiguration(runnerAndConfigurationSettings, false);
}
Also used : CfmlRunConfiguration(com.intellij.coldFusion.UI.runner.CfmlRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 98 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-plugins by JetBrains.

the class FlexModuleBuilder method createRunConfiguration.

public static void createRunConfiguration(final Module module, final FlexBuildConfiguration bc) {
    final RunManager runManager = RunManagerEx.getInstance(module.getProject());
    final List<RunConfiguration> existingConfigurations = runManager.getConfigurationsList(FlashRunConfigurationType.getInstance());
    for (RunConfiguration configuration : existingConfigurations) {
        final FlashRunnerParameters parameters = ((FlashRunConfiguration) configuration).getRunnerParameters();
        if (module.getName().equals(parameters.getModuleName()) && bc.getName().equals(parameters.getBCName())) {
            //already exists
            return;
        }
    }
    final RunnerAndConfigurationSettings settings = runManager.createConfiguration("", FlashRunConfigurationType.getFactory());
    final FlashRunConfiguration runConfiguration = (FlashRunConfiguration) settings.getConfiguration();
    final FlashRunnerParameters params = runConfiguration.getRunnerParameters();
    params.setModuleName(module.getName());
    params.setBCName(bc.getName());
    if (bc.getNature().isMobilePlatform()) {
        if (bc.getAndroidPackagingOptions().isEnabled()) {
            params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.Android);
        } else if (bc.getIosPackagingOptions().isEnabled()) {
            params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.IOS);
        }
    }
    settings.setName(params.suggestUniqueName(existingConfigurations));
    settings.setTemporary(false);
    runManager.addConfiguration(settings, false);
    runManager.setSelectedConfiguration(settings);
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RunManager(com.intellij.execution.RunManager) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters)

Example 99 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-plugins by JetBrains.

the class FlexUnitExecutionTest method doTest.

private AbstractTestProxy doTest(boolean debugNotRun, FlexUnitRunnerParameters.Scope testScope, String testClassOrPackage, @Nullable String testMethod, @Nullable String projectRoot, @Nullable FlexUnitRunnerParameters.OutputLogLevel outputLogLevel, String... files) throws Exception {
    configureByFiles(projectRoot, files);
    final Ref<IXMLElement> expected = new Ref<>();
    UIUtil.invokeAndWaitIfNeeded((Runnable) () -> WriteAction.run(() -> {
        try {
            Collection<IXMLElement> collection = JSTestUtils.extractXml(myEditor.getDocument(), "testResults");
            assertEquals("Invalid expected structure", 1, collection.size());
            expected.set(collection.iterator().next());
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
    }));
    UIUtil.invokeAndWaitIfNeeded((Runnable) () -> WriteAction.run(() -> FlexTestUtils.modifyBuildConfiguration(myModule, configuration -> configuration.setTargetPlatform(myTargetPlatform))));
    final RunnerAndConfigurationSettings runnerAndConfigurationSettings = RunManager.getInstance(myProject).createRunConfiguration("test", FlexUnitRunConfigurationType.getFactory());
    final FlexUnitRunConfiguration flexUnitRunConfig = (FlexUnitRunConfiguration) runnerAndConfigurationSettings.getConfiguration();
    final FlexUnitRunnerParameters params = flexUnitRunConfig.getRunnerParameters();
    params.setModuleName(myModule.getName());
    params.setBCName(FlexBuildConfigurationManager.getInstance(myModule).getBuildConfigurations()[0].getName());
    params.setOutputLogLevel(outputLogLevel);
    params.setScope(testScope);
    switch(testScope) {
        case Class:
            params.setClassName(testClassOrPackage);
            break;
        case Method:
            params.setClassName(testClassOrPackage);
            params.setMethodName(testMethod);
            break;
        case Package:
            params.setPackageName(testClassOrPackage);
            break;
        default:
            fail("Unknown scope: " + testScope);
    }
    flexUnitRunConfig.checkConfiguration();
    final ProgramRunner runner = new FlexUnitTestRunner();
    final Executor executor = debugNotRun ? DefaultDebugExecutor.getDebugExecutorInstance() : DefaultRunExecutor.getRunExecutorInstance();
    final ExecutionEnvironment env = new ExecutionEnvironment(executor, runner, runnerAndConfigurationSettings, getProject());
    final Semaphore compilation = new Semaphore();
    compilation.down();
    final Semaphore execution = new Semaphore();
    execution.down();
    final Semaphore startup = new Semaphore();
    final ProcessListener listener = new ProcessListener() {

        @Override
        public void startNotified(ProcessEvent event) {
            startup.up();
        }

        @Override
        public void processTerminated(ProcessEvent event) {
            execution.up();
        }

        @Override
        public void processWillTerminate(ProcessEvent event, boolean willBeDestroyed) {
        }

        @Override
        public void onTextAvailable(ProcessEvent event, Key outputType) {
            System.out.println("FlexUnit: " + event.getText());
        }
    };
    final Ref<ExecutionConsole> executionConsole = new Ref<>();
    ApplicationManager.getApplication().invokeLater(() -> {
        try {
            runner.execute(env, new ProgramRunner.Callback() {

                @Override
                public void processStarted(RunContentDescriptor descriptor) {
                    compilation.up();
                    startup.down();
                    descriptor.getProcessHandler().addProcessListener(listener);
                    executionConsole.set(descriptor.getExecutionConsole());
                }
            });
        } catch (Throwable t) {
            t.printStackTrace();
            fail(t.getMessage());
            compilation.up();
            startup.up();
            execution.up();
        }
    });
    if (!compilation.waitFor(COMPILATION_TIMEOUT * 1000)) {
        fail("Compilation did not succeed in " + COMPILATION_TIMEOUT + " seconds. There was an error or it took too long\n" + FlexCompilerHandler.getInstance(myProject).getLastCompilationMessages());
    }
    if (!startup.waitFor(STARTUP_TIMEOUT * 1000)) {
        fail("Process was not started in " + STARTUP_TIMEOUT + " seconds");
    }
    if (!execution.waitFor(EXECUTION_TIMEOUT * 1000)) {
        fail("Execution did not finish in " + EXECUTION_TIMEOUT + " seconds");
    }
    // give tests tree some time to stabilize
    Thread.sleep(200);
    final AbstractTestProxy testRoot = ((SMTRunnerConsoleView) executionConsole.get()).getResultsViewer().getRoot();
    checkResults(expected.get(), testRoot);
    if (outputLogLevel == null) {
        checkOutput(testRoot, outputLogLevel);
    }
    return testRoot;
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) VirtualFile(com.intellij.openapi.vfs.VirtualFile) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) TargetPlatform(com.intellij.flex.model.bc.TargetPlatform) ServerSocket(java.net.ServerSocket) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType) FlexCompilerHandler(com.intellij.lang.javascript.flex.build.FlexCompilerHandler) Semaphore(com.intellij.util.concurrency.Semaphore) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) Map(java.util.Map) TestStateInfo(com.intellij.execution.testframework.sm.runner.states.TestStateInfo) FlexUnitRunConfigurationType(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfigurationType) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Collection(java.util.Collection) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo) Nullable(org.jetbrains.annotations.Nullable) Printable(com.intellij.execution.testframework.Printable) ProcessListener(com.intellij.execution.process.ProcessListener) SMTRunnerConsoleView(com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) JSTestOptions(com.intellij.lang.javascript.JSTestOptions) ApplicationManager(com.intellij.openapi.application.ApplicationManager) ProcessEvent(com.intellij.execution.process.ProcessEvent) NotNull(org.jetbrains.annotations.NotNull) FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) Ref(com.intellij.openapi.util.Ref) ExecutionConsole(com.intellij.execution.ui.ExecutionConsole) CodeInsightTestCase(com.intellij.codeInsight.CodeInsightTestCase) WriteAction(com.intellij.openapi.application.WriteAction) JSTestOption(com.intellij.lang.javascript.JSTestOption) FlexModuleType(com.intellij.lang.javascript.flex.FlexModuleType) FlexUnitLibs(com.intellij.flex.util.FlexUnitLibs) HashMap(java.util.HashMap) CompilerProjectExtension(com.intellij.openapi.roots.CompilerProjectExtension) IXMLElement(net.n3.nanoxml.IXMLElement) SocketTimeoutException(java.net.SocketTimeoutException) RunManager(com.intellij.execution.RunManager) ModuleType(com.intellij.openapi.module.ModuleType) FlexTestUtils(com.intellij.flex.util.FlexTestUtils) ThrowableRunnable(com.intellij.util.ThrowableRunnable) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) ProgramRunner(com.intellij.execution.runners.ProgramRunner) FlexUnitRunnerParameters(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters) Key(com.intellij.openapi.util.Key) FlexUnitRunConfiguration(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration) IOException(java.io.IOException) Executor(com.intellij.execution.Executor) AbstractTestProxy(com.intellij.execution.testframework.AbstractTestProxy) Sdk(com.intellij.openapi.projectRoots.Sdk) File(java.io.File) JSTestUtils(com.intellij.lang.javascript.JSTestUtils) Printer(com.intellij.execution.testframework.Printer) FlexCompilerProjectConfiguration(com.intellij.lang.javascript.flex.build.FlexCompilerProjectConfiguration) Assert(org.junit.Assert) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) ProcessEvent(com.intellij.execution.process.ProcessEvent) ProcessListener(com.intellij.execution.process.ProcessListener) FlexUnitRunConfiguration(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration) AbstractTestProxy(com.intellij.execution.testframework.AbstractTestProxy) Semaphore(com.intellij.util.concurrency.Semaphore) IXMLElement(net.n3.nanoxml.IXMLElement) SocketTimeoutException(java.net.SocketTimeoutException) IOException(java.io.IOException) Ref(com.intellij.openapi.util.Ref) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) Executor(com.intellij.execution.Executor) FlexUnitRunnerParameters(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ExecutionConsole(com.intellij.execution.ui.ExecutionConsole) ProgramRunner(com.intellij.execution.runners.ProgramRunner) Key(com.intellij.openapi.util.Key)

Example 100 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-plugins by JetBrains.

the class FlexTestUtils method checkFlashRunConfig.

public static void checkFlashRunConfig(final RunManager runManager, final Module module, final String configName, final String className) {
    final List<RunnerAndConfigurationSettings> settings = runManager.getConfigurationSettingsList(FlashRunConfigurationType.getInstance());
    RunnerAndConfigurationSettings settingsToCheck = null;
    for (RunnerAndConfigurationSettings setting : settings) {
        if (configName.equals(setting.getName())) {
            settingsToCheck = setting;
            break;
        }
    }
    Assert.assertNotNull("Run configuration not found: " + configName, settingsToCheck);
    final FlashRunnerParameters params = ((FlashRunConfiguration) settingsToCheck.getConfiguration()).getRunnerParameters();
    Assert.assertEquals(className, params.getOverriddenMainClass());
    Assert.assertEquals(FlexBuildConfigurationManager.getInstance(module).getActiveConfiguration().getName(), params.getBCName());
}
Also used : FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters)

Aggregations

RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)104 Project (com.intellij.openapi.project.Project)24 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)16 RunManagerEx (com.intellij.execution.RunManagerEx)14 Nullable (org.jetbrains.annotations.Nullable)14 RunManager (com.intellij.execution.RunManager)12 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 Module (com.intellij.openapi.module.Module)10 NotNull (org.jetbrains.annotations.NotNull)9 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)7 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)7 ExternalSystemRunConfiguration (com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration)7 ExternalSystemTaskExecutionSettings (com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)6 Executor (com.intellij.execution.Executor)4 RunManagerImpl (com.intellij.execution.impl.RunManagerImpl)4 AbstractExternalSystemTaskConfigurationType (com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType)4 ExternalSystemNode (com.intellij.openapi.externalSystem.view.ExternalSystemNode)4 RunConfigurationNode (com.intellij.openapi.externalSystem.view.RunConfigurationNode)4 PsiElement (com.intellij.psi.PsiElement)4 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)3