пересмотр добавления теста из папки. Теперь, все файлы, не удовлетворяющие критериям, то есть не являющимися программами на языке группы, просто игнорируются. В случае добавления текущего проекта как теста, не будут добавлены исключенные файлы.

This commit is contained in:
2023-12-01 19:31:31 +03:00
parent 10b6cc03ab
commit 7ef2a7540c
5 changed files with 77 additions and 51 deletions

8
.idea/workspace.xml generated
View File

@@ -7,15 +7,11 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment=""> <list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromFile.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/icons/AddFile.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/UI/Menus_2023/TestingBar/TestingBar.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/UI/Menus_2023/TestingBar/TestingBar.java" 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/Common/Utils/Utils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Utils/Utils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ProjectData/LanguageName.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ProjectData/LanguageName.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/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/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/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/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/UI/Main/TestingForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Main/TestingForm.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -1,7 +1,11 @@
package Visual_DVM_2021.Passes.All; package Visual_DVM_2021.Passes.All;
import Common.Current; import Common.Current;
import ProjectData.Files.FileState;
import ProjectData.Files.ProjectFile;
import ProjectData.Project.db_project_info;
import Visual_DVM_2021.Passes.PassCode_2021; import Visual_DVM_2021.Passes.PassCode_2021;
public class CreateTestFromCurrentProject extends CreateTestFromDirectory { public class CreateTestFromCurrentProject extends CreateTestFromDirectory {
db_project_info project;
@Override @Override
public String getIconPath() { public String getIconPath() {
return "/icons/RedAdd.png"; return "/icons/RedAdd.png";
@@ -9,6 +13,7 @@ public class CreateTestFromCurrentProject extends CreateTestFromDirectory {
@Override @Override
protected boolean canStart(Object... args) throws Exception { protected boolean canStart(Object... args) throws Exception {
if (Current.Check(Log, Current.Group, Current.Project)) { if (Current.Check(Log, Current.Group, Current.Project)) {
project = Current.getProject();
return super.canStart(Current.getProject().Home, Current.getGroup()); return super.canStart(Current.getProject().Home, Current.getGroup());
} }
return false; return false;
@@ -17,4 +22,9 @@ public class CreateTestFromCurrentProject extends CreateTestFromDirectory {
protected void performDone() throws Exception { protected void performDone() throws Exception {
passes.get(PassCode_2021.PublishTest).Do(target); passes.get(PassCode_2021.PublishTest).Do(target);
} }
@Override
public boolean isNotExcluded(ProjectFile projectFile) {
return project.db.files.containsKey(projectFile.file.getName()) &&
!project.db.files.get(projectFile.file.getName()).state.equals(FileState.Excluded);
}
} }

View File

@@ -10,7 +10,9 @@ import Repository.Component.Sapfor.Sapfor;
import TestingSystem.Common.Group.Group; import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Test.Test; import TestingSystem.Common.Test.Test;
import Visual_DVM_2021.Passes.PassCode_2021; import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.Pass_2021; import Visual_DVM_2021.Passes.Pass_2021;
import org.apache.commons.io.FileUtils;
import java.io.File; import java.io.File;
import java.util.Vector; import java.util.Vector;
@@ -54,7 +56,6 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
} }
//--- //---
File[] files = dir.listFiles(); File[] files = dir.listFiles();
project_files = new Vector<>();
int subdirs = 0; int subdirs = 0;
int bad = 0; int bad = 0;
int active_programs = 0; int active_programs = 0;
@@ -75,20 +76,21 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
Log.Writeln_("Не удалось получить список файлов для папки " + Utils.Brackets(dir) + "."); Log.Writeln_("Не удалось получить список файлов для папки " + Utils.Brackets(dir) + ".");
return false; return false;
} }
//---
project_files = new Vector<>();
//-- //--
for (File file : files) { for (File file : files) {
if (!Utils.validateProjectFile(file, Log)) { //-----
Log.Writeln_("Имя файла " + Utils.Brackets(file.getName()) + " содержит запрещённые символы " + Constants.all_forbidden_characters_string + ", или кириллицу."); if (file.isDirectory()) {
bad++; //если это подпапка нам все равно на каком она языке. не версия и не служебная. ее наличие уже не допустимо.
} if (!file.getName().equalsIgnoreCase(Constants.data) &&
if (file.isDirectory() && !Utils.isVersion(file)) {
!file.getName().equalsIgnoreCase(Constants.data) &&
!Utils.isVersion(file)
) {
subdirs++; subdirs++;
} }
if (file.isFile()) { } else if (file.isFile() && !Utils.ContainsCyrillic(file.getName()) && !Utils.ContainsForbiddenName(file.getName())) {
//если файл. все недопустимые файлы просто игнорируются.
ProjectFile projectFile = new ProjectFile(file); ProjectFile projectFile = new ProjectFile(file);
if (isNotExcluded(projectFile)) {
switch (projectFile.fileType) { switch (projectFile.fileType) {
case program: case program:
if (projectFile.languageName.equals(group.language)) { if (projectFile.languageName.equals(group.language)) {
@@ -107,29 +109,20 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
} }
} }
} }
}
//-- //--
if (subdirs > 0) { if (subdirs > 0) {
Log.Writeln_("Папка " + Utils.Brackets(dir) + " содержит вложенные подпапки."); Log.Writeln_("Папка " + Utils.Brackets(dir) + " содержит вложенные подпапки,\n" +
return false; "не являющиеся версиями или данными визуализатора");
}
if (bad > 0) {
return false; return false;
} }
if (active_programs == 0) { if (active_programs == 0) {
Log.Writeln_("Папка не содержит ни одной программы на языке " + group.language.getDescription() + "."); Log.Writeln_("Папка не содержит ни одной программы на языке " + group.language.getDescription() + ".");
return false; return false;
} }
/* if (project_files.isEmpty()) {
if (other_project_files > 0) { Log.Writeln_("В папке не найдено файлов с допустимыми расширениями для языка " +
Log.Writeln_("Папка содержит файлы, не являющиеся программами на языке " + group.language.getDescription() + "\n" +
group.language.getDescription() +
", или заголовочными.");
return false;
}
*/
if (project_files.isEmpty()){
Log.Writeln_("В папке не найдено файлов с допустимыми расширениями для языка "+
group.language.getDescription()+"\n"+
group.language.PrintExtensions() group.language.PrintExtensions()
); );
} }
@@ -145,13 +138,39 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
target.files = String.join("\n", filesNames); target.files = String.join("\n", filesNames);
return true; return true;
} }
protected void fillProjectFiles() throws Exception { public boolean isNotExcluded(ProjectFile projectFile) {
return true;
} }
//-
public File packTestCode() throws Exception {
target.temp_project_name = Utils.getDateName("test");
//-
File tempProject = target.getTempProject();
File tempArchive = target.getTempArchive();
//- создать бд.
FileUtils.forceMkdir(tempProject);
//--
for (ProjectFile projectFile : project_files) {
System.out.println(projectFile.file.getAbsolutePath());
File dst = new File(tempProject, projectFile.file.getName());
FileUtils.copyFile(projectFile.file, dst);
}
//---
Utils.ClearProjectData(tempProject);
//--
ZipFolderPass zip = new ZipFolderPass();
if (zip.Do(tempProject.getAbsolutePath(), tempArchive.getAbsolutePath())) {
target.project_archive_bytes = Utils.packFile(tempArchive);
} else throw new PassException("Не удалось создать архив папки с кодом.");
return tempProject;
}
//-
@Override @Override
protected void body() throws Exception { protected void body() throws Exception {
ShowMessage1(dir.getName()); ShowMessage1(dir.getName());
//-- //--
File tempProject = target.packCode(dir, true); //создание копии папки, и архивация. File tempProject = packTestCode(); //создание копии папки, и архивация.
//-- получить размерность консольным сапфором. папка уже отправлена и чистить ее не нужно!! //-- получить размерность консольным сапфором. папка уже отправлена и чистить ее не нужно!!
ShowMessage2("Синтаксический анализ и определение размерности"); ShowMessage2("Синтаксический анализ и определение размерности");
if (group.language.equals(LanguageName.fortran) && !Sapfor.getMinMaxDim(Sapfor.getTempCopy(Current.getSapfor().getFile()), tempProject, target)) if (group.language.equals(LanguageName.fortran) && !Sapfor.getMinMaxDim(Sapfor.getTempCopy(Current.getSapfor().getFile()), tempProject, target))

View File

@@ -1,4 +1,5 @@
package Visual_DVM_2021.Passes.All; package Visual_DVM_2021.Passes.All;
import TestingSystem.Common.Test.Test;
import Visual_DVM_2021.Passes.Pass_2021; import Visual_DVM_2021.Passes.Pass_2021;
public class CreateTestFromFile extends Pass_2021 { public class CreateTestFromFile extends Pass_2021<Test> {
} }