fix check utilities
authorLiana.Bakradze <liana.bakradze@jetbrains.com>
Tue, 4 Oct 2016 15:31:34 +0000 (18:31 +0300)
committerliana.bakradze <liana.bakradze@jetbrains.com>
Thu, 17 Nov 2016 14:08:28 +0000 (17:08 +0300)
python/educational-python/course-creator-python/src/com/jetbrains/edu/coursecreator/run/PyCCRunTestsConfigurationProducer.java
python/educational-python/student-python/src/com/jetbrains/edu/learning/PyStudyTestRunner.java

index f58104fb37e2f80ebcfb1bac66d819e2b6ec47f7..c61ecd00d9827e6d11865f4a1341a4f5b1e14878 100644 (file)
@@ -10,6 +10,7 @@ import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.PsiElement;
 import com.jetbrains.edu.coursecreator.CCUtils;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.PsiElement;
 import com.jetbrains.edu.coursecreator.CCUtils;
+import com.jetbrains.edu.coursecreator.PyCCLanguageManager;
 import com.jetbrains.edu.learning.StudyUtils;
 import com.jetbrains.edu.learning.core.EduNames;
 import com.jetbrains.edu.learning.courseFormat.Task;
 import com.jetbrains.edu.learning.StudyUtils;
 import com.jetbrains.edu.learning.core.EduNames;
 import com.jetbrains.edu.learning.courseFormat.Task;
@@ -59,7 +60,12 @@ public class PyCCRunTestsConfigurationProducer extends RunConfigurationProducer<
     if (task == null) {
       return null;
     }
     if (task == null) {
       return null;
     }
-    return task.getLesson().getName() + "/" + task.getName();
+    String generatedName = task.getLesson().getName() + "/" + task.getName();
+    if (task.hasSubtasks()) {
+      int index = task.getActiveSubtaskIndex() + 1;
+      generatedName += " " + index;
+    }
+    return generatedName;
   }
 
   @Nullable
   }
 
   @Nullable
@@ -81,7 +87,7 @@ public class PyCCRunTestsConfigurationProducer extends RunConfigurationProducer<
     if (task == null) {
       return null;
     }
     if (task == null) {
       return null;
     }
-    String testsFileName = EduNames.TESTS_FILE;
+    String testsFileName = PyCCLanguageManager.getSubtaskTestsFileName(task.getActiveSubtaskIndex());
     String taskDirPath = FileUtil.toSystemDependentName(taskDir.getPath());
     String testsPath = taskDir.findChild(EduNames.SRC) != null ?
                        FileUtil.join(taskDirPath, EduNames.SRC, testsFileName) :
     String taskDirPath = FileUtil.toSystemDependentName(taskDir.getPath());
     String testsPath = taskDir.findChild(EduNames.SRC) != null ?
                        FileUtil.join(taskDirPath, EduNames.SRC, testsFileName) :
index f7c64d1099f149e6b843b279321c2c1f869c961a..6ae2fa3d338b4c9d4f884e255bb0f60bac42ba05 100644 (file)
@@ -7,8 +7,10 @@ import com.intellij.openapi.module.ModuleManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.io.FileUtilRt;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.jetbrains.edu.learning.checker.StudyTestRunner;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.jetbrains.edu.learning.checker.StudyTestRunner;
+import com.jetbrains.edu.learning.core.EduNames;
 import com.jetbrains.edu.learning.courseFormat.Course;
 import com.jetbrains.edu.learning.courseFormat.Task;
 import com.jetbrains.python.sdk.PythonSdkType;
 import com.jetbrains.edu.learning.courseFormat.Course;
 import com.jetbrains.edu.learning.courseFormat.Task;
 import com.jetbrains.python.sdk.PythonSdkType;
@@ -35,6 +37,11 @@ public class PyStudyTestRunner extends StudyTestRunner {
     }
 
     String testsFileName = manager.getTestFileName();
     }
 
     String testsFileName = manager.getTestFileName();
+    if (myTask.hasSubtasks()) {
+      testsFileName = FileUtil.getNameWithoutExtension(testsFileName);
+      int index = myTask.getActiveSubtaskIndex() + 1;
+      testsFileName += EduNames.SUBTASK_MARKER + index + "." + FileUtilRt.getExtension(manager.getTestFileName());
+    }
     final File testRunner = new File(myTaskDir.getPath(), testsFileName);
     final GeneralCommandLine commandLine = new GeneralCommandLine();
     commandLine.withWorkDirectory(myTaskDir.getPath());
     final File testRunner = new File(myTaskDir.getPath(), testsFileName);
     final GeneralCommandLine commandLine = new GeneralCommandLine();
     commandLine.withWorkDirectory(myTaskDir.getPath());