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

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 name="ChangeListManager">
<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$/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/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/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/UI/Main/TestingForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Main/TestingForm.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" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -1055,7 +1055,7 @@ public class Utils {
}
return false;
}
//временно.
//временно.
public static int getTestingMaxKernels() {
return 64; // (Current.getAccount().isAdmin()) ? 64 : 14;
}

View File

@@ -1,7 +1,11 @@
package Visual_DVM_2021.Passes.All;
import Common.Current;
import ProjectData.Files.FileState;
import ProjectData.Files.ProjectFile;
import ProjectData.Project.db_project_info;
import Visual_DVM_2021.Passes.PassCode_2021;
public class CreateTestFromCurrentProject extends CreateTestFromDirectory {
db_project_info project;
@Override
public String getIconPath() {
return "/icons/RedAdd.png";
@@ -9,6 +13,7 @@ public class CreateTestFromCurrentProject extends CreateTestFromDirectory {
@Override
protected boolean canStart(Object... args) throws Exception {
if (Current.Check(Log, Current.Group, Current.Project)) {
project = Current.getProject();
return super.canStart(Current.getProject().Home, Current.getGroup());
}
return false;
@@ -17,4 +22,9 @@ public class CreateTestFromCurrentProject extends CreateTestFromDirectory {
protected void performDone() throws Exception {
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.Test.Test;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.Pass_2021;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.Vector;
@@ -54,7 +56,6 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
}
//---
File[] files = dir.listFiles();
project_files = new Vector<>();
int subdirs = 0;
int bad = 0;
int active_programs = 0;
@@ -75,63 +76,55 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
Log.Writeln_("Не удалось получить список файлов для папки " + Utils.Brackets(dir) + ".");
return false;
}
//---
project_files = new Vector<>();
//--
for (File file : files) {
if (!Utils.validateProjectFile(file, Log)) {
Log.Writeln_("Имя файла " + Utils.Brackets(file.getName()) + " содержит запрещённые символы " + Constants.all_forbidden_characters_string + ", или кириллицу.");
bad++;
}
if (file.isDirectory() &&
!file.getName().equalsIgnoreCase(Constants.data) &&
!Utils.isVersion(file)
) {
subdirs++;
}
if (file.isFile()) {
//-----
if (file.isDirectory()) {
//если это подпапка нам все равно на каком она языке. не версия и не служебная. ее наличие уже не допустимо.
if (!file.getName().equalsIgnoreCase(Constants.data) &&
!Utils.isVersion(file)) {
subdirs++;
}
} else if (file.isFile() && !Utils.ContainsCyrillic(file.getName()) && !Utils.ContainsForbiddenName(file.getName())) {
//если файл. все недопустимые файлы просто игнорируются.
ProjectFile projectFile = new ProjectFile(file);
switch (projectFile.fileType) {
case program:
if (projectFile.languageName.equals(group.language)) {
active_programs++;
if (isNotExcluded(projectFile)) {
switch (projectFile.fileType) {
case program:
if (projectFile.languageName.equals(group.language)) {
active_programs++;
project_files.add(projectFile);
} else
other_project_files++;
break;
case header:
headers++;
project_files.add(projectFile);
} else
break;
default:
other_project_files++;
break;
case header:
headers++;
project_files.add(projectFile);
break;
default:
other_project_files++;
break;
break;
}
}
}
}
//--
if (subdirs > 0) {
Log.Writeln_("Папка " + Utils.Brackets(dir) + " содержит вложенные подпапки.");
return false;
}
if (bad > 0) {
Log.Writeln_("Папка " + Utils.Brackets(dir) + " содержит вложенные подпапки,\n" +
"не являющиеся версиями или данными визуализатора");
return false;
}
if (active_programs == 0) {
Log.Writeln_("Папка не содержит ни одной программы на языке " + group.language.getDescription() + ".");
return false;
}
/*
if (other_project_files > 0) {
Log.Writeln_("Папка содержит файлы, не являющиеся программами на языке " +
group.language.getDescription() +
", или заголовочными.");
return false;
}
*/
if (project_files.isEmpty()){
Log.Writeln_("В папке не найдено файлов с допустимыми расширениями для языка "+
group.language.getDescription()+"\n"+
if (project_files.isEmpty()) {
Log.Writeln_("В папке не найдено файлов с допустимыми расширениями для языка " +
group.language.getDescription() + "\n" +
group.language.PrintExtensions()
);
);
}
//-----
target = new Test();
@@ -145,13 +138,39 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
target.files = String.join("\n", filesNames);
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
protected void body() throws Exception {
ShowMessage1(dir.getName());
//--
File tempProject = target.packCode(dir, true); //создание копии папки, и архивация.
File tempProject = packTestCode(); //создание копии папки, и архивация.
//-- получить размерность консольным сапфором. папка уже отправлена и чистить ее не нужно!!
ShowMessage2("Синтаксический анализ и определение размерности");
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;
import TestingSystem.Common.Test.Test;
import Visual_DVM_2021.Passes.Pass_2021;
public class CreateTestFromFile extends Pass_2021 {
public class CreateTestFromFile extends Pass_2021<Test> {
}