подсветка версий с ошибками в журнале

This commit is contained in:
2024-04-07 21:30:11 +03:00
parent 002867274f
commit 8b9400fb95
9 changed files with 125 additions and 66 deletions

View File

@@ -62,7 +62,7 @@ public class Visualiser extends Component {
//http://www.seostella.com/ru/article/2012/02/05/formatirovanie-daty-v-java.html
@Override
public void GetVersionInfo() {
version = 1089;
version = 1090;
String pattern = "MMM dd yyyy HH:mm:ss";
DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
date_text = df.format(getClassBuildTime());

View File

@@ -132,9 +132,9 @@ public class GroupsDBTable extends iDBTable<Group> {
}
return false;
}
public Group getGroupByDescription(String description_in) {
public Group getGroupByDescription(LanguageName language_in,String description_in) {
for (Group group : Data.values()) {
if (group.description.equalsIgnoreCase(description_in))
if (group.language.equals(language_in)&&group.description.equalsIgnoreCase(description_in))
return group;
}
return null;

View File

@@ -100,9 +100,9 @@ public class TestDBTable extends iDBTable<Test> {
}
return false;
}
public Test getTestByDescription(String description_in) {
public Test getTestByDescription(int group_id_in, String description_in) {
for (Test test : Data.values()) {
if (test.description.equalsIgnoreCase(description_in))
if ((test.group_id==group_id_in)&&(test.description.equalsIgnoreCase(description_in)))
return test;
}
return null;

View File

@@ -5,7 +5,6 @@ import Common.Global;
import Common.Utils.Utils;
import GlobalData.Account.Account;
import ProjectData.LanguageName;
import Repository.Component.Sapfor.Sapfor;
import Repository.EmailMessage;
import Repository.RepositoryRefuseException;
import Repository.RepositoryServer;
@@ -299,7 +298,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
throw new RepositoryRefuseException("Не удалось обновить репозиторий");
//-->>
Vector<Pair<Group, Vector<File>>> groups = new Vector<>();
LinkedHashMap<Group, Vector<Test>> res = new LinkedHashMap<>();
File testsSrc = Paths.get(
Global.RepoDirectory.getAbsolutePath(),
"dvm", "tools", "tester", "trunk", "test-suite").toFile();
@@ -338,58 +336,8 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
//-теперь создать тесты.
System.out.println("найдено " + groups.size() + " групп");
//--
for (Pair<Group, Vector<File>> p : groups) {
Group group = p.getKey();
//-
db.Insert(group);
Vector<Test> testsIds = new Vector<>();
res.put(group, testsIds);
//-
Vector<File> files = p.getValue();
if (!files.isEmpty()) {
//->>
for (File file : files) {
System.out.println("Создание теста " + file.getName());
Test test = new Test();
test.description = Utils.getNameWithoutExtension(file.getName()) + "_" + group.language.getDVMCompile();
test.sender_name = account.name;
test.sender_address = account.email;
test.group_id = group.id;
test.files = file.getName();
db.Insert(test);
testsIds.add(test);
//->>
File testDirectory = new File(Global.TestsDirectory, String.valueOf(test.id));
Utils.CheckAndCleanDirectory(testDirectory);
File testFile = Paths.get(testDirectory.getAbsolutePath(), file.getName()).toFile();
FileUtils.copyFile(file, testFile);
//----
//архивация.
File archive = test.getArchive();
ZipFolderPass zip = new ZipFolderPass();
zip.Do(testDirectory.getAbsolutePath(), archive.getAbsolutePath());
//---
//Определение размерности
switch (group.language) {
case fortran:
// временная папка для анализа. чтобы не засорять нормальную.
File tempProject = Utils.getTempFileName("test");
FileUtils.forceMkdir(tempProject);
FileUtils.copyDirectory(testDirectory, tempProject);
//--
if (Sapfor.getMinMaxDim(Sapfor.getTempCopy(new File(sapfor.call_command)), tempProject, test)) {
db.Update(test);
} else
throw new RepositoryRefuseException("Не удалось определить размерность теста " + Utils.Brackets(test.description));
break;
case c:
test.max_dim = Utils.getCTestMaxDim(testFile);
db.Update(test);
break;
}
}
}
}
for (Pair<Group, Vector<File>> p : groups)
db.RefreshGroup(account, sapfor, p);
}
private void GetFirstActiveDVMPackagesByMachines() {
response = new ServerExchangeUnit_2021(ServerCode.OK);

View File

@@ -1,7 +1,14 @@
package TestingSystem.Common;
import Common.Constants;
import Common.Database.SQLITE.SQLiteDatabase;
import Common.Global;
import Common.Utils.Utils;
import GlobalData.Account.Account;
import Repository.Component.Sapfor.Sapfor;
import Repository.RepositoryRefuseException;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Group.GroupsDBTable;
import TestingSystem.Common.Test.Test;
import TestingSystem.Common.Test.TestDBTable;
import TestingSystem.Common.TestingPackageToKill.TestingPackagesToKillDBTable;
import TestingSystem.DVM.Configuration.ConfigurationDBTable;
@@ -12,9 +19,14 @@ import TestingSystem.SAPFOR.SapforConfiguration.SapforConfigurationDBTable;
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommandsDBTable;
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
import TestingSystem.SAPFOR.SapforPackage.SapforPackageDBTable;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapforsDBTable;
import Visual_DVM_2021.Passes.All.ZipFolderPass;
import Visual_DVM_2021.Passes.PassCode_2021;
import javafx.util.Pair;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.LinkedHashMap;
@@ -144,4 +156,78 @@ public class TestsDatabase extends SQLiteDatabase {
}
return res;
}
//--
public void SaveTestFromSingleFile(ServerSapfor sapfor, Group group, Test test, File file) throws Exception {
File testDirectory = new File(Global.TestsDirectory, String.valueOf(test.id));
Utils.CheckAndCleanDirectory(testDirectory);
File testFile = Paths.get(testDirectory.getAbsolutePath(), file.getName()).toFile();
FileUtils.copyFile(file, testFile);
//----
//архивация.
File archive = test.getArchive();
if (archive.exists())
FileUtils.forceDelete(archive);
//----------->>
ZipFolderPass zip = new ZipFolderPass();
zip.Do(testDirectory.getAbsolutePath(), archive.getAbsolutePath());
//---
//Определение размерности
switch (group.language) {
case fortran:
// временная папка для анализа. чтобы не засорять нормальную.
File tempProject = Utils.getTempFileName("test");
FileUtils.forceMkdir(tempProject);
FileUtils.copyDirectory(testDirectory, tempProject);
//--
if (Sapfor.getMinMaxDim(Sapfor.getTempCopy(new File(sapfor.call_command)), tempProject, test)) {
Update(test);
} else
throw new RepositoryRefuseException("Не удалось определить размерность теста " + Utils.Brackets(test.description));
break;
case c:
test.max_dim = Utils.getCTestMaxDim(testFile);
Update(test);
break;
}
}
//---
public void CreateTestFromSingleFile(Account account, ServerSapfor sapfor, Group group, File file, String testDescription) throws Exception {
System.out.println("Создание теста " + file.getName());
Test test = new Test();
test.description = testDescription;
test.sender_name = account.name;
test.sender_address = account.email;
test.group_id = group.id;
test.files = file.getName();
Insert(test);
//->>
SaveTestFromSingleFile(sapfor, group, test, file);
}
public void RefreshGroup(Account account, ServerSapfor sapfor, Pair<Group, Vector<File>> groupData) throws Exception {
Group group = groupData.getKey();
Vector<File> files = groupData.getValue();
//--
Group oldGroup = groups.getGroupByDescription(group.language,group.description);
if (oldGroup == null) {
System.out.println("group "+Utils.Brackets(group.description)+" not found. create.");
Insert(group);
for (File file : files) {
String testDescription = Utils.getNameWithoutExtension(file.getName()) + "_" + group.language.getDVMCompile();
System.out.println("test "+Utils.Brackets(testDescription) + " create"); //добавить тест.
CreateTestFromSingleFile(account, sapfor, group, file, testDescription);
}
} else {
for (File file : files) {
String testDescription = Utils.getNameWithoutExtension(file.getName()) + "_" + group.language.getDVMCompile();
Test oldTest = tests.getTestByDescription(oldGroup.id, testDescription);
if (oldTest == null) {
System.out.println("test "+Utils.Brackets(testDescription) + " not found. create"); //добавить тест.
CreateTestFromSingleFile(account, sapfor, oldGroup, file, testDescription);
} else {
System.out.println(Utils.Brackets(testDescription) + " found. rewrite"); //добавить тест.
SaveTestFromSingleFile(sapfor, group, oldTest, file);
}
}
}
}
}

View File

@@ -2,5 +2,6 @@ package TestingSystem.SAPFOR.Json;
import java.io.Serializable;
public enum SapforVersionState implements Serializable {
Empty, //версия оказалась пуста.
Normal //версия построена
Normal, //версия построена
HasErrors //версия построена, но в журналах есть ошибка.
}

View File

@@ -8,6 +8,7 @@ import ProjectData.Files.ProjectFile;
import ProjectData.LanguageName;
import ProjectData.Messages.Errors.MessageError;
import ProjectData.Project.db_project_info;
import Repository.Component.Sapfor.Sapfor;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import com.google.gson.annotations.Expose;
import org.apache.commons.io.FileUtils;
@@ -76,6 +77,26 @@ public class SapforVersion_json implements Serializable {
parse_err = new ProjectFile(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.parse_err_file).toFile());
out = new ProjectFile(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.out_file).toFile());
err = new ProjectFile(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.err_file).toFile());
//--
Vector<File> files = new Vector<>();
files.add(parse_out.file);
files.add(parse_err.file);
files.add(out.file);
files.add(err.file);
for (File file:files){
try {
if (file.exists()) {
Vector<String> lines = new Vector<>(FileUtils.readLines(file));
if (!Sapfor.checkLines(lines)) {
state = SapforVersionState.HasErrors;
return;
}
}
}
catch (Exception ex){
ex.printStackTrace();
}
}
}
public boolean isMatch(SapforVersion_json version_json) {
if (!description.equals(version_json.description)) {