diff options
Diffstat (limited to 'python/testSrc/com/jetbrains/python/fixtures/PyCommandLineTestCase.java')
-rw-r--r-- | python/testSrc/com/jetbrains/python/fixtures/PyCommandLineTestCase.java | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/python/testSrc/com/jetbrains/python/fixtures/PyCommandLineTestCase.java b/python/testSrc/com/jetbrains/python/fixtures/PyCommandLineTestCase.java index bbaf31252c3e..65815c112b2e 100644 --- a/python/testSrc/com/jetbrains/python/fixtures/PyCommandLineTestCase.java +++ b/python/testSrc/com/jetbrains/python/fixtures/PyCommandLineTestCase.java @@ -20,16 +20,15 @@ import com.intellij.execution.ExecutionException; import com.intellij.execution.Executor; import com.intellij.execution.configurations.ConfigurationFactory; import com.intellij.execution.configurations.ConfigurationType; -import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.executors.DefaultDebugExecutor; import com.intellij.execution.executors.DefaultRunExecutor; -import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.execution.runners.ExecutionEnvironmentBuilder; import com.intellij.openapi.project.Project; import com.jetbrains.python.PythonHelpersLocator; import com.jetbrains.python.debugger.PyDebugRunner; import com.jetbrains.python.run.AbstractPythonRunConfiguration; import com.jetbrains.python.run.PythonCommandLineState; +import org.jetbrains.annotations.NotNull; import java.util.List; @@ -59,11 +58,9 @@ public abstract class PyCommandLineTestCase extends PyTestCase { protected List<String> buildRunCommandLine(AbstractPythonRunConfiguration configuration) { try { - final Executor executor = DefaultRunExecutor.getRunExecutorInstance(); - ExecutionEnvironment env = new ExecutionEnvironmentBuilder(myFixture.getProject(), executor).setRunProfile(configuration).build(); - final PythonCommandLineState state = (PythonCommandLineState)configuration.getState(executor, env); - final GeneralCommandLine generalCommandLine = state.generateCommandLine(); - return generalCommandLine.getParametersList().getList(); + PythonCommandLineState state = getState(configuration, DefaultRunExecutor.getRunExecutorInstance()); + assert state != null; + return state.generateCommandLine().getParametersList().getList(); } catch (ExecutionException e) { throw new RuntimeException(e); @@ -72,15 +69,21 @@ public abstract class PyCommandLineTestCase extends PyTestCase { protected List<String> buildDebugCommandLine(AbstractPythonRunConfiguration configuration) { try { - final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance(); - ExecutionEnvironment env = new ExecutionEnvironmentBuilder(myFixture.getProject(), executor).setRunProfile(configuration).build(); - final PythonCommandLineState state = (PythonCommandLineState)configuration.getState(executor, env); - final GeneralCommandLine generalCommandLine = - state.generateCommandLine(PyDebugRunner.createCommandLinePatchers(configuration.getProject(), state, configuration, PORT)); - return generalCommandLine.getParametersList().getList(); + PythonCommandLineState state = getState(configuration, DefaultDebugExecutor.getDebugExecutorInstance()); + assert state != null; + return state.generateCommandLine(PyDebugRunner.createCommandLinePatchers(configuration.getProject(), state, configuration, PORT)) + .getParametersList() + .getList(); } catch (ExecutionException e) { throw new RuntimeException(e); } } + + + private static PythonCommandLineState getState(@NotNull AbstractPythonRunConfiguration configuration, @NotNull Executor executor) throws ExecutionException { + return (PythonCommandLineState)ExecutionEnvironmentBuilder.create(executor, configuration) + .build() + .getState(); + } } |