no message

This commit is contained in:
2023-11-17 00:04:21 +03:00
parent 1ff88fc5fb
commit beb1359544
132 changed files with 617 additions and 591 deletions

View File

@@ -0,0 +1,14 @@
package TestingSystem.SAPFOR.Json;
import Visual_DVM_2021.Passes.PassCode_2021;
import com.google.gson.annotations.Expose;
import java.util.List;
import java.util.Vector;
public class SapforConfiguration_json {
@Expose
public String id = "";
@Expose
public String flags = "";
@Expose
public List<PassCode_2021> codes = new Vector<>();
}

View File

@@ -0,0 +1,15 @@
package TestingSystem.SAPFOR.Json;
import com.google.gson.annotations.Expose;
import java.util.List;
import java.util.Vector;
public class SapforTasksPackage_json {
@Expose
public int kernels = 1;
@Expose
public String sapfor_drv = ""; //файл с сапфором. Имя уникально для сценария.
@Expose
public List<SapforTest_json> tests = new Vector<>();
@Expose
public List<SapforConfiguration_json> configurations = new Vector<>();
}

View File

@@ -0,0 +1,266 @@
package TestingSystem.SAPFOR.Json;
import Common.Utils.Utils;
import GlobalData.Tasks.TaskState;
import TestingSystem.SAPFOR.SapforTask.MatchState;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
import TestingSystem.SAPFOR.SapforTasksPackage.UI.*;
import com.google.gson.annotations.Expose;
import javax.swing.tree.DefaultMutableTreeNode;
import java.io.File;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Vector;
public class SapforTasksResults_json {
//---
public PackageSummary root = null;
public PackageSummary comparison_root = null;
//---
@Expose
public long StartDate = 0;
@Expose
public long EndDate = 0;
@Expose
public List<SapforTask> tasks = new Vector<>();
//все задачи по ключам.
public LinkedHashMap<String, SapforTask> allTasks = new LinkedHashMap<>();
public LinkedHashMap<TaskState, LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>>> sortedTasks = new LinkedHashMap<>();
//-- задачи, отсортированные для сравнения.
public LinkedHashMap<MatchState, LinkedHashMap<TaskState, LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>>>> comparisonSortedTasks = new LinkedHashMap<>();
//----
public void buildTree(SapforTasksPackage package_in) {
root = new PackageSummary();
//---
for (TaskState state : sortedTasks.keySet()) {
//--
StateSummary stateSummary = new StateSummary(state);
//--
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByConfigurations = sortedTasks.get(state);
for (String configuration_id : tasksByConfigurations.keySet()) {
//--
DefaultMutableTreeNode configurationNode = null;
//--
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = tasksByConfigurations.get(configuration_id);
for (String group : groups_tasks.keySet()) {
//--
GroupSummary groupSummary = new GroupSummary(group);
//--
for (SapforTask task : groups_tasks.get(group)) {
//--
stateSummary.count++;
root.count++;
//--
if (configurationNode == null) {
configurationNode = new ConfigurationSummary(configuration_id, task);
}
//--
groupSummary.add(task.getVersionsTree(new File(package_in.getLocalWorkspace(), configuration_id)));
}
if (configurationNode != null)
configurationNode.add(groupSummary);
}
stateSummary.add(configurationNode);
}
if (stateSummary.count > 0) {
root.add(stateSummary);
}
}
}
public void buildComparisonTree(SapforTasksPackage package_in) {
comparison_root = new PackageSummary();
for (MatchState match_state : comparisonSortedTasks.keySet()) {
//--
MatchesSummary matchesSummary = new MatchesSummary(match_state);
//---
LinkedHashMap<TaskState, LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>>> task_states = comparisonSortedTasks.get(match_state);
//---
for (TaskState state : task_states.keySet()) {
//--
StateSummary stateSummary = new StateSummary(state);
//--
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByConfigurations = task_states.get(state);
for (String configuration_id : tasksByConfigurations.keySet()) {
//--
DefaultMutableTreeNode configurationNode = null;
//--
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = tasksByConfigurations.get(configuration_id);
for (String group : groups_tasks.keySet()) {
//--
GroupSummary groupSummary = new GroupSummary(group);
//--
for (SapforTask task : groups_tasks.get(group)) {
//--
stateSummary.count++;
matchesSummary.count++;
comparison_root.count++;
//--
if (configurationNode == null) {
configurationNode = new ConfigurationSummary(configuration_id, task);
}
//--
groupSummary.add(task.getVersionsTree(new File(package_in.getLocalWorkspace(), configuration_id)));
}
if (configurationNode != null)
configurationNode.add(groupSummary);
}
stateSummary.add(configurationNode);
}
if (stateSummary.count > 0) {
matchesSummary.add(stateSummary);
}
}
//---
if (matchesSummary.count > 0) {
comparison_root.add(matchesSummary);
}
}
}
//----
public void SortTasks() {
sortedTasks.clear();
//--
for (TaskState state : TaskState.values()) {
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> configuration_tasks = new LinkedHashMap<>();
sortedTasks.put(state, configuration_tasks);
//--
for (SapforTask task : tasks) {
if (task.state.equals(state)) {
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = null;
if (configuration_tasks.containsKey(task.sapfor_configuration_id)) {
groups_tasks = configuration_tasks.get(task.sapfor_configuration_id);
} else {
groups_tasks = new LinkedHashMap<>();
configuration_tasks.put(task.sapfor_configuration_id, groups_tasks);
}
Vector<SapforTask> tasks_ = null;
if (groups_tasks.containsKey(task.group_description)) {
tasks_ = groups_tasks.get(task.group_description);
} else {
tasks_ = new Vector<>();
groups_tasks.put(task.group_description, tasks_);
}
tasks_.add(task);
}
}
//--
}
//--
for (TaskState state : TaskState.values()) {
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> configuration_tasks = sortedTasks.get(state);
for (String configuration_id : configuration_tasks.keySet()) {
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = configuration_tasks.get(configuration_id);
for (String group : groups_tasks.keySet()) {
Vector<SapforTask> tasks_ = groups_tasks.get(group);
tasks_.sort(Comparator.comparing(SapforTask::getUniqueKey));
}
}
}
}
public void SortTasksForComparison() {
comparisonSortedTasks.clear();
//раскидать задачи по состояниям, конфигам, группам
for (MatchState matchState : MatchState.values()) {
LinkedHashMap<TaskState, LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>>> state_tasks = new LinkedHashMap<>();
comparisonSortedTasks.put(matchState, state_tasks);
//--
for (TaskState state : TaskState.values()) {
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> configuration_tasks = new LinkedHashMap<>();
state_tasks.put(state, configuration_tasks);
//--
for (SapforTask task : tasks) {
if (task.match.equals(matchState) && task.state.equals(state)) {
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = null;
if (configuration_tasks.containsKey(task.sapfor_configuration_id)) {
groups_tasks = configuration_tasks.get(task.sapfor_configuration_id);
} else {
groups_tasks = new LinkedHashMap<>();
configuration_tasks.put(task.sapfor_configuration_id, groups_tasks);
}
Vector<SapforTask> tasks = null;
if (groups_tasks.containsKey(task.group_description)) {
tasks = groups_tasks.get(task.group_description);
} else {
tasks = new Vector<>();
groups_tasks.put(task.group_description, tasks);
}
tasks.add(task);
}
}
}
//--
}
//рассортировать задачи в группах по ключам.
for (MatchState matchState : MatchState.values()) {
LinkedHashMap<TaskState, LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>>> state_tasks = comparisonSortedTasks.get(matchState);
for (TaskState state : TaskState.values()) {
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> configuration_tasks = state_tasks.get(state);
for (String configuration_id : configuration_tasks.keySet()) {
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = configuration_tasks.get(configuration_id);
for (String group : groups_tasks.keySet()) {
Vector<SapforTask> tasks_ = groups_tasks.get(group);
tasks_.sort(Comparator.comparing(SapforTask::getUniqueKey));
}
}
}
}
}
public void DropComparison(){
comparison_root = null;
comparisonSortedTasks.clear();
for (SapforTask task : allTasks.values())
task.match = MatchState.NotMatch;
}
//---
public String getEmailSummary() {
String res = "";
Vector<String> summary_lines = new Vector<>();
summary_lines.add("Всего задач: " + tasks.size());
for (TaskState state : sortedTasks.keySet()) {
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByConfigurations = sortedTasks.get(state);
if (!tasksByConfigurations.isEmpty()) {
int count = 0;
if (!state.equals(TaskState.Done)) {
Vector<String> flagsLines = new Vector<>();
for (String configuration_id : tasksByConfigurations.keySet()) {
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByConfigurations.get(configuration_id);
for (String group : tasksByGroups.keySet()) {
Vector<SapforTask> tasks = tasksByGroups.get(group);
flagsLines.add("Группа " + group + ": " + tasks.size());
count += tasks.size();
for (SapforTask task : tasks) {
task.versionsDescription = task.getVersionsChain();
flagsLines.add(
"тест: " +
Utils.Brackets(task.test_description) + " " +
"флаги: "
+ Utils.Brackets(task.flags) + " " +
"версии: " +
task.versionsDescription
// + " " + "конфигурация " + task.sapfor_configuration_id
);
}
}
}
summary_lines.add(state.getDescription() + " :" + count);
summary_lines.addAll(flagsLines);
} else {
for (String flags : tasksByConfigurations.keySet()) {
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByConfigurations.get(flags);
for (String group : tasksByGroups.keySet()) {
Vector<SapforTask> tasks = tasksByGroups.get(group);
for (SapforTask task : tasks)
task.versionsDescription = task.getVersionsChain();
count += tasks.size();
}
}
summary_lines.add(state.getDescription() + " :" + count);
}
}
}
res = String.join("\n", summary_lines);
return res;
}
//---
}

View File

@@ -0,0 +1,8 @@
package TestingSystem.SAPFOR.Json;
import com.google.gson.annotations.Expose;
public class SapforTest_json {
@Expose
public String test_description = "";
@Expose
public String group_description = "";
}

View File

@@ -0,0 +1,287 @@
package TestingSystem.SAPFOR.Json;
import Common.Constants;
import Common.Global;
import Common.Utils.Utils;
import ProjectData.Files.DBProjectFile;
import ProjectData.Files.FileType;
import ProjectData.Files.ProjectFile;
import ProjectData.LanguageName;
import ProjectData.Messages.Errors.MessageError;
import ProjectData.Project.db_project_info;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import com.google.gson.annotations.Expose;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.nio.file.Paths;
import java.util.LinkedHashMap;
import java.util.Vector;
import static java.lang.Character.isDigit;
public class SapforVersion_json implements Serializable {
@Expose
public String version = "";
@Expose
public String description = "";
public boolean success = true;
//поля для отображения деревьев.
public File Home = null;
public LinkedHashMap<String, ProjectFile> files = new LinkedHashMap<>();
//--
public ProjectFile parse_out = null;
public ProjectFile parse_err = null;
public ProjectFile out = null;
public ProjectFile err = null;
//--
public SapforTask task = null; //родная задача. Нужна для построения дерева версий.
public db_project_info project = null;
//--
public SapforVersion_json(String version_in, String description_in) {
version = version_in;
description = description_in;
}
public SapforVersion_json(String root_in, String version_in, String description_in) {
version = version_in.substring(root_in.length() + 1);
description = description_in;
}
@Override
public String toString() {
return Home.getName() + " : " + Utils.Brackets(description);
}
public void init(File configurationRoot) {
String relativePath = Global.isWindows ? Utils.toW(version) : version;
Home = Paths.get(configurationRoot.getAbsolutePath(), relativePath).toFile();
files = new LinkedHashMap<>();
//--
File[] files_ = Home.listFiles();
if (files_ != null) {
for (File file : files_) {
if (file.isFile()) {
ProjectFile projectFile = new ProjectFile(file);
if (!projectFile.fileType.equals(FileType.forbidden)
) {
files.put(projectFile.file.getName(), projectFile);
}
}
}
}
parse_out = new ProjectFile(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.parse_out_file).toFile());
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());
}
public boolean isMatch(SapforVersion_json version_json) {
if (!description.equals(version_json.description)) {
System.out.println("не совпадение описания версии");
return false;
}
if (files.size() != version_json.files.size()) {
System.out.println("не совпадение количества файлов");
return false;
}
for (String name1 : files.keySet()) {
if (!version_json.files.containsKey(name1)) {
System.out.println("Файл " + Utils.Brackets(name1) + " не найден в версии " + version_json.Home);
return false;
}
}
for (String name1 : files.keySet()) {
ProjectFile file1 = files.get(name1);
ProjectFile file2 = version_json.files.get(name1);
//---
String text1 = "";
String text2 = "";
try {
text1 = FileUtils.readFileToString(file1.file, Charset.defaultCharset());
} catch (Exception ex) {
ex.printStackTrace();
}
try {
text2 = FileUtils.readFileToString(file2.file, Charset.defaultCharset());
} catch (Exception ex) {
ex.printStackTrace();
}
if (!text1.equals(text2)) {
System.out.println("различие текста файла " + Utils.Brackets(file1.file.getName()));
return false;
}
}
return true;
}
public MessageError unpackMessage(String line_in) throws Exception {
MessageError res = new MessageError();
res.file = "";
res.line = Constants.Nan;
res.value = "";
String line = line_in.substring(9);
//System.out.println(line);
int i = 0;
int s = 0;
String lexeme = "";
//#1020: red43.fdv: line 988]: Active DVM directives are not supported (turn on DVM-directive support option)
for (char c : line.toCharArray()) {
// System.out.print("<s=" + s + ">");
// System.out.println(c);
switch (s) {
case 0:
//поиск groups_s
if (c == '#') {
s = 1;
lexeme = "";
} else return null;
break;
case 1:
//group_s
if (isDigit(c)) {
res.group_s += c;
lexeme += c;
} else if (c == ':') {
s = 2;
res.group = Integer.parseInt(lexeme);
} else return null;
break;
case 2:
//поиск filename
if (c == ' ') {
s = 3;
} else return null;
break;
case 3:
//filename
if (c == ':') {
s = 4;
} else {
res.file += c;
}
break;
case 4:
//поиск line
if (c == ' ') {
s = 5;
lexeme = "";
} else return null;
break;
case 5:
//line
if (c == ' ') {
if (!lexeme.equals("line"))
return null;
else {
s = 6;
lexeme = "";
}
} else {
lexeme += c;
}
break;
case 6:
//line number
if (isDigit(c)) {
lexeme += c;
} else if (c == ']') {
res.line = Integer.parseInt(lexeme);
s = 7;
} else return null;
break;
case 7:
//Поиск value
if (c == ':') {
s = 8;
} else return null;
break;
case 8:
if (c == ' ') {
s = 9;
} else return null;
break;
case 9:
//value
res.value += c;
break;
}
;
++i;
}
//--
if (s != 9)
return null;
//--
return res;
}
public void readMessagesFromFileDump(File file, Vector<MessageError> messages) {
try {
//Образец запакованного сообщения
//ERROR - [#1020: red43.fdv: line 988]: Active DVM directives are not supported (turn on DVM-directive support option)
Vector<String> lines = new Vector<>(FileUtils.readLines(file));
if (!lines.isEmpty()) {
for (int i = lines.size() - 1; i >= 0; --i) {
String line = lines.get(i);
if (line.startsWith("ERROR - ")) {
MessageError message = unpackMessage(line);
if (message != null)
messages.add(message);
//--
} else break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
//--
public void createProject(File rootHome) throws Exception {
project = null;
String version_ = Global.isWindows ? Utils.toW(version) : Utils.toU(version);
project = new db_project_info();
project.Home = Paths.get(rootHome.getAbsolutePath(), version_).toFile();
project.name = project.Home.getName();
project.description = description;
project.languageName = LanguageName.fortran;
project.creationDate = Utils.getDateNumber();
//---
FileUtils.copyDirectory(Home, project.Home);
///--------------------------------------
project.CreateVisualiserData();
}
public void ReadMessages() throws Exception {
if (project != null) {
Vector<MessageError> messages = new Vector<>();
//--
File p_out = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.parse_out_file).toFile();
File p_err = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.parse_err_file).toFile();
File out = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.out_file).toFile();
File err = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.err_file).toFile();
//--
if (p_out.exists()) {
project.Log += (FileUtils.readFileToString(p_out));
readMessagesFromFileDump(p_out, messages);
}
if (out.exists()) {
project.Log += "\n" + FileUtils.readFileToString(out);
readMessagesFromFileDump(out, messages);
}
//в потоки ошибок идет информация от операционной системы. сообщений там быть не должно.
if (p_err.exists())
project.Log += (FileUtils.readFileToString(p_err));
if (err.exists())
project.Log += "\n" + FileUtils.readFileToString(err);
//--
project.Open();
project.Update(); //Журнал
//а так же, убрать dep и txt
project.db.BeginTransaction();
for (MessageError m : messages) {
if (project.db.files.containsKey(m.file)) {
DBProjectFile file = project.db.files.Data.get(m.file);
file.CreateAndAddNewMessage(1, m.value, m.line, m.group);
//update file
project.db.Update(file);
}
}
project.db.Commit();
project.db.Disconnect();
}
}
}