доделал создание тестов из версий дерева версий. тоже включил учет исключенных файлов.
This commit is contained in:
9
.idea/workspace.xml
generated
9
.idea/workspace.xml
generated
@@ -8,10 +8,13 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Common/Utils/Utils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Utils/Utils.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromCurrentProject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromCurrentProject.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Common/UI/Menus_2023/TestsMenuBar/TestsMenuBar.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/UI/Menus_2023/TestsMenuBar/TestsMenuBar.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/Test/Test.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/Test/Test.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromCurrentProject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromProject.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromDirectory.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromDirectory.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromFile.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromFile.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestsGroupFromSelectedVersions.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestsGroupFromSelectedVersions.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PublishTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PublishTests.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
||||
@@ -5,7 +5,7 @@ public class TestsMenuBar extends DataMenuBar {
|
||||
public TestsMenuBar() {
|
||||
super("тесты",
|
||||
//PassCode_2021.PublishTest,
|
||||
PassCode_2021.CreateTestFromCurrentProject,
|
||||
PassCode_2021.CreateTestFromProject,
|
||||
PassCode_2021.CreateTestFromDirectory,
|
||||
PassCode_2021.EditTest,
|
||||
PassCode_2021.DownloadTest,
|
||||
|
||||
@@ -13,7 +13,6 @@ import ProjectData.LanguageName;
|
||||
import Repository.RepositoryRefuseException;
|
||||
import Visual_DVM_2021.Passes.All.UnzipFolderPass;
|
||||
import Visual_DVM_2021.Passes.All.ZipFolderPass;
|
||||
import Visual_DVM_2021.Passes.PassException;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
@@ -21,10 +20,10 @@ import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class Test extends riDBObject {
|
||||
@Description("DEFAULT 1")
|
||||
public int min_dim = 1; //мин размерность теста.
|
||||
@Description("DEFAULT 1")
|
||||
public int max_dim = 1; //макс размерность теста.
|
||||
@Description("DEFAULT 0")
|
||||
public int min_dim = 0; //мин размерность теста.
|
||||
@Description("DEFAULT 0")
|
||||
public int max_dim = 0; //макс размерность теста.
|
||||
@Description("DEFAULT ''")
|
||||
public String args = ""; //аргументы командной строки. на всякий случай поле зарезервирую. пусть будут.
|
||||
@Description("DEFAULT -1")
|
||||
@@ -80,37 +79,6 @@ public class Test extends riDBObject {
|
||||
public File getTempProject() {
|
||||
return new File(Global.TempDirectory, temp_project_name);
|
||||
}
|
||||
//--
|
||||
public File packCode(File dir, boolean create_archive) throws Exception {
|
||||
temp_project_name = Utils.getDateName("test");
|
||||
//-
|
||||
File tempProject = getTempProject();
|
||||
File tempArchive = getTempArchive();
|
||||
//- создать бд.
|
||||
FileUtils.forceMkdir(tempProject);
|
||||
File[] files = dir.listFiles();
|
||||
if (files == null)
|
||||
throw new PassException("Не удалось получить список файлов папки " + Utils.Brackets(dir));
|
||||
//--
|
||||
//предполагается, что тут уже нет вложенных подпапок кроме версий. поэтому копируем только файлы.
|
||||
for (File file : files) {
|
||||
if (file.isFile()) {
|
||||
System.out.println(file.getAbsolutePath());
|
||||
File dst = new File(tempProject, file.getName());
|
||||
FileUtils.copyFile(file, dst);
|
||||
}
|
||||
}
|
||||
//---
|
||||
Utils.ClearProjectData(tempProject);
|
||||
//--
|
||||
if (create_archive) {
|
||||
ZipFolderPass zip = new ZipFolderPass();
|
||||
if (zip.Do(tempProject.getAbsolutePath(), tempArchive.getAbsolutePath())) {
|
||||
project_archive_bytes = Utils.packFile(tempArchive);
|
||||
} else throw new PassException("Не удалось создать архив папки с кодом.");
|
||||
}
|
||||
return tempProject;
|
||||
}
|
||||
public boolean unpackProjectOnServer() throws Exception {
|
||||
File tmpArchive = new File(Global.TempDirectory, temp_project_name + ".zip");
|
||||
File tmpProject = new File(Global.TempDirectory, temp_project_name);
|
||||
|
||||
@@ -90,12 +90,16 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
|
||||
} else if (file.isFile() && !Utils.ContainsCyrillic(file.getName()) && !Utils.ContainsForbiddenName(file.getName())) {
|
||||
//если файл. все недопустимые файлы просто игнорируются.
|
||||
ProjectFile projectFile = new ProjectFile(file);
|
||||
System.out.println(projectFile.file);
|
||||
System.out.println("1");
|
||||
if (isNotExcluded(projectFile)) {
|
||||
System.out.println("1.5");
|
||||
switch (projectFile.fileType) {
|
||||
case program:
|
||||
if (projectFile.languageName.equals(group.language)) {
|
||||
active_programs++;
|
||||
project_files.add(projectFile);
|
||||
System.out.println("2");
|
||||
} else
|
||||
other_project_files++;
|
||||
break;
|
||||
@@ -158,7 +162,6 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
|
||||
//---
|
||||
Utils.ClearProjectData(tempProject);
|
||||
//--
|
||||
|
||||
ZipFolderPass zip = new ZipFolderPass();
|
||||
if (zip.Do(tempProject.getAbsolutePath(), tempArchive.getAbsolutePath())) {
|
||||
target.project_archive_bytes = Utils.packFile(tempArchive);
|
||||
@@ -173,8 +176,9 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
|
||||
File tempProject = packTestCode(); //создание копии папки, и архивация.
|
||||
//-- получить размерность консольным сапфором. папка уже отправлена и чистить ее не нужно!!
|
||||
ShowMessage2("Синтаксический анализ и определение размерности");
|
||||
if (group.language.equals(LanguageName.fortran) && !Sapfor.getMinMaxDim(Sapfor.getTempCopy(Current.getSapfor().getFile()), tempProject, target))
|
||||
Log.Writeln_("Не удалось определить размерность теста " + Utils.Brackets(tempProject.getName()));
|
||||
if (group.language == LanguageName.fortran) {//если не определит, будут нули.
|
||||
Sapfor.getMinMaxDim(Sapfor.getTempCopy(Current.getSapfor().getFile()), tempProject, target);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected boolean validate() {
|
||||
|
||||
@@ -3,8 +3,9 @@ import Common.Current;
|
||||
import ProjectData.Files.FileState;
|
||||
import ProjectData.Files.ProjectFile;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import TestingSystem.Common.Group.Group;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class CreateTestFromCurrentProject extends CreateTestFromDirectory {
|
||||
public class CreateTestFromProject extends CreateTestFromDirectory {
|
||||
db_project_info project;
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
@@ -12,10 +13,20 @@ public class CreateTestFromCurrentProject extends CreateTestFromDirectory {
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
if (Current.Check(Log, Current.Group, Current.Project)) {
|
||||
project = Current.getProject();
|
||||
from_directory_chooser = true;
|
||||
return super.canStart(Current.getProject().Home, Current.getGroup());
|
||||
}
|
||||
} else {
|
||||
project = (db_project_info) args[0];
|
||||
group = (Group) args[1];
|
||||
from_directory_chooser = false;
|
||||
project.Open();
|
||||
project.Close();
|
||||
return super.canStart(project.Home, group);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@@ -1,7 +1,10 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.UI.UI;
|
||||
import Common.Utils.Utils;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.PublishTests;
|
||||
|
||||
import java.util.Vector;
|
||||
@@ -20,7 +23,18 @@ public class CreateTestsGroupFromSelectedVersions extends PublishTests {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected boolean findFiles() {
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
if (!Current.getAccount().CheckRegistered(Log))
|
||||
return false;
|
||||
//---
|
||||
target = new Vector<>();
|
||||
//--------------------------
|
||||
group = null;
|
||||
if (!getGroup()) return false;
|
||||
if (group == null) {
|
||||
Log.Writeln_("Группа не выбрана.");
|
||||
return false;
|
||||
}
|
||||
if (!Global.versions_multiselection) {
|
||||
Log.Writeln_("Нажмите правую клавишу мыши, и перейдите в режим выбора версий.");
|
||||
return false;
|
||||
@@ -31,14 +45,20 @@ public class CreateTestsGroupFromSelectedVersions extends PublishTests {
|
||||
Log.Writeln_("Не отмечено ни одной версии.");
|
||||
return false;
|
||||
}
|
||||
for (db_project_info version : versions)
|
||||
files.add(version.Home);
|
||||
return true;
|
||||
//---
|
||||
CreateTestFromProject createTestFromProject = (CreateTestFromProject) passes.get(PassCode_2021.CreateTestFromProject);
|
||||
//---
|
||||
for (db_project_info version : versions) {
|
||||
if (createTestFromProject.Do(version, group))
|
||||
target.add(createTestFromProject.target);
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
if (!Current.getAccount().CheckRegistered(Log))
|
||||
//---
|
||||
if (target.isEmpty()) {
|
||||
Log.Writeln_("Не удалось создать ни одного теста.");
|
||||
return false;
|
||||
return super.canStart(args);
|
||||
}
|
||||
//---
|
||||
return UI.Question("В группу " + Utils.Brackets(group.description) +
|
||||
"\nбудет добавлено " + target.size() + " тестов.\nПродолжить");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ public enum PassCode_2021 {
|
||||
//--
|
||||
CreateGroupFromDirectory,
|
||||
CreateTestFromDirectory,
|
||||
CreateTestFromCurrentProject,
|
||||
CreateTestFromProject,
|
||||
SPF_RemoveComments,
|
||||
CreateTestFromFile,
|
||||
//->
|
||||
@@ -312,7 +312,7 @@ public enum PassCode_2021 {
|
||||
return "Создать тест из файла";
|
||||
case SPF_RemoveComments:
|
||||
return "Удаление комментариев";
|
||||
case CreateTestFromCurrentProject:
|
||||
case CreateTestFromProject:
|
||||
return "Создать тест из текущего проекта";
|
||||
case CreateTestFromDirectory:
|
||||
return "Создать тест из папки";
|
||||
|
||||
@@ -23,7 +23,7 @@ public abstract class PublishTests extends TestingSystemPass<Vector<Test>> {
|
||||
protected Group group;
|
||||
protected Vector<File> files;
|
||||
protected abstract boolean getGroup();
|
||||
protected abstract boolean findFiles();
|
||||
protected boolean findFiles(){ return false;}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
target = new Vector<>();
|
||||
|
||||
Reference in New Issue
Block a user