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".
This commit is contained in:
Ilya.Kazakevich
2016-06-22 22:08:59 +03:00
parent 82a33b4e56
commit 7392dfe9b7
3 changed files with 20 additions and 0 deletions
@@ -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 <a href='http://epydoc.sourceforge.net/'>Epydoc</a> 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
@@ -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);
}
@@ -171,4 +171,11 @@ public abstract class PythonTestCommandLineStateBase extends PythonCommandLineSt
protected abstract HelperPackage getRunner();
@NotNull
protected abstract List<String> getTestSpecs();
/**
* @return is it possible to rerun tests now?
*/
public boolean isRerunEnabled() {
return !getTestSpecs().isEmpty();
}
}