PY-21454: Use project dir if directory not provided
authorIlya.Kazakevich <Ilya.Kazakevich@jetbrains.com>
Wed, 16 Nov 2016 15:41:04 +0000 (18:41 +0300)
committerIlya.Kazakevich <Ilya.Kazakevich@jetbrains.com>
Wed, 16 Nov 2016 15:43:26 +0000 (18:43 +0300)
 * 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

python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java

index 470cd7f2134e27f0546783815e16cd39f453677e..d7a9db40811d8e714f3e8b0eb5ca201ad4da5c68 100644 (file)
@@ -89,7 +89,7 @@ public abstract class PythonTestCommandLineStateBase extends PythonCommandLineSt
   }
 
   @Override
   }
 
   @Override
-  public GeneralCommandLine generateCommandLine()  {
+  public GeneralCommandLine generateCommandLine() {
     GeneralCommandLine cmd = super.generateCommandLine();
 
     setWorkingDirectory(cmd);
     GeneralCommandLine cmd = super.generateCommandLine();
 
     setWorkingDirectory(cmd);
@@ -103,14 +103,11 @@ public abstract class PythonTestCommandLineStateBase extends PythonCommandLineSt
   }
 
   protected void setWorkingDirectory(@NotNull final GeneralCommandLine cmd) {
   }
 
   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
   }
 
   @Override
@@ -134,10 +131,11 @@ public abstract class PythonTestCommandLineStateBase extends PythonCommandLineSt
     return executionResult;
   }
 
     return executionResult;
   }
 
-  protected void addBeforeParameters(GeneralCommandLine cmd)  {}
+  protected void addBeforeParameters(GeneralCommandLine cmd) {}
+
   protected void addAfterParameters(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);
     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();
   }
 
   protected abstract HelperPackage getRunner();
+
   @NotNull
   protected abstract List<String> getTestSpecs();
 }
   @NotNull
   protected abstract List<String> getTestSpecs();
 }