mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
added option to skip running task file on check action
This commit is contained in:
+16
-2
@@ -3,6 +3,7 @@ package com.jetbrains.edu.learning.checker;
|
||||
import com.intellij.execution.process.CapturingProcessHandler;
|
||||
import com.intellij.execution.process.ProcessOutput;
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -16,6 +17,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.jetbrains.edu.learning.*;
|
||||
import com.jetbrains.edu.learning.actions.StudyAfterCheckAction;
|
||||
import com.jetbrains.edu.learning.actions.StudyRunAction;
|
||||
import com.jetbrains.edu.learning.core.EduNames;
|
||||
import com.jetbrains.edu.learning.core.EduUtils;
|
||||
import com.jetbrains.edu.learning.courseFormat.*;
|
||||
@@ -38,7 +40,9 @@ public class StudyCheckTask extends com.intellij.openapi.progress.Task.Backgroun
|
||||
private final Ref<Boolean> myCheckInProcess;
|
||||
private final Process myTestProcess;
|
||||
private final String myCommandLine;
|
||||
private boolean myRunTestFile = true;
|
||||
private static final String FAILED_CHECK_LAUNCH = "Failed to launch checking";
|
||||
private static final String DO_NOT_RUN_ON_CHECK = "DO_NOT_RUN_ON_CHECK";
|
||||
|
||||
public StudyCheckTask(Project project, StudyState studyState, Ref<Boolean> checkInProcess, Process testProcess, String commandLine) {
|
||||
super(project, "Checking Task");
|
||||
@@ -87,7 +91,9 @@ public class StudyCheckTask extends com.intellij.openapi.progress.Task.Backgroun
|
||||
|
||||
private void checkForEduCourse(@NotNull ProgressIndicator indicator) {
|
||||
final StudyTestsOutputParser.TestsOutput testsOutput = getTestOutput(indicator);
|
||||
|
||||
if (myRunTestFile) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> runTask(myProject));
|
||||
}
|
||||
if (testsOutput != null) {
|
||||
if (testsOutput.isSuccess()) {
|
||||
onTaskSolved(testsOutput.getMessage());
|
||||
@@ -103,6 +109,14 @@ public class StudyCheckTask extends com.intellij.openapi.progress.Task.Backgroun
|
||||
}
|
||||
}
|
||||
|
||||
private static void runTask(@NotNull Project project) {
|
||||
final StudyRunAction runAction = (StudyRunAction)ActionManager.getInstance().getAction(StudyRunAction.ACTION_ID);
|
||||
if (runAction == null) {
|
||||
return;
|
||||
}
|
||||
runAction.run(project);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private StudyTestsOutputParser.TestsOutput getTestOutput(@NotNull ProgressIndicator indicator) {
|
||||
final CapturingProcessHandler handler = new CapturingProcessHandler(myTestProcess, null, myCommandLine);
|
||||
@@ -111,7 +125,7 @@ public class StudyCheckTask extends com.intellij.openapi.progress.Task.Backgroun
|
||||
ApplicationManager.getApplication().invokeLater(
|
||||
() -> StudyCheckUtils.showTestResultPopUp("Check cancelled", MessageType.WARNING.getPopupBackground(), myProject));
|
||||
}
|
||||
|
||||
myRunTestFile = !output.getStdout().contains(DO_NOT_RUN_ON_CHECK);
|
||||
final Course course = StudyTaskManager.getInstance(myProject).getCourse();
|
||||
if (course != null) {
|
||||
final StudyTestsOutputParser.TestsOutput testsOutput = StudyTestsOutputParser.getTestsOutput(output, course.isAdaptive());
|
||||
|
||||
@@ -248,6 +248,13 @@ def check_samples(samples=()):
|
||||
passed()
|
||||
|
||||
|
||||
def do_not_run_on_check():
|
||||
"""
|
||||
Do not execute task file on check
|
||||
"""
|
||||
print("#educational_plugin DO_NOT_RUN_ON_CHECK")
|
||||
|
||||
|
||||
def run_common_tests(error_text="Please, reload file and try again"):
|
||||
test_is_initial_text()
|
||||
test_is_not_empty()
|
||||
|
||||
-14
@@ -1,7 +1,6 @@
|
||||
package com.jetbrains.edu.learning;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -11,7 +10,6 @@ import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.jetbrains.edu.learning.actions.StudyCheckAction;
|
||||
import com.jetbrains.edu.learning.actions.StudyRunAction;
|
||||
import com.jetbrains.edu.learning.checker.StudyCheckTask;
|
||||
import com.jetbrains.edu.learning.checker.StudyCheckUtils;
|
||||
import com.jetbrains.edu.learning.checker.StudyTestRunner;
|
||||
@@ -44,9 +42,6 @@ public class PyStudyCheckAction extends StudyCheckAction {
|
||||
}
|
||||
if (StudyCheckUtils.hasBackgroundProcesses(project)) return;
|
||||
|
||||
final Course course = StudyTaskManager.getInstance(project).getCourse();
|
||||
if (course != null && !course.isAdaptive() && !runTask(project)) return;
|
||||
|
||||
final Task task = studyState.getTask();
|
||||
final VirtualFile taskDir = studyState.getTaskDir();
|
||||
StudyCheckUtils.flushWindows(task, taskDir);
|
||||
@@ -77,15 +72,6 @@ public class PyStudyCheckAction extends StudyCheckAction {
|
||||
}));
|
||||
}
|
||||
|
||||
private static boolean runTask(@NotNull Project project) {
|
||||
final StudyRunAction runAction = (StudyRunAction)ActionManager.getInstance().getAction(StudyRunAction.ACTION_ID);
|
||||
if (runAction == null) {
|
||||
return false;
|
||||
}
|
||||
runAction.run(project);
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private StudyCheckTask getCheckTask(@NotNull final Project project,
|
||||
final StudyState studyState,
|
||||
|
||||
Reference in New Issue
Block a user