Java Code Examples for com.intellij.execution.runners.ExecutionEnvironment

The following are top voted examples for showing how to use com.intellij.execution.runners.ExecutionEnvironment. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: intellij-ce-playground   File: PyDebugRunner.java   View source code 6 votes vote down vote up
protected XDebugSession createSession(@NotNull RunProfileState state, @NotNull final ExecutionEnvironment environment)
  throws ExecutionException {
  FileDocumentManager.getInstance().saveAllDocuments();

  final PythonCommandLineState pyState = (PythonCommandLineState)state;
  final ServerSocket serverSocket = PythonCommandLineState.createServerSocket();
  final int serverLocalPort = serverSocket.getLocalPort();
  RunProfile profile = environment.getRunProfile();
  final ExecutionResult result =
    pyState.execute(environment.getExecutor(), createCommandLinePatchers(environment.getProject(), pyState, profile, serverLocalPort));

  return XDebuggerManager.getInstance(environment.getProject()).
    startSession(environment, new XDebugProcessStarter() {
      @Override
      @NotNull
      public XDebugProcess start(@NotNull final XDebugSession session) {
        PyDebugProcess pyDebugProcess =
          createDebugProcess(session, serverSocket, result, pyState);

        createConsoleCommunicationAndSetupActions(environment.getProject(), result, pyDebugProcess, session);
        return pyDebugProcess;
      }
    });
}
 
Example 2
Project: mule-intellij-plugins   File: WeaveDebuggerRunner.java   View source code 6 votes vote down vote up
@Nullable
protected RunContentDescriptor attachVirtualMachine(final RunProfileState state, final @NotNull ExecutionEnvironment env)
        throws ExecutionException
{

    return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter()
    {
        @NotNull
        public XDebugProcess start(@NotNull XDebugSession session) throws ExecutionException
        {
            WeaveRunnerCommandLine weaveRunnerCommandLine = (WeaveRunnerCommandLine) state;
            final String weaveFile = weaveRunnerCommandLine.getModel().getWeaveFile();
            final Project project = weaveRunnerCommandLine.getEnvironment().getProject();
            final VirtualFile projectFile = project.getBaseDir();
            final String path = project.getBasePath();
            final String relativePath = weaveFile.substring(path.length());
            final VirtualFile fileByRelativePath = projectFile.findFileByRelativePath(relativePath);
            final DebuggerClient localhost = new DebuggerClient(new WeaveDebuggerClientListener(session, fileByRelativePath), new TcpClientDebuggerProtocol("localhost", 6565));
            final ExecutionResult result = state.execute(env.getExecutor(), WeaveDebuggerRunner.this);
            new DebuggerConnector(localhost).start();
            return new WeaveDebugProcess(session, localhost, result);
        }
    }).getRunContentDescriptor();

}
 
Example 3
Project: intellij-ce-playground   File: JUnitClasspathTest.java   View source code 6 votes vote down vote up
public void testNoWorkingDirsFileWhenOnlyOneModuleExist() throws Exception {
  setupModule("mod1", "T1");
  final JUnitConfiguration configuration =
    new JUnitConfiguration("p", getProject(), JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
  configuration.setWorkingDirectory("$MODULE_DIR$");
  final JUnitConfiguration.Data persistentData = configuration.getPersistentData();
  persistentData.setScope(TestSearchScope.WHOLE_PROJECT);
  persistentData.PACKAGE_NAME = "p";
  persistentData.TEST_OBJECT = JUnitConfiguration.TEST_PACKAGE;
  final ExecutionEnvironment environment =
    ExecutionEnvironmentBuilder.create(DefaultRunExecutor.getRunExecutorInstance(), configuration).build();
  final TestPackage aPackage = new TestPackage(configuration, environment);
  aPackage.createSearchingForTestsTask().startSearch();
  final File workingDirsFile = aPackage.getWorkingDirsFile();
  assertNotNull(workingDirsFile);
  assertEmpty(FileUtil.loadFile(workingDirsFile));
}
 
Example 4
Project: intellij   File: BlazeAndroidBinaryMobileInstallRunContext.java   View source code 6 votes vote down vote up
public BlazeAndroidBinaryMobileInstallRunContext(
    Project project,
    AndroidFacet facet,
    RunConfiguration runConfiguration,
    ExecutionEnvironment env,
    BlazeAndroidBinaryRunConfigurationState configState,
    Label label,
    ImmutableList<String> blazeFlags,
    ImmutableList<String> exeFlags) {
  this.project = project;
  this.facet = facet;
  this.runConfiguration = runConfiguration;
  this.env = env;
  this.configState = configState;
  this.consoleProvider = new BlazeAndroidBinaryConsoleProvider(project);
  this.buildStep =
      new BlazeApkBuildStepMobileInstall(
          project,
          env,
          label,
          blazeFlags,
          exeFlags,
          configState.useSplitApksIfPossible(),
          configState.getLaunchMethod().equals(AndroidBinaryLaunchMethod.MOBILE_INSTALL_V2));
  this.applicationIdProvider = new BlazeAndroidBinaryApplicationIdProvider(buildStep);
}
 
Example 5
Project: tomcat-runner   File: TomcatProgramDebugger.java   View source code 6 votes vote down vote up
@Override
@Nullable
protected RunContentDescriptor createContentDescriptor(RunProfileState state, ExecutionEnvironment env)
        throws ExecutionException {
    // Now we figure out if it the Debug button has been hit
    Executor executor = env.getExecutor();
    // If was the debug, then we do some extra magic
    if (executor instanceof DefaultDebugExecutor) {
        // Get hold of the JavaParameters
        JavaCommandLine javaCommandLine = (JavaCommandLine) state;
        JavaParameters javaParameters = javaCommandLine.getJavaParameters();
        // Making the assumption that it's JVM 7 onwards
        javaParameters.getVMParametersList().addParametersString(XDEBUG);
        // Debugger port
        String debuggerPort = DebuggerUtils.getInstance().findAvailableDebugAddress(true);
        String remotePort = JDWP + debuggerPort;
        javaParameters.getVMParametersList().addParametersString(remotePort);
        // Creating a 'Remote' configuration on the fly
        RemoteConnection connection = new RemoteConnection(true, LOCALHOST, debuggerPort, false);
        // Attaches the remote configuration to the VM and then starts it up
        return super.attachVirtualMachine(state, env, connection, true);
    } else {
        // If it was something else then we don't do anything special
        return super.createContentDescriptor(state, env);
    }
}
 
Example 6
Project: intellij   File: BlazeApkBuildStepMobileInstall.java   View source code 6 votes vote down vote up
public BlazeApkBuildStepMobileInstall(
    Project project,
    ExecutionEnvironment env,
    Label label,
    ImmutableList<String> blazeFlags,
    ImmutableList<String> exeFlags,
    boolean useSplitApksIfPossible,
    boolean mobileInstallV2) {
  this.project = project;
  this.env = env;
  this.label = label;
  this.blazeFlags = blazeFlags;
  this.exeFlags = exeFlags;
  this.useSplitApksIfPossible = useSplitApksIfPossible;
  this.mobileInstallV2 = mobileInstallV2;
}
 
Example 7
Project: intellij   File: BlazeHotSwapManager.java   View source code 6 votes vote down vote up
@Nullable
static HotSwappableDebugSession findHotSwappableBlazeDebuggerSession(Project project) {
  DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project);
  DebuggerSession session = debuggerManager.getContext().getDebuggerSession();
  if (session == null || !session.isAttached()) {
    return null;
  }
  JavaDebugProcess process = session.getProcess().getXdebugProcess();
  if (process == null) {
    return null;
  }
  ExecutionEnvironment env = ((XDebugSessionImpl) process.getSession()).getExecutionEnvironment();
  if (env == null || ClassFileManifestBuilder.getManifest(env) == null) {
    return null;
  }
  RunProfile runProfile = env.getRunProfile();
  if (!(runProfile instanceof BlazeCommandRunConfiguration)) {
    return null;
  }
  return new HotSwappableDebugSession(session, env, (BlazeCommandRunConfiguration) runProfile);
}
 
Example 8
Project: intellij-ce-playground   File: TestObject.java   View source code 6 votes vote down vote up
public static TestObject fromString(final String id,
                                    final JUnitConfiguration configuration,
                                    @NotNull ExecutionEnvironment environment) {
  if (JUnitConfiguration.TEST_METHOD.equals(id)) {
    return new TestMethod(configuration, environment);
  }
  if (JUnitConfiguration.TEST_CLASS.equals(id)) {
    return new TestClass(configuration, environment);
  }
  if (JUnitConfiguration.TEST_PACKAGE.equals(id)){
    return new TestPackage(configuration, environment);
  }
  if (JUnitConfiguration.TEST_DIRECTORY.equals(id)) {
    return new TestDirectory(configuration, environment);
  }
  if (JUnitConfiguration.TEST_CATEGORY.equals(id)) {
    return new TestCategory(configuration, environment);
  }
  if (JUnitConfiguration.TEST_PATTERN.equals(id)) {
    return new TestsPattern(configuration, environment);
  }
  assert false : MESSAGE + id;
  return null;
}
 
Example 9
Project: intellij   File: BlazeAndroidTestRunConfigurationHandler.java   View source code 6 votes vote down vote up
@Override
public BlazeCommandRunConfigurationRunner createRunner(
    Executor executor, ExecutionEnvironment environment) throws ExecutionException {
  Project project = environment.getProject();

  Module module = getModule();
  AndroidFacet facet = module != null ? AndroidFacet.getInstance(module) : null;
  ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
  BlazeAndroidRunConfigurationValidationUtil.validateExecution(module, facet, projectViewSet);

  ImmutableList<String> blazeFlags =
      configState
          .getCommonState()
          .getExpandedBuildFlags(project, projectViewSet, BlazeCommandName.TEST);
  ImmutableList<String> exeFlags =
      ImmutableList.copyOf(configState.getCommonState().getExeFlagsState().getExpandedFlags());
  BlazeAndroidRunContext runContext =
      createRunContext(project, facet, environment, blazeFlags, exeFlags);

  return new BlazeAndroidRunConfigurationRunner(
      module,
      runContext,
      getCommonState().getDeployTargetManager(),
      getCommonState().getDebuggerManager(),
      configuration.getUniqueID());
}
 
Example 10
Project: intellij-ce-playground   File: AutoTestManager.java   View source code 6 votes vote down vote up
public void setAutoTestEnabled(@NotNull RunContentDescriptor descriptor, @NotNull ExecutionEnvironment environment, boolean enabled) {
  Content content = descriptor.getAttachedContent();
  if (content != null) {
    if (enabled) {
      EXECUTION_ENVIRONMENT_KEY.set(content, environment);
      myDocumentWatcher.activate();
    }
    else {
      EXECUTION_ENVIRONMENT_KEY.set(content, null);
      if (!hasEnabledAutoTests()) {
        myDocumentWatcher.deactivate();
      }
      ProcessHandler processHandler = descriptor.getProcessHandler();
      if (processHandler != null) {
        clearRestarterListener(processHandler);
      }
    }
  }
}
 
Example 11
Project: intellij-ce-playground   File: MvcRunConfiguration.java   View source code 6 votes vote down vote up
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
  final Module module = getModule();
  if (module == null) {
    throw new ExecutionException("Module is not specified");
  }

  if (!isSupport(module)) {
    throw new ExecutionException(getNoSdkMessage());
  }

  final ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
  final Sdk sdk = rootManager.getSdk();
  if (sdk == null || !(sdk.getSdkType() instanceof JavaSdkType)) {
    throw CantRunException.noJdkForModule(module);
  }

  return createCommandLineState(environment, module);

}
 
Example 12
Project: intellij-ce-playground   File: ExecutionManagerImpl.java   View source code 6 votes vote down vote up
protected void doRun(@NotNull final ExecutionEnvironment environment, @NotNull final Runnable startRunnable) {
  Boolean allowSkipRun = environment.getUserData(EXECUTION_SKIP_RUN);
  if (allowSkipRun != null && allowSkipRun) {
    environment.getProject().getMessageBus().syncPublisher(EXECUTION_TOPIC).processNotStarted(environment.getExecutor().getId(),
                                                                                              environment);
  }
  else {
    // important! Do not use DumbService.smartInvokeLater here because it depends on modality state
    // and execution of startRunnable could be skipped if modality state check fails
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        if (!myProject.isDisposed()) {
          DumbService.getInstance(myProject).runWhenSmart(startRunnable);
        }
      }
    });
  }
}
 
Example 13
Project: intellij-ce-playground   File: AutoTestManager.java   View source code 6 votes vote down vote up
private static boolean isAutoTestEnabledForDescriptor(@NotNull RunContentDescriptor descriptor) {
  Content content = descriptor.getAttachedContent();
  if (content != null) {
    ExecutionEnvironment watched = EXECUTION_ENVIRONMENT_KEY.get(content);
    if (watched != null) {
      ExecutionEnvironment current = getCurrentEnvironment(content);
      boolean result = current != null && equals(current, watched);
      if (!result) {
        // let GC do its work
        EXECUTION_ENVIRONMENT_KEY.set(content, null);
      }
      return result;
    }
  }
  return false;
}
 
Example 14
Project: intellij-ce-playground   File: SMTRunnerConsoleTest.java   View source code 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();

  final TestConsoleProperties consoleProperties = createConsoleProperties();
  final ExecutionEnvironment environment = new ExecutionEnvironment();

  myMockResettablePrinter = new MockPrinter(true);
  myConsole = new MyConsoleView(consoleProperties, environment);
  myConsole.initUI();
  myResultsViewer = myConsole.getResultsViewer();
  myRootSuite = myResultsViewer.getTestsRootNode();
  myEventsProcessor = new GeneralToSMTRunnerEventsConvertor(consoleProperties.getProject(), myResultsViewer.getTestsRootNode(), "SMTestFramework");

  myEventsProcessor.onStartTesting();
}
 
Example 15
Project: intellij-ce-playground   File: SMTRunnerStatisticsPanelTest.java   View source code 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();

  myRootSuite = createSuiteProxy("root");

  final TestConsoleProperties consoleProperties = createConsoleProperties();
  final ExecutionEnvironment environment = new ExecutionEnvironment();
  myResultsForm = new SMTestRunnerResultsForm(
    new JLabel(),
                                              consoleProperties
  );
  Disposer.register(myResultsForm, consoleProperties);
  myResultsForm.initUI();
  myStatisticsPanel = myResultsForm.getStatisticsPane();
  myTestEventsListener = myStatisticsPanel.createTestEventsListener();
}
 
Example 16
Project: intellij-ce-playground   File: RerunFailedActionsTestTools.java   View source code 6 votes vote down vote up
/**
 * Fetches "rerun" env from run action
 *
 * @param runAction action to fetch state from
 * @return state or null if not found
 */
@Nullable
public static ExecutionEnvironment getReRunEnvironment(@NotNull final AbstractRerunFailedTestsAction runAction) {
  final MyRunProfile profile = runAction.getRunProfile(new ExecutionEnvironment());
  if (profile == null) {
    return null;
  }
  final Ref<ExecutionEnvironment> stateRef = new Ref<ExecutionEnvironment>();
  UsefulTestCase.edt(new Runnable() {
    @Override
    public void run() {
      stateRef.set(ExecutionEnvironmentBuilder.create(DefaultRunExecutor.getRunExecutorInstance(), profile).build());
    }
  });
  return stateRef.get();
}
 
Example 17
Project: intellij-ce-playground   File: ExternalSystemRunConfiguration.java   View source code 6 votes vote down vote up
public MyRunnableState(@NotNull ExternalSystemTaskExecutionSettings settings,
                       @NotNull Project project,
                       boolean debug,
                       @NotNull ExternalSystemRunConfiguration configuration,
                       @NotNull ExecutionEnvironment env) {
  mySettings = settings;
  myProject = project;
  myConfiguration = configuration;
  myEnv = env;
  int port;
  if (debug) {
    try {
      port = NetUtils.findAvailableSocketPort();
    }
    catch (IOException e) {
      LOG.warn("Unexpected I/O exception occurred on attempt to find a free port to use for external system task debugging", e);
      port = 0;
    }
  }
  else {
    port = 0;
  }
  myDebugPort = port;
}
 
Example 18
Project: intellij-ce-playground   File: ExternalSystemBeforeRunTaskProvider.java   View source code 6 votes vote down vote up
@Override
public boolean canExecuteTask(RunConfiguration configuration, ExternalSystemBeforeRunTask beforeRunTask) {
  final ExternalSystemTaskExecutionSettings executionSettings = beforeRunTask.getTaskExecutionSettings();

  final List<ExternalTaskPojo> tasks = ContainerUtilRt.newArrayList();
  for (String taskName : executionSettings.getTaskNames()) {
    tasks.add(new ExternalTaskPojo(taskName, executionSettings.getExternalProjectPath(), null));
  }
  if (tasks.isEmpty()) return true;

  final Pair<ProgramRunner, ExecutionEnvironment> pair =
    ExternalSystemUtil.createRunner(executionSettings, DefaultRunExecutor.EXECUTOR_ID, myProject, mySystemId);

  if (pair == null) return false;

  final ProgramRunner runner = pair.first;
  final ExecutionEnvironment environment = pair.second;

  return runner.canRun(DefaultRunExecutor.EXECUTOR_ID, environment.getRunProfile());
}
 
Example 19
Project: intellij-ce-playground   File: ExternalSystemUtil.java   View source code 6 votes vote down vote up
@Nullable
public static Pair<ProgramRunner, ExecutionEnvironment> createRunner(@NotNull ExternalSystemTaskExecutionSettings taskSettings,
                                                                     @NotNull String executorId,
                                                                     @NotNull Project project,
                                                                     @NotNull ProjectSystemId externalSystemId) {
  Executor executor = ExecutorRegistry.getInstance().getExecutorById(executorId);
  if (executor == null) return null;

  String runnerId = getRunnerId(executorId);
  if (runnerId == null) return null;

  ProgramRunner runner = RunnerRegistry.getInstance().findRunnerById(runnerId);
  if (runner == null) return null;

  RunnerAndConfigurationSettings settings = createExternalSystemRunnerAndConfigurationSettings(taskSettings, project, externalSystemId);
  if (settings == null) return null;

  return Pair.create(runner, new ExecutionEnvironment(executor, runner, settings, project));
}
 
Example 20
Project: intellij-ce-playground   File: RerunFailedTestsAction.java   View source code 6 votes vote down vote up
@Override
protected MyRunProfile getRunProfile(@NotNull ExecutionEnvironment environment) {
  //noinspection ConstantConditions
  final JUnitConfiguration configuration = (JUnitConfiguration)myConsoleProperties.getConfiguration();
  final TestMethods testMethods = new TestMethods(configuration, environment, getFailedTests(configuration.getProject()));
  return new MyRunProfile(configuration) {
    @Override
    @NotNull
    public Module[] getModules() {
      return testMethods.getModulesToCompile();
    }

    @Override
    public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) {
      testMethods.clear();
      return testMethods;
    }
  };
}
 
Example 21
Project: intellij   File: BlazePyRunConfigurationRunner.java   View source code 6 votes vote down vote up
@Override
public boolean executeBeforeRunTask(ExecutionEnvironment env) {
  if (!isDebugging(env)) {
    return true;
  }
  env.getCopyableUserData(EXECUTABLE_KEY).set(null);
  try {
    File executable = getExecutableToDebug(env);
    env.getCopyableUserData(EXECUTABLE_KEY).set(executable);
    if (executable != null) {
      return true;
    }
  } catch (ExecutionException e) {
    ExecutionUtil.handleExecutionError(
        env.getProject(), env.getExecutor().getToolWindowId(), env.getRunProfile(), e);
  }
  return false;
}
 
Example 22
Project: react-native-console   File: FreeRunConfiguration.java   View source code 5 votes vote down vote up
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
    // here just run one command: python freeline.py
    GeneralCommandLine commandLine = new GeneralCommandLine();
    ExecutionEnvironment environment = getEnvironment();
    commandLine.setWorkDirectory(environment.getProject().getBasePath());
    commandLine.setExePath("npm");
    commandLine.addParameters("list");
    return new OSProcessHandler(commandLine);
}
 
Example 23
Project: educational-plugin   File: PyCCCommandLineState.java   View source code 5 votes vote down vote up
public PyCCCommandLineState(PyCCRunTestConfiguration runConfiguration,
                            ExecutionEnvironment env) {
  super(runConfiguration, env);
  myRunConfiguration = runConfiguration;

  VirtualFile testsFile = LocalFileSystem.getInstance().findFileByPath(myRunConfiguration.getPathToTest());
  assert testsFile != null;
  myTaskDir = StudyUtils.getTaskDir(testsFile);
  assert myTaskDir != null;
  myTask = StudyUtils.getTask(myRunConfiguration.getProject(), myTaskDir);
  assert myTask != null;
}
 
Example 24
Project: processing-idea   File: ProcessingCommandLineState.java   View source code 5 votes vote down vote up
public ProcessingCommandLineState(Module module,
                                  ExecutionEnvironment environment,
                                  @NotNull final ProcessingRunConfiguration configuration) {
    super(environment);
    this.configuration = configuration;
    this.module = module;
}
 
Example 25
Project: Goal-Intellij-Plugin   File: GoalDebugConfiguration.java   View source code 5 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {


    final CommandLineState state = new CommandLineState(environment) {
        @NotNull
        @Override
        protected ProcessHandler startProcess() throws ExecutionException {
            GoalRuntime runtime = GoalRuntime.instance;
            System.out.println("runtime is created");

            final GeneralCommandLine line = new GeneralCommandLine();
            line.setRedirectErrorStream(true);
            line.setExePath("java");
            line.addParameters("-cp","-debug", runtime.getRuntimePath().toString(),
                    "goal.tools.Run",
                    GoalDebugConfiguration.this.runFilePath);

            System.out.println("command: " + line.getCommandLineString());


            final Process process = line.createProcess();
            return new OSProcessHandler(process, line.getCommandLineString());
        }


    };

    return state;
}
 
Example 26
Project: Goal-Intellij-Plugin   File: GoalRunConfiguration.java   View source code 5 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor,
                                @NotNull ExecutionEnvironment environment)
        throws ExecutionException {
    final CommandLineState state = new CommandLineState(environment) {
        @NotNull
        @Override
        protected ProcessHandler startProcess() throws ExecutionException {
            final GoalRuntime runtime = GoalRuntime.getInstance();

            //TODO: MAke sure that the preferences are used when running goal.
            //final Path preferences = GoalRunConfiguration.this.writePreferences();

            final GeneralCommandLine line = new GeneralCommandLine();
            line.setRedirectErrorStream(true);
            line.setExePath("java");
            line.addParameters(
                    "-cp", runtime.getRuntimePath().toString(),
                    "goal.tools.Run",
                    //preferences.toString(),
                    GoalRunConfiguration.this.runFilePath
            );
            System.out.println("command: " + line.getCommandLineString());


            final Process process = line.createProcess();

            return new OSProcessHandler(process, line.getCommandLineString());
        }
    };

    return state;
}
 
Example 27
Project: intellij   File: BlazeBeforeRunTaskProvider.java   View source code 5 votes vote down vote up
@Override
public boolean executeTask(
    final DataContext dataContext,
    final RunConfiguration configuration,
    final ExecutionEnvironment env,
    Task task) {
  if (!canExecuteTask(configuration, task)) {
    return false;
  }
  BlazeCommandRunConfigurationRunner runner =
      env.getCopyableUserData(BlazeCommandRunConfigurationRunner.RUNNER_KEY);
  return runner.executeBeforeRunTask(env);
}
 
Example 28
Project: intellij-nette-tester   File: TesterExecutionUtil.java   View source code 5 votes vote down vote up
public static ConsoleView createConsole(Project project, ProcessHandler processHandler, ExecutionEnvironment executionEnvironment, TesterTestLocator locationProvider) {
    TesterRunConfiguration profile = (TesterRunConfiguration) executionEnvironment.getRunProfile();

    TesterConsoleProperties properties = new TesterConsoleProperties(profile, executionEnvironment.getExecutor(), locationProvider);
    properties.addStackTraceFilter(new XdebugCallStackFilter(project, locationProvider.getPathMapper()));

    BaseTestsOutputConsoleView testsOutputConsoleView = SMTestRunnerConnectionUtil.createConsole("Nette Tester", properties);
    testsOutputConsoleView.addMessageFilter(new TesterStackTraceFilter(project, locationProvider.getPathMapper()));
    testsOutputConsoleView.attachToProcess(processHandler);
    Disposer.register(project, testsOutputConsoleView);
    return testsOutputConsoleView;
}
 
Example 29
Project: intellij-ce-playground   File: TestNGConsoleView.java   View source code 5 votes vote down vote up
public TestNGConsoleView(TestNGConfiguration config,
                         ExecutionEnvironment environment,
                         final TreeRootNode unboundOutputRoot,
                         Executor executor) {
  super(new TestNGConsoleProperties(config, executor), unboundOutputRoot);
  myConfiguration = config;
  myEnvironment = environment;
  myUnboundOutput = unboundOutputRoot;
}
 
Example 30
Project: intellij-ce-playground   File: Tool.java   View source code 5 votes vote down vote up
public void execute(AnActionEvent event, DataContext dataContext, long executionId, @Nullable final ProcessListener processListener) {
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return;
  }

  FileDocumentManager.getInstance().saveAllDocuments();
  try {
    if (isUseConsole()) {
      ExecutionEnvironment environment = ExecutionEnvironmentBuilder.create(project,
                                                                            DefaultRunExecutor.getRunExecutorInstance(),
                                                                            new ToolRunProfile(this, dataContext)).build();
      environment.setExecutionId(executionId);
      environment.getRunner().execute(environment, new ProgramRunner.Callback() {
        @Override
        public void processStarted(RunContentDescriptor descriptor) {
          ProcessHandler processHandler = descriptor.getProcessHandler();
          if (processHandler != null && processListener != null) {
            processHandler.addProcessListener(processListener);
          }
        }
      });
    }
    else {
      GeneralCommandLine commandLine = createCommandLine(dataContext);
      if (commandLine == null) {
        return;
      }
      OSProcessHandler handler = new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString());
      handler.addProcessListener(new ToolProcessAdapter(project, synchronizeAfterExecution(), getName()));
      if (processListener != null) {
        handler.addProcessListener(processListener);
      }
      handler.startNotify();
    }
  }
  catch (ExecutionException ex) {
    ExecutionErrorDialog.show(ex, ToolsBundle.message("tools.process.start.error"), project);
  }
}
 
Example 31
Project: intellij-ce-playground   File: GradleTestsExecutionConsoleManager.java   View source code 5 votes vote down vote up
@NotNull
@Override
public ExecutionConsole attachExecutionConsole(@NotNull final ExternalSystemTask task,
                                               @NotNull final Project project,
                                               @NotNull final ExternalSystemRunConfiguration configuration,
                                               @NotNull final Executor executor,
                                               @NotNull final ExecutionEnvironment env,
                                               @NotNull final ProcessHandler processHandler) throws ExecutionException {
  final GradleConsoleProperties properties = new GradleConsoleProperties(configuration, executor);
  myExecutionConsole = (SMTRunnerConsoleView)SMTestRunnerConnectionUtil.createAndAttachConsole(
    configuration.getSettings().getExternalSystemId().getReadableName(), processHandler, properties);

  TestTreeRenderer originalRenderer =
    ObjectUtils.tryCast(myExecutionConsole.getResultsViewer().getTreeView().getCellRenderer(), TestTreeRenderer.class);
  if (originalRenderer != null) {
    originalRenderer.setAdditionalRootFormatter(new SMRootTestProxyFormatter() {
      @Override
      public void format(@NotNull SMTestProxy.SMRootTestProxy testProxy, @NotNull TestTreeRenderer renderer) {
        final TestStateInfo.Magnitude magnitude = testProxy.getMagnitudeInfo();
        if (magnitude == TestStateInfo.Magnitude.RUNNING_INDEX) {
          renderer.clear();
          renderer.append(GradleBundle.message(
                            "gradle.test.runner.ui.tests.tree.presentation.labels.waiting.tests"),
                          SimpleTextAttributes.REGULAR_ATTRIBUTES
          );
        }
        else if (!testProxy.isInProgress() && testProxy.isEmptySuite()) {
          renderer.clear();
          renderer.append(GradleBundle.message(
                            "gradle.test.runner.ui.tests.tree.presentation.labels.no.tests.were.found"),
                          SimpleTextAttributes.REGULAR_ATTRIBUTES
          );
        }
      }
    });
  }
  return myExecutionConsole;
}
 
Example 32
Project: intellij-ce-playground   File: TestMethods.java   View source code 5 votes vote down vote up
public TestMethods(@NotNull JUnitConfiguration configuration,
                   @NotNull ExecutionEnvironment environment,
                   @NotNull Collection<AbstractTestProxy> failedTests) {
  super(configuration, environment);

  myFailedTests = failedTests;
}
 
Example 33
Project: intellij-ce-playground   File: DefaultDebugEnvironment.java   View source code 5 votes vote down vote up
public DefaultDebugEnvironment(@NotNull ExecutionEnvironment environment, @NotNull RunProfileState state, RemoteConnection remoteConnection, boolean pollConnection) {
  this.environment = environment;
  this.state = state;
  myRemoteConnection = remoteConnection;
  myPollConnection = pollConnection;

  mySearchScope = SearchScopeProvider.createSearchScope(environment.getProject(), environment.getRunProfile());
}
 
Example 34
Project: intellij-ce-playground   File: AndroidRunConfiguration.java   View source code 5 votes vote down vote up
@Override
public AndroidRunningState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
  AndroidRunningState state = super.getState(executor, env);
  if (state != null) {
    state.setDeploy(DEPLOY);
    state.setArtifactName(ARTIFACT_NAME);
    state.setOpenLogcatAutomatically(SHOW_LOGCAT_AUTOMATICALLY);
    state.setFilterLogcatAutomatically(FILTER_LOGCAT_AUTOMATICALLY);
  }
  return state;
}
 
Example 35
Project: intellij-ce-playground   File: ConfigurationBasedProcessRunner.java   View source code 5 votes vote down vote up
@Override
protected final boolean shouldRunAgain() {
  final ExecutionEnvironment rerunEnvironment = getEnvironmentToRerun(myLastProcessDescriptor);
  if (rerunEnvironment == null) {
    return false;
  }
  myRerunExecutionEnvironment = rerunEnvironment;
  return true;
}
 
Example 36
Project: intellij-ce-playground   File: GenericDebuggerRunner.java   View source code 5 votes vote down vote up
@Nullable
protected RunContentDescriptor attachVirtualMachine(RunProfileState state,
                                                    @NotNull ExecutionEnvironment env,
                                                    RemoteConnection connection,
                                                    boolean pollConnection) throws ExecutionException {
  DebugEnvironment environment = new DefaultDebugEnvironment(env, state, connection, pollConnection);
  final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(env.getProject()).attachVirtualMachine(environment);
  if (debuggerSession == null) {
    return null;
  }

  final DebugProcessImpl debugProcess = debuggerSession.getProcess();
  if (debugProcess.isDetached() || debugProcess.isDetaching()) {
    debuggerSession.dispose();
    return null;
  }
  if (environment.isRemote()) {
    // optimization: that way BatchEvaluator will not try to lookup the class file in remote VM
    // which is an expensive operation when executed first time
    debugProcess.putUserData(BatchEvaluator.REMOTE_SESSION_KEY, Boolean.TRUE);
  }

  return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {
    @Override
    @NotNull
    public XDebugProcess start(@NotNull XDebugSession session) {
      XDebugSessionImpl sessionImpl = (XDebugSessionImpl)session;
      ExecutionResult executionResult = debugProcess.getExecutionResult();
      sessionImpl.addExtraActions(executionResult.getActions());
      if (executionResult instanceof DefaultExecutionResult) {
        sessionImpl.addRestartActions(((DefaultExecutionResult)executionResult).getRestartActions());
        sessionImpl.addExtraStopActions(((DefaultExecutionResult)executionResult).getAdditionalStopActions());
      }
      return JavaDebugProcess.create(session, debuggerSession);
    }
  }).getRunContentDescriptor();
}
 
Example 37
Project: intellij-ce-playground   File: ToggleAutoTestAction.java   View source code 5 votes vote down vote up
@Override
public void setSelected(AnActionEvent e, boolean state) {
  Project project = e.getData(CommonDataKeys.PROJECT);
  RunContentDescriptor descriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
  ExecutionEnvironment environment = e.getData(LangDataKeys.EXECUTION_ENVIRONMENT);
  if (project != null && descriptor != null && environment != null) {
    AutoTestManager.getInstance(project).setAutoTestEnabled(descriptor, environment, state);
  }
}
 
Example 38
Project: intellij-ce-playground   File: PyDebugRunner.java   View source code 5 votes vote down vote up
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull final ExecutionEnvironment environment)
  throws ExecutionException {
  XDebugSession session = createSession(state, environment);
  initSession(session, state, environment.getExecutor());
  return session.getRunContentDescriptor();
}
 
Example 39
Project: intellij-ce-playground   File: ApplicationConfiguration.java   View source code 5 votes vote down vote up
@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
  final JavaCommandLineState state = new JavaApplicationCommandLineState<ApplicationConfiguration>(this, env);
  JavaRunConfigurationModule module = getConfigurationModule();
  state.setConsoleBuilder(TextConsoleBuilderFactory.getInstance().createBuilder(getProject(), module.getSearchScope()));
  return state;
}
 
Example 40
Project: intellij-ce-playground   File: PyRerunFailedTestsAction.java   View source code 5 votes vote down vote up
@Override
@Nullable
protected MyRunProfile getRunProfile(@NotNull ExecutionEnvironment environment) {
  final TestFrameworkRunningModel model = getModel();
  if (model == null) {
    return null;
  }
  return new MyTestRunProfile((AbstractPythonRunConfiguration)model.getProperties().getConfiguration());
}