From: Ilya.Kazakevich Date: Wed, 16 Nov 2016 15:41:04 +0000 (+0300) Subject: PY-21454: Use project dir if directory not provided X-Git-Tag: rubymine/171.1024~7 X-Git-Url: https://git.jetbrains.org/?p=idea%2Fcommunity.git;a=commitdiff_plain;h=b729a1c229a8886332072319e63cdafa6fdaee7e PY-21454: Use project dir if directory not provided * We already have this functionality for tests, we now support it for any config. * Default folder should never be PyCharm working dir. Project should be used if workdir not provided explicitly --- diff --git a/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java b/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java index 470cd7f2134e..d7a9db40811d 100644 --- a/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java +++ b/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java @@ -89,7 +89,7 @@ public abstract class PythonTestCommandLineStateBase extends PythonCommandLineSt } @Override - public GeneralCommandLine generateCommandLine() { + public GeneralCommandLine generateCommandLine() { GeneralCommandLine cmd = super.generateCommandLine(); setWorkingDirectory(cmd); @@ -103,14 +103,11 @@ public abstract class PythonTestCommandLineStateBase extends PythonCommandLineSt } protected void setWorkingDirectory(@NotNull final GeneralCommandLine cmd) { - final String workingDirectory = myConfiguration.getWorkingDirectory(); - if (!StringUtil.isEmptyOrSpaces(workingDirectory)) { - cmd.withWorkDirectory(workingDirectory); - } - else if (myConfiguration instanceof AbstractPythonTestRunConfiguration) { - final AbstractPythonTestRunConfiguration configuration = (AbstractPythonTestRunConfiguration)myConfiguration; - cmd.withWorkDirectory(configuration.getWorkingDirectorySafe()); + String workingDirectory = myConfiguration.getWorkingDirectory(); + if (StringUtil.isEmptyOrSpaces(workingDirectory)) { + workingDirectory = myConfiguration.getWorkingDirectorySafe(); } + cmd.withWorkDirectory(workingDirectory); } @Override @@ -134,10 +131,11 @@ public abstract class PythonTestCommandLineStateBase extends PythonCommandLineSt return executionResult; } - protected void addBeforeParameters(GeneralCommandLine cmd) {} + protected void addBeforeParameters(GeneralCommandLine cmd) {} + protected void addAfterParameters(GeneralCommandLine cmd) {} - protected void addTestRunnerParameters(GeneralCommandLine cmd) { + protected void addTestRunnerParameters(GeneralCommandLine cmd) { ParamsGroup scriptParams = cmd.getParametersList().getParamsGroup(GROUP_SCRIPT); assert scriptParams != null; getRunner().addToGroup(scriptParams, cmd); @@ -153,6 +151,7 @@ public abstract class PythonTestCommandLineStateBase extends PythonCommandLineSt } protected abstract HelperPackage getRunner(); + @NotNull protected abstract List getTestSpecs(); }