From 7392dfe9b7cedce0b4e668fc082e3d57c7c18b03 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Wed, 22 Jun 2016 18:41:49 +0300 Subject: [PATCH] PY-19738: Do not rerun tests if we can't get list of specs to rerun When rerun, test task should provide list of test specs to rerun. If it fails to do so, no need to rerun "something". --- python/src/com/jetbrains/python/PyBundle.properties | 2 ++ python/src/com/jetbrains/python/run/PythonRunner.java | 11 +++++++++++ .../testing/PythonTestCommandLineStateBase.java | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/python/src/com/jetbrains/python/PyBundle.properties b/python/src/com/jetbrains/python/PyBundle.properties index 797f0c74f1ec..ee67f7d0e69a 100644 --- a/python/src/com/jetbrains/python/PyBundle.properties +++ b/python/src/com/jetbrains/python/PyBundle.properties @@ -765,6 +765,8 @@ QDOC.module.path.unknown=(Module path is unknown) QDOC.epydoc.python2.sdk.not.found=You need configured Python 2 SDK to render Epydoc docstrings QDOC.sdk.not.found=You need configured Python SDK to render docstrings +runcfg.tests.cant_rerun=Can't rerun tests since test IDs can't be resolved. Try to delete run configuration, and create new one using right click. + ### doctest run conf runcfg.doctest.display_name=Doctests runcfg.doctest.description=Python's doctests run configuration diff --git a/python/src/com/jetbrains/python/run/PythonRunner.java b/python/src/com/jetbrains/python/run/PythonRunner.java index 8509b55bb531..bc5657debf25 100644 --- a/python/src/com/jetbrains/python/run/PythonRunner.java +++ b/python/src/com/jetbrains/python/run/PythonRunner.java @@ -25,7 +25,10 @@ import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.execution.runners.RunContentBuilder; import com.intellij.execution.ui.RunContentDescriptor; import com.intellij.openapi.fileEditor.FileDocumentManager; +import com.jetbrains.python.PyBundle; +import com.jetbrains.python.testing.PythonTestCommandLineStateBase; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author yole @@ -41,12 +44,20 @@ public class PythonRunner extends DefaultProgramRunner { return executorId.equals(DefaultRunExecutor.EXECUTOR_ID) && profile instanceof AbstractPythonRunConfiguration; } + @Nullable @Override protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException { FileDocumentManager.getInstance().saveAllDocuments(); ExecutionResult executionResult; RunProfile profile = env.getRunProfile(); + + if (state instanceof PythonTestCommandLineStateBase) { + if (!((PythonTestCommandLineStateBase)state).isRerunEnabled()) { + throw new ExecutionException(PyBundle.message("runcfg.tests.cant_rerun")); + } + } + if (state instanceof PythonCommandLineState && profile instanceof CommandLinePatcher) { executionResult = ((PythonCommandLineState)state).execute(env.getExecutor(), (CommandLinePatcher)profile); } diff --git a/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java b/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java index f20daa18eb04..90a1c6befdf3 100644 --- a/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java +++ b/python/src/com/jetbrains/python/testing/PythonTestCommandLineStateBase.java @@ -171,4 +171,11 @@ public abstract class PythonTestCommandLineStateBase extends PythonCommandLineSt protected abstract HelperPackage getRunner(); @NotNull protected abstract List getTestSpecs(); + + /** + * @return is it possible to rerun tests now? + */ + public boolean isRerunEnabled() { + return !getTestSpecs().isEmpty(); + } }