Revert "упорядочил папки с кодом."

This reverts commit 44c6daffa3.
This commit is contained in:
2023-11-19 02:12:44 +03:00
parent 44c6daffa3
commit 28908bcfac
596 changed files with 1569 additions and 2140 deletions

View File

@@ -0,0 +1,15 @@
package TestingSystem.SAPFOR.Json;
import Common.Constants;
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 int id = Constants.Nan;
@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<Integer, LinkedHashMap<String, Vector<SapforTask>>>> sortedTasks = new LinkedHashMap<>();
//-- задачи, отсортированные для сравнения.
public LinkedHashMap<MatchState, LinkedHashMap<TaskState, LinkedHashMap<Integer, 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<Integer, LinkedHashMap<String, Vector<SapforTask>>> tasksByConfigurations = sortedTasks.get(state);
for (int 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(), String.valueOf(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<Integer, LinkedHashMap<String, Vector<SapforTask>>>> task_states = comparisonSortedTasks.get(match_state);
//---
for (TaskState state : task_states.keySet()) {
//--
StateSummary stateSummary = new StateSummary(state);
//--
LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>> tasksByConfigurations = task_states.get(state);
for (int 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(), String.valueOf(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<Integer, 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<Integer, LinkedHashMap<String, Vector<SapforTask>>> configuration_tasks = sortedTasks.get(state);
for (int 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<Integer, LinkedHashMap<String, Vector<SapforTask>>>> state_tasks = new LinkedHashMap<>();
comparisonSortedTasks.put(matchState, state_tasks);
//--
for (TaskState state : TaskState.values()) {
LinkedHashMap<Integer, 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<Integer, LinkedHashMap<String, Vector<SapforTask>>>> state_tasks = comparisonSortedTasks.get(matchState);
for (TaskState state : TaskState.values()) {
LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>> configuration_tasks = state_tasks.get(state);
for (int 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<Integer, 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 (int 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 (int configurationId : tasksByConfigurations.keySet()) {
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByConfigurations.get(configurationId);
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();
}
}
}

View File

@@ -0,0 +1,69 @@
package TestingSystem.SAPFOR;
import Common.Constants;
import Common.Global;
import Common.Utils.Utils;
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
import TestingSystem.SAPFOR.Json.SapforTasksPackage_json;
import TestingSystem.SAPFOR.Json.SapforTasksResults_json;
import TestingSystem.SAPFOR.Json.SapforTest_json;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import TestingSystem.Common.TaskThread;
import TestingSystem.Common.ThreadsPlanner.ThreadsPlanner;
import Visual_DVM_2021.Passes.PassCode_2021;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.Date;
import java.util.Vector;
public class PackageModeSupervisor extends ThreadsPlanner {
SapforTasksPackage_json package_json = null;
SapforTasksResults_json results_json = new SapforTasksResults_json();
public PackageModeSupervisor() throws Exception {
super(2000);
package_json = (SapforTasksPackage_json) Utils.jsonFromFile(new File(Global.Home, Constants.package_json), SapforTasksPackage_json.class);
Date startDate = new Date();
results_json.StartDate = startDate.getTime();
File started = new File(Constants.STARTED);
FileUtils.writeStringToFile(started, String.valueOf(startDate));
//формирование списка задач.
File sapfor_drv = new File(Global.Home, package_json.sapfor_drv);
setMaxKernels(package_json.kernels);
for (SapforConfiguration_json sapforConfiguration_json : package_json.configurations) {
for (SapforTest_json test : package_json.tests) {
//--- чтобы было можно на нее сослаться после выполнения всех нитей.
SapforTask task = new SapforTask();
task.group_description = test.group_description;
task.test_description = test.test_description;
task.flags = sapforConfiguration_json.flags;
task.sapfor_configuration_id = sapforConfiguration_json.id;
task.sapfortaskspackage_id = Integer.parseInt(new File(Global.Home).getName());
results_json.tasks.add(task);
Vector<String> codes_s = new Vector<>();
for (PassCode_2021 code : sapforConfiguration_json.codes) {
codes_s.add(code.toString());
}
task.codes = String.join(" ", codes_s);
//---
addThread(new TaskThread(task, sapfor_drv, sapforConfiguration_json));
}
}
interruptThread.start();
}
@Override
public String printThread(Integer id) {
TaskThread taskThread = (TaskThread) threads.get(id);
return taskThread.task.getSummary();
}
@Override
protected void finalize() {
results_json.EndDate = new Date().getTime();
//записать результаты всех задач.
try {
Utils.jsonToFile(results_json, new File(Global.Home, Constants.results_json));
FileUtils.writeStringToFile(new File(Constants.DONE), "");
} catch (Exception e) {
Global.Log.PrintException(e);
}
System.exit(0);
}
}

View File

@@ -0,0 +1,366 @@
package TestingSystem.SAPFOR;
import Common.Constants;
import Common.Global;
import Common.Utils.Utils;
import GlobalData.Tasks.TaskState;
import ProjectData.Messages.Errors.MessageError;
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
import TestingSystem.SAPFOR.Json.SapforVersion_json;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.Vector;
import static java.lang.Character.isDigit;
public class PerformSapforTask extends Pass_2021<SapforTask> {
@Override
public String getDescription() {
return "";
// "Запуск задачи SAPFOR"; Оставляем пустое описание чтобы не засорять журнал.
}
@Override
protected boolean needsAnimation() {
return false;
}
//--
File sapfor_drv;
SapforConfiguration_json sapforConfiguration_json;
//-----
File root;
File parentTask;
File task;
//-----
Process process = null;
int exit_code = Constants.Nan;
//----
File outputFile = null;
File errorsFile = null;
//--
Vector<String> outputLines;
Vector<String> errorsLines;
//---
@Override
protected boolean canStart(Object... args) throws Exception {
sapfor_drv = (File) args[0];
sapforConfiguration_json = (SapforConfiguration_json) args[1];
target = (SapforTask) args[2];
//--->>
parentTask = Paths.get(Global.Home, String.valueOf(sapforConfiguration_json.id), target.test_description).toFile();
root = new File(Global.Home, String.valueOf(sapforConfiguration_json.id));
task = null;
//--->>
return true;
}
protected static boolean checkLines(Vector<String> lines) {
for (String line : lines) {
if (line.toLowerCase().contains("internal error")) {
return false;
}
if (line.toLowerCase().contains("exception")) {
return false;
}
if (line.contains("[ERROR]")) {
return false;
}
if (line.toLowerCase().contains("segmentation fault")) {
return false;
}
}
return true;
}
protected boolean performSapforScript(String name, File workspace, String command, String outName, String errName) throws Exception {
process = null;
exit_code = Constants.Nan;
//---
File data_workspace = new File(workspace, Constants.data);
Utils.CheckDirectory(data_workspace);
outputFile = new File(data_workspace, outName);
errorsFile = new File(data_workspace, errName);
Utils.delete_with_check(outputFile);
Utils.delete_with_check(errorsFile);
//---
File file = new File(data_workspace, name + (Global.isWindows ? ".bat" : ".sh"));
FileUtils.write(file,
Utils.DQuotes(sapfor_drv.getAbsolutePath())
+ (target.flags.isEmpty() ? "" : (" " + target.flags))
+ " -noLogo"
+ " " + command +
" 1>" +
Utils.DQuotes(outputFile.getAbsolutePath()) +
" 2>" +
Utils.DQuotes(errorsFile.getAbsolutePath()),
Charset.defaultCharset());
if (!file.setExecutable(true))
throw new Exception("Не удалось сделать файл скрипта " + name + " исполняемым!");
//--
boolean flag = false;
do {
try {
ProcessBuilder procBuilder = new ProcessBuilder(file.getAbsolutePath());
procBuilder.directory(workspace);
process = procBuilder.start();
exit_code = process.waitFor();
flag = true;
} catch (Exception ex) {
Global.Log.PrintException(ex);
Utils.sleep(1000);
}
}
while (!flag);
process = null;
//---
outputLines = new Vector<>(FileUtils.readLines(outputFile));
errorsLines = new Vector<>(FileUtils.readLines(errorsFile));
return (exit_code == 0) &&
checkLines(outputLines) &&
checkLines(errorsLines);
}
protected boolean parse() throws Exception {
if (performSapforScript("parse", parentTask,
"-parse *.f *.for *.fdv *.f90 *.f77",
Constants.parse_out_file,
Constants.parse_err_file)
&& (new File(parentTask, "dvm.proj")).exists()) {
return true;
} else {
target.state = TaskState.DoneWithErrors;
return false;
}
}
//слегка изменить подход.
protected boolean transformation(PassCode_2021 code) throws Exception {
task = new File(parentTask, "v1");
Utils.CheckAndCleanDirectory(task); //папка для преобразования.
//если версия пустая, это тоже результат тестирования. Поэтому должна учитываться в древе.
target.versions.add(new SapforVersion_json(
root.getAbsolutePath(),
task.getAbsolutePath(), code.getDescription()));
//---
if (performSapforScript("transformation", parentTask,
code.getTestingCommand() + " -F " + Utils.DQuotes(task.getAbsolutePath()),
Constants.out_file,
Constants.err_file
)) {
target.state = TaskState.Done;
parentTask = task;
return true;
}
target.state = TaskState.DoneWithErrors;
return false;
}
protected void variants() throws Exception {
//папки вариантов создается самим сапфором.
target.state = performSapforScript("create_variants", parentTask, " -t 13 -allVars"
+ " -tinfo"
,
Constants.out_file,
Constants.err_file
) ? TaskState.Done : TaskState.DoneWithErrors;
//найти папки с вариантами.
File[] files_ = parentTask.listFiles((dir, name) -> dir.isDirectory() && Utils.isParallelVersionName(name));
if ((files_ != null) && (files_.length > 0)) {
Vector<File> files = new Vector<>(Arrays.asList(files_));
files.sort(Comparator.comparingInt(o -> Integer.parseInt(o.getName().substring(1))));
for (File file : files)
target.variants.add(
new SapforVersion_json(
root.getAbsolutePath(),
file.getAbsolutePath(), PassCode_2021.SPF_CreateParallelVariant.getDescription()));
}
}
//-------------------------------------------------->>
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) throws Exception {
//Образец запакованного сообщения
//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;
}
}
}
//--
/*
protected void createVersionProjectData(SapforVersion_json version, boolean isTransformation) throws Exception {
db_project_info project = new db_project_info();
project.Home = new File(version.version);
project.name = project.Home.getName();
project.description = version.description;
project.languageName = LanguageName.fortran;
project.creationDate = Utils.getDateNumber();
//--
Vector<MessageError> messages = new Vector<>();
//--
if (isTransformation) {
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.CreateVisualiserData();
//---
if (isTransformation && !messages.isEmpty()) {
project.Open(); //нельзя!!! сначала надо определиться с версиями. И только потом, получать файлы.
//а так же, убрать 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();
}
}
*/
//-------------------------------------------------->>
@Override
protected void body() throws Exception {
target.StartDate = new Date().getTime();
target.versions.add(new SapforVersion_json(target.test_description, "исходная"));
for (PassCode_2021 code : sapforConfiguration_json.codes) {
if (parse()) {
if (code.equals(PassCode_2021.CreateParallelVariants))
variants();
else if (!transformation(code))
break;
} else
break;
}
target.ChangeDate = new Date().getTime();
}
}

View File

@@ -0,0 +1,59 @@
package TestingSystem.SAPFOR.SapforConfiguration;
import Common.Database.DBObject;
import Common.Database.riDBObject;
import Common.Global;
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommand;
import Visual_DVM_2021.Passes.PassCode_2021;
import java.util.Vector;
public class SapforConfiguration extends riDBObject {
//настройки.
public int maxtime = 300; //лимит времени преобразования. (пока не используется)
public int FREE_FORM = 0; //"Свободный выходной стиль"; -f90
public int STATIC_SHADOW_ANALYSIS = 0;//"Оптимизация теневых обменов"; -sh
public int MAX_SHADOW_WIDTH = 50; // "Максимальный размер теневых граней"; (%) -shwidth значение поля
public int KEEP_SPF_DIRECTIVES = 0; //"Сохранять SPF директивы при построении параллельных вариантов"; -keepSPF
public int KEEP_DVM_DIRECTIVES = 0;// "Учитывать DVM директивы"; -keepDVM
//----
public String getFlags() {
Vector<String> res = new Vector<>();
if (FREE_FORM > 0)
res.add("-f90");
if (STATIC_SHADOW_ANALYSIS > 0)
res.add("-sh");
if (MAX_SHADOW_WIDTH > 0)
res.add("-shwidth " + MAX_SHADOW_WIDTH);
if (KEEP_DVM_DIRECTIVES > 0)
res.add("-keepDVM");
if (KEEP_SPF_DIRECTIVES > 0)
res.add("-keepSPF");
return String.join(" ", res);
}
//-
public Vector<PassCode_2021> getPassCodes() {
Vector<PassCode_2021> res = new Vector<>();
for (SapforConfigurationCommand command : Global.testingServer.db.sapforConfigurationCommands.Data.values()) {
if (command.sapforconfiguration_id == id) {
res.add(command.passCode);
}
}
return res;
}
//--
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
SapforConfiguration c = (SapforConfiguration) src;
maxtime = c.maxtime;
FREE_FORM = c.FREE_FORM;
STATIC_SHADOW_ANALYSIS = c.STATIC_SHADOW_ANALYSIS;
MAX_SHADOW_WIDTH = c.MAX_SHADOW_WIDTH;
KEEP_SPF_DIRECTIVES = c.KEEP_SPF_DIRECTIVES;
KEEP_DVM_DIRECTIVES = c.KEEP_DVM_DIRECTIVES;
}
public SapforConfiguration(SapforConfiguration sapforConfiguration) {
this.SynchronizeFields(sapforConfiguration);
}
public SapforConfiguration() {
}
}

View File

@@ -0,0 +1,108 @@
package TestingSystem.SAPFOR.SapforConfiguration;
import Common.Current;
import Common.Database.*;
import Common.UI.DataSetControlForm;
import Common.UI.Windows.Dialog.DBObjectDialog;
import Common.Utils.Utils;
import TestingSystem.SAPFOR.SapforConfiguration.UI.SapforConfigurationFields;
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommand;
import java.util.LinkedHashMap;
public class SapforConfigurationDBTable extends iDBTable<SapforConfiguration> {
public SapforConfigurationDBTable() {
super(SapforConfiguration.class);
}
@Override
public Current CurrentName() {
return Current.SapforConfiguration;
}
@Override
public String getSingleDescription() {
return "конфигурация тестирования SAPFOR";
}
@Override
public String getPluralDescription() {
return "конфигурации";
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this){
@Override
public boolean hasCheckBox() {
return true;
}
@Override
protected void AdditionalInitColumns() {
//columns.get(0).setVisible(false);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"имя",
"автор",
"флаги"
};
}
@Override
public Object getFieldAt(SapforConfiguration object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.description;
case 3:
return object.sender_name;
case 4:
return object.getFlags();
default:
return null;
}
}
//--
@Override
public DBObjectDialog<SapforConfiguration, SapforConfigurationFields> getDialog() {
return new DBObjectDialog<SapforConfiguration, SapforConfigurationFields>(SapforConfigurationFields.class) {
@Override
public int getDefaultHeight() {
return 415;
}
@Override
public int getDefaultWidth() {
return 600;
}
@Override
public void validateFields() {
}
@Override
public void fillFields() {
fields.tfName.setText(Result.description);
fields.cbFREE_FORM.setSelected(Result.FREE_FORM != 0);
fields.cbKEEP_DVM_DIRECTIVES.setSelected(Result.KEEP_DVM_DIRECTIVES != 0);
fields.cbKEEP_SPF_DIRECTIVES.setSelected(Result.KEEP_SPF_DIRECTIVES != 0);
fields.cbSTATIC_SHADOW_ANALYSIS.setSelected(Result.STATIC_SHADOW_ANALYSIS != 0);
fields.sMAX_SHADOW_WIDTH.setValue(Result.MAX_SHADOW_WIDTH);
}
@Override
public void ProcessResult() {
Result.description = fields.tfName.getText();
Result.FREE_FORM = Utils.fromBoolean(fields.cbFREE_FORM.isSelected());
Result.KEEP_DVM_DIRECTIVES = Utils.fromBoolean(fields.cbKEEP_DVM_DIRECTIVES.isSelected());
Result.KEEP_SPF_DIRECTIVES = Utils.fromBoolean(fields.cbKEEP_SPF_DIRECTIVES.isSelected());
Result.STATIC_SHADOW_ANALYSIS = Utils.fromBoolean(fields.cbSTATIC_SHADOW_ANALYSIS.isSelected());
Result.MAX_SHADOW_WIDTH = fields.sMAX_SHADOW_WIDTH.getValue();
}
@Override
public void SetReadonly() {
fields.tfName.setEnabled(false);
fields.sTransformationMaxtime.setEnabled(false);
}
};
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(SapforConfigurationCommand.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
return res;
}
}

View File

@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="TestingSystem.SAPFOR.SapforConfiguration.UI.SapforConfigurationFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="883" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="d1d6e" layout-manager="GridLayoutManager" row-count="8" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3257b" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false">
<preferred-size width="284" height="20"/>
</grid>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="название"/>
</properties>
</component>
<vspacer id="224d6">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<preferred-size width="284" height="14"/>
</grid>
</constraints>
</vspacer>
<component id="ecbf1" class="javax.swing.JTextField" binding="tfName" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="200" height="30"/>
<preferred-size width="200" height="30"/>
<maximum-size width="200" height="30"/>
</grid>
</constraints>
<properties/>
</component>
<component id="b644a" class="javax.swing.JCheckBox" binding="cbFREE_FORM">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="284" height="25"/>
</grid>
</constraints>
<properties>
<font name="Times New Roman" size="14" style="2"/>
<icon value="icons/NotPick.png"/>
<selectedIcon value="icons/Pick.png"/>
<text value="Свободный выходной стиль"/>
</properties>
</component>
<component id="7721e" class="javax.swing.JCheckBox" binding="cbKEEP_SPF_DIRECTIVES">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="284" height="25"/>
</grid>
</constraints>
<properties>
<font name="Times New Roman" size="14" style="2"/>
<icon value="icons/NotPick.png"/>
<selectedIcon value="icons/Pick.png"/>
<text value="Сохранять SPF директивы"/>
</properties>
</component>
<component id="f44c1" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="3" use-parent-layout="false">
<preferred-size width="284" height="17"/>
</grid>
</constraints>
<properties>
<font name="Times New Roman" size="14" style="2"/>
<text value="Максимальный размер теневых граней, %"/>
</properties>
</component>
<component id="54e77" class="javax.swing.JCheckBox" binding="cbSTATIC_SHADOW_ANALYSIS">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="284" height="25"/>
</grid>
</constraints>
<properties>
<font name="Times New Roman" size="14" style="2"/>
<icon value="icons/NotPick.png"/>
<selectedIcon value="icons/Pick.png"/>
<text value="Оптимизация теневых обменов"/>
</properties>
</component>
<component id="4e865" class="javax.swing.JCheckBox" binding="cbKEEP_DVM_DIRECTIVES">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="284" height="25"/>
</grid>
</constraints>
<properties>
<font name="Times New Roman" size="14" style="2"/>
<icon value="icons/NotPick.png"/>
<selectedIcon value="icons/Pick.png"/>
<text value="Учитывать DVM директивы"/>
</properties>
</component>
<component id="14243" class="javax.swing.JSlider" binding="sMAX_SHADOW_WIDTH">
<constraints>
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="500" height="40"/>
<preferred-size width="500" height="40"/>
<maximum-size width="500" height="40"/>
</grid>
</constraints>
<properties>
<majorTickSpacing value="25"/>
<minorTickSpacing value="1"/>
<paintLabels value="true"/>
<paintTicks value="true"/>
<snapToTicks value="false"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>

View File

@@ -0,0 +1,25 @@
package TestingSystem.SAPFOR.SapforConfiguration.UI;
import Common.UI.TextField.StyledTextField;
import Common.UI.Windows.Dialog.DialogFields;
import javax.swing.*;
import java.awt.*;
public class SapforConfigurationFields implements DialogFields {
private JPanel content;
public JTextField tfName;
public JSpinner sTransformationMaxtime;
public JCheckBox cbFREE_FORM;
public JSlider sMAX_SHADOW_WIDTH;
public JCheckBox cbSTATIC_SHADOW_ANALYSIS;
public JCheckBox cbKEEP_SPF_DIRECTIVES;
public JCheckBox cbKEEP_DVM_DIRECTIVES;
//--
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
tfName = new StyledTextField();
}
}

View File

@@ -0,0 +1,28 @@
package TestingSystem.SAPFOR.SapforConfigurationCommand;
import Common.Constants;
import Common.Current;
import Common.Database.DBObject;
import Common.Database.riDBObject;
import Visual_DVM_2021.Passes.PassCode_2021;
import com.sun.org.glassfish.gmbal.Description;
public class SapforConfigurationCommand extends riDBObject {
@Description("DEFAULT -1")
public int sapforconfiguration_id = Constants.Nan;
public PassCode_2021 passCode = PassCode_2021.SPF_RemoveDvmDirectives;
@Override
public boolean isVisible() {
return Current.HasSapforConfiguration() && (Current.getSapforConfiguration().id == sapforconfiguration_id);
}
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
SapforConfigurationCommand c = (SapforConfigurationCommand) src;
sapforconfiguration_id = c.sapforconfiguration_id;
passCode = c.passCode;
}
public SapforConfigurationCommand() {
}
public SapforConfigurationCommand(SapforConfigurationCommand sapforConfigurationCommand) {
this.SynchronizeFields(sapforConfigurationCommand);
}
}

View File

@@ -0,0 +1,67 @@
package TestingSystem.SAPFOR.SapforConfigurationCommand;
import Common.Current;
import Common.Database.iDBTable;
import Common.UI.DataSetControlForm;
import Common.UI.UI;
import Common.UI.Windows.Dialog.DBObjectDialog;
import TestingSystem.SAPFOR.SapforConfigurationCommand.UI.SapforConfigurationCommandFields;
import Visual_DVM_2021.Passes.PassCode_2021;
public class SapforConfigurationCommandsDBTable extends iDBTable<SapforConfigurationCommand> {
public SapforConfigurationCommandsDBTable() {
super(SapforConfigurationCommand.class);
}
@Override
public String getSingleDescription() {
return "команда";
}
@Override
public String getPluralDescription() {
return "команды";
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this){
@Override
protected void AdditionalInitColumns() {
//columns.get(0).setVisible(false);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Проход"
};
}
@Override
public Object getFieldAt(SapforConfigurationCommand object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.passCode.getDescription();
default:
return null;
}
}
@Override
public Current CurrentName() {
return Current.SapforConfigurationCommand;
}
@Override
public DBObjectDialog<SapforConfigurationCommand, SapforConfigurationCommandFields> getDialog() {
return new DBObjectDialog<SapforConfigurationCommand, SapforConfigurationCommandFields>(SapforConfigurationCommandFields.class) {
@Override
public int getDefaultHeight() {
return 250;
}
@Override
public void fillFields() {
UI.TrySelect(fields.cbPassCode, Result.passCode);
}
@Override
public void ProcessResult() {
Result.passCode = (PassCode_2021) fields.cbPassCode.getSelectedItem();
Result.sapforconfiguration_id = Current.getSapforConfiguration().id;
}
};
}
}

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="TestingSystem.SAPFOR.SapforConfigurationCommand.UI.SapforConfigurationCommandFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="97a3c" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="проход"/>
</properties>
</component>
<vspacer id="7e4ea">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="e95d0" class="javax.swing.JComboBox" binding="cbPassCode" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<toolTipText value="выберите проход"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,32 @@
package TestingSystem.SAPFOR.SapforConfigurationCommand.UI;
import Common.Current;
import Common.UI.Tables.StyledCellLabel;
import Common.UI.Windows.Dialog.DialogFields;
import Repository.Component.Sapfor.Sapfor;
import Visual_DVM_2021.Passes.PassCode_2021;
import javax.swing.*;
import java.awt.*;
public class SapforConfigurationCommandFields implements DialogFields {
private JPanel content;
public JComboBox<PassCode_2021> cbPassCode;
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
cbPassCode = new JComboBox<>();
cbPassCode.setRenderer((list, value, index, isSelected, cellHasFocus) -> {
JLabel res = new StyledCellLabel();
res.setText(value.getDescription());
res.setBackground(isSelected ?
Current.getTheme().selection_background : Current.getTheme().background
);
return res;
});
//-
for (PassCode_2021 code : Sapfor.getScenariosCodes())
cbPassCode.addItem(code);
}
}

View File

@@ -0,0 +1,36 @@
package TestingSystem.SAPFOR.SapforTask;
import Common.Current;
import Common.UI.StatusEnum;
import Common.UI.Themes.VisualiserFonts;
import java.awt.*;
public enum MatchState implements StatusEnum {
Unknown,
NotMatch,
Match;
public String getDescription() {
switch (this) {
case Unknown:
return "неизвестно";
case Match:
return "совпадений";
case NotMatch:
return "различий";
default:
return "?";
}
}
@Override
public Font getFont() {
switch (this) {
case Unknown:
return Current.getTheme().Fonts.get(VisualiserFonts.UnknownState);
case Match:
return Current.getTheme().Fonts.get(VisualiserFonts.GoodState);
case NotMatch:
return Current.getTheme().Fonts.get(VisualiserFonts.BadState);
default:
return StatusEnum.super.getFont();
}
}
}

View File

@@ -0,0 +1,196 @@
package TestingSystem.SAPFOR.SapforTask;
import Common.Constants;
import Common.Current;
import Common.Database.DBObject;
import Common.Utils.Utils;
import GlobalData.Tasks.TaskState;
import TestingSystem.SAPFOR.Json.SapforVersion_json;
import TestingSystem.SAPFOR.SapforTasksPackage.UI.VersionSummary;
import Visual_DVM_2021.Passes.PassCode_2021;
import com.google.gson.annotations.Expose;
import com.sun.org.glassfish.gmbal.Description;
import javax.swing.tree.DefaultMutableTreeNode;
import java.io.File;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Vector;
public class SapforTask extends DBObject {
//------------------------------------>>
@Description("PRIMARY KEY, UNIQUE")
@Expose
public long id = Constants.Nan;
@Description("DEFAULT '-1'")
@Expose
public int sapfor_configuration_id = Constants.Nan;
@Expose
@Description("DEFAULT '-1'")
public int sapfortaskspackage_id = Constants.Nan;
//------------------------------------->>
@Description("DEFAULT ''")
@Expose
public String test_description = "";
@Description("DEFAULT ''")
@Expose
public String group_description = "";
@Description("DEFAULT ''")
@Expose
public String flags = "";
@Description("DEFAULT ''")
@Expose
public String codes = "";
@Expose
public TaskState state = TaskState.Inactive;
@Expose
public long StartDate = 0; //дата начала выполнения
@Expose
public long ChangeDate = 0;//дата окончания выполнения
//в json не выносить. это только для БД.
@Description("DEFAULT ''")
public String versionsDescription = "";
//------
@Description("IGNORE")
@Expose
public Vector<SapforVersion_json> versions = new Vector<>();
//----------
@Description("IGNORE")
@Expose
public Vector<SapforVersion_json> variants = new Vector<>();
//----------
@Description("IGNORE")
public MatchState match = MatchState.Unknown;
//-----------
public String getUniqueKey() {
return sapfor_configuration_id + "_" + group_description + "_" + test_description;
}
public String getSummary() {
Vector<String> lines = new Vector<>();
lines.add(group_description);
lines.add(test_description);
lines.add(codes);
lines.add(flags);
return String.join(" ", lines);
}
//-----------
public SapforTask() {
}
public DefaultMutableTreeNode getVersionsTree(File configurationRoot) {
DefaultMutableTreeNode root = null;
DefaultMutableTreeNode child = null;
DefaultMutableTreeNode parent = null;
//--
for (SapforVersion_json version_json : versions) {
version_json.init(configurationRoot);
version_json.task = this;
//-
child = new VersionSummary(version_json);
if (parent == null) {
root = child;
parent = child;
} else {
parent.add(child);
parent = child;
}
//-
}
if (parent != null) {
for (SapforVersion_json version_json : variants) {
version_json.init(configurationRoot);
version_json.task = this;
parent.add(new VersionSummary(version_json));
}
}
//--
return root;
}
public void Reset() {
state = TaskState.Inactive;
versions.clear();
variants.clear();
}
public SapforTask(SapforTask src) {
this.SynchronizeFields(src);
}
@Override
public Object getPK() {
return id;
}
@Override
public void SynchronizeFields(DBObject object) {
super.SynchronizeFields(object);
SapforTask t = (SapforTask) object;
id = t.id;
sapfor_configuration_id = t.sapfor_configuration_id;
sapfortaskspackage_id = t.sapfortaskspackage_id;
//-
test_description = t.test_description;
group_description = t.group_description;
versionsDescription = t.versionsDescription;
//--
codes = t.codes;
state = t.state;
//--
}
public String getVersionsChain() {
Vector<String> versionsLines = new Vector<>();
for (int i = 1; i < versions.size(); ++i) {
versionsLines.add(Utils.Brackets(versions.get(i).description));
}
if (!variants.isEmpty()) {
versionsLines.add(Utils.Brackets(PassCode_2021.CreateParallelVariants.getDescription()));
}
return String.join("", versionsLines);
}
@Override
public boolean isVisible() {
return Current.HasSapforTasksPackage() && Current.getSapforTasksPackage().id == this.sapfortaskspackage_id;
}
public LinkedHashMap<String, SapforVersion_json> getSortedVersions() {
LinkedHashMap<String, SapforVersion_json> res = new LinkedHashMap<>();
for (SapforVersion_json version_json : versions)
res.put(version_json.version, version_json);
//--
for (SapforVersion_json version_json : variants)
res.put(version_json.version, version_json);
return res;
}
public void checkMatch(SapforTask task2) {
if (!state.equals(task2.state)) {
System.out.println("Не совпадение цепочки версий в задаче " + getUniqueKey());
} else if (versions.size() != task2.versions.size()) {
System.out.println("Не совпадение длины цепочки версий в задаче " + getUniqueKey());
} else if (variants.size() != task2.variants.size()) {
System.out.println("Не совпадение длины цепочки вариантов в задаче " + getUniqueKey());
} else {
LinkedHashMap<String, SapforVersion_json> versions1 = getSortedVersions();
LinkedHashMap<String, SapforVersion_json> versions2 = task2.getSortedVersions();
//---
for (String name1 : versions1.keySet()) {
if (!versions2.containsKey(name1)) {
System.out.println("Не совпадение имен версий в задаче " + getUniqueKey());
return;
}
}
System.out.println("сравнение версий.");
//--
for (String name1 : versions1.keySet()) {
System.out.println("version name=" + name1);
SapforVersion_json version1 = versions1.get(name1);
SapforVersion_json version2 = versions2.get(name1);
//---
if (!version1.isMatch(version2)) {
System.out.println("Не совпадение версий в задаче " + getUniqueKey());
return;
}
}
match = MatchState.Match;
task2.match = MatchState.Match;
}
}
public Date getStartDate() {
return new Date(StartDate);
}
public Date getChangeDate() {
return new Date(ChangeDate);
}
}

View File

@@ -0,0 +1,68 @@
package TestingSystem.SAPFOR.SapforTask;
import Common.Current;
import Common.Database.DBTable;
import Common.UI.DataSetControlForm;
import static Common.UI.Tables.TableRenderers.RendererDate;
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
public class SapforTasksDBTable extends DBTable<Long, SapforTask> {
public SapforTasksDBTable() {
super(Long.class, SapforTask.class);
}
@Override
public String getSingleDescription() {
return "задача";
}
@Override
public String getPluralDescription() {
return "задачи";
}
@Override
public Current CurrentName() {
return Current.SapforTask;
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
protected void AdditionalInitColumns() {
columns.get(4).setRenderer(RendererStatusEnum);
columns.get(5).setRenderer(RendererDate);
columns.get(6).setRenderer(RendererDate);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Группа",
"Тест",
"Флаги",
"Статус",
"Начало",
"Окончание",
"Версии"
};
}
@Override
public Object getFieldAt(SapforTask object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.group_description;
case 2:
return object.test_description;
case 3:
return object.flags;
case 4:
return object.state;
case 5:
return object.getStartDate();
case 6:
return object.getChangeDate();
case 7:
return object.versionsDescription;
default:
return null;
}
}
}

View File

@@ -0,0 +1,17 @@
package TestingSystem.SAPFOR.SapforTasksPackage;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Test.Test;
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
import java.io.Serializable;
import java.util.LinkedHashMap;
public class SapforPackageData implements Serializable {
//--->
public LinkedHashMap<Integer, Group> groups =new LinkedHashMap<Integer, Group>();
public LinkedHashMap<Integer, Test> tests = new LinkedHashMap<>();
public LinkedHashMap<Integer, SapforConfiguration> sapforConfigurations = new LinkedHashMap<>();
public ServerSapfor sapfor = null;
//-->>
public String notFound = "";
}

View File

@@ -0,0 +1,98 @@
package TestingSystem.SAPFOR.SapforTasksPackage;
import Common.Constants;
import Common.Database.DBObject;
import Common.Database.riDBObject;
import Common.Global;
import Common.Utils.Utils;
import TestingSystem.DVM.TasksPackage.TasksPackageState;
import TestingSystem.SAPFOR.Json.SapforTasksResults_json;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import com.sun.org.glassfish.gmbal.Description;
import java.io.File;
import java.nio.file.Paths;
import java.util.Comparator;
public class SapforTasksPackage extends riDBObject {
@Description("DEFAULT ''")
public String testsNames = "";//имена тестов через ; для отображения
//---
public int sapforId = Constants.Nan;
public String sapfor_version = "?"; //тестируемая версия SAPFOR для таблицы
public String sapfor_process_name = "";
//---
public String workspace = ""; //домашняя папка
//---
public int tasksCount = 0; //Общее число задач
//---
public int needsEmail = 0;
public long StartDate = 0; //дата начала выполнения
public long ChangeDate = 0;//дата окончания выполнения
//-
public int kernels = 1; //количество потоков.
@Description("DEFAULT 'TestsSynchronize'")
public TasksPackageState state = TasksPackageState.TestsSynchronize;
@Description("DEFAULT ''")
public String testsIds = "";
@Description("DEFAULT ''")
public String configurationsIds = "";
@Description("DEFAULT ''")
public String summary = "";
@Description("IGNORE")
public SapforTasksResults_json results = null;
///---
public File getArchive() {
return new File(Global.SapforPackagesDirectory, id + ".zip");
}
public File getLocalWorkspace() {
return new File(Global.SapforPackagesDirectory, String.valueOf(id));
}
public File getLoadedSign() {
return Paths.get(Global.SapforPackagesDirectory.getAbsolutePath(), String.valueOf(id), Constants.LOADED).toFile();
}
public boolean isLoaded() {
return getLoadedSign().exists();
}
public void readResults() {
File json_file = new File(getLocalWorkspace(), Constants.results_json);
results = null;
try {
results = (SapforTasksResults_json) Utils.jsonFromFile(json_file,
SapforTasksResults_json.class);
//----
results.tasks.sort(Comparator.comparing(SapforTask::getUniqueKey));
for (SapforTask task : results.tasks)
results.allTasks.put(task.getUniqueKey(), task);
//---
results.SortTasks(); //по состояниям конфигурациям и группам
//---
results.buildTree(this);
//---
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
SapforTasksPackage p = (SapforTasksPackage) src;
sapforId = p.sapforId;
testsNames = p.testsNames;
sapfor_version = p.sapfor_version;
workspace = p.workspace;
tasksCount = p.tasksCount;
StartDate = p.StartDate;
ChangeDate = p.ChangeDate;
kernels = p.kernels;
sapfor_process_name = p.sapfor_process_name;
state = p.state;
needsEmail = p.needsEmail;
summary = p.summary;
}
//---
public SapforTasksPackage() {
}
//--
public SapforTasksPackage(SapforTasksPackage sapforTasksPackage) {
this.SynchronizeFields(sapforTasksPackage);
}
}

View File

@@ -0,0 +1,80 @@
package TestingSystem.SAPFOR.SapforTasksPackage;
import Common.Current;
import Common.Database.*;
import Common.UI.DataSetControlForm;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import java.util.Date;
import java.util.LinkedHashMap;
import static Common.UI.Tables.TableRenderers.RendererDate;
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
public class SapforTasksPackagesDBTable extends iDBTable<SapforTasksPackage> {
public SapforTasksPackagesDBTable() {
super(SapforTasksPackage.class);
}
@Override
public Current CurrentName() {
return Current.SapforTasksPackage;
}
@Override
public String getSingleDescription() {
return "пакет задач Sapfor";
}
@Override
public String getPluralDescription() {
return "пакеты задач Sapfor";
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
protected void AdditionalInitColumns() {
// columns.get(0).setVisible(false);
columns.get(5).setRenderer(RendererDate);
columns.get(6).setRenderer(RendererDate);
columns.get(7).setRenderer(RendererStatusEnum);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"SAPFOR",
"Тесты",
"Задач",
"Ядер",
"Начало",
"Изменено",
"Статус"
};
}
@Override
public Object getFieldAt(SapforTasksPackage object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.sapfor_version;
case 2:
return object.testsNames;
case 3:
return object.tasksCount;
case 4:
return object.kernels;
case 5:
return new Date(object.StartDate);
case 6:
return new Date(object.ChangeDate);
case 7:
return object.state;
default:
return null;
}
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(SapforTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
return res;
}
}

View File

@@ -0,0 +1,29 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import Common.Constants;
import Common.Utils.Utils;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import Visual_DVM_2021.Passes.PassCode_2021;
import java.util.Arrays;
import java.util.Vector;
public class ConfigurationSummary extends SapforPackageTreeNode {
public int configuration_id = Constants.Nan;
public String flags = "";
public Vector<String> codes_descriptions = new Vector<>();
public ConfigurationSummary(int configuration_id_in, SapforTask task) {
configuration_id = configuration_id_in;
flags = task.flags;
Vector<String> codes_s = new Vector<>(Arrays.asList(task.codes.split(" ")));
for (int i = 1; i < codes_s.size(); ++i) {
codes_descriptions.add(Utils.Brackets(PassCode_2021.valueOf(codes_s.get(i)).getDescription()));
}
}
@Override
public String toString() {
return flags + " " + String.join("", codes_descriptions);
}
@Override
public String getImageKey() {
return "Configuration";
}
}

View File

@@ -0,0 +1,15 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
public class GroupSummary extends SapforPackageTreeNode {
public String group_name = "";
@Override
public String getImageKey() {
return "Group";
}
public GroupSummary(String group_name_in) {
group_name = group_name_in;
}
@Override
public String toString() {
return group_name;
}
}

View File

@@ -0,0 +1,24 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import TestingSystem.SAPFOR.SapforTask.MatchState;
public class MatchesSummary extends SapforPackageTreeNode {
public MatchState state;
public int count = 0;
public MatchesSummary(MatchState state_in) {
state = state_in;
}
@Override
public String toString() {
return state.getDescription() + " : " + count;
}
@Override
public String getImageKey() {
switch (state) {
case Match:
return "Match";
case NotMatch:
return "NotMatch";
default:
return "TestVersion";
}
}
}

View File

@@ -0,0 +1,14 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
public class PackageSummary extends SapforPackageTreeNode {
public int count = 0;
@Override
public String getImageKey() {
return null;
}
public PackageSummary() {
}
@Override
public String toString() {
return "всего задач : " + count;
}
}

View File

@@ -0,0 +1,12 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.Objects;
public abstract class SapforPackageTreeNode extends DefaultMutableTreeNode {
public ImageIcon getIcon() {
return (getImageKey() != null) ?
new ImageIcon(Objects.requireNonNull(getClass().getResource("/icons/versions/" + getImageKey() + ".png")))
: null;
}
public abstract String getImageKey();
}

View File

@@ -0,0 +1,70 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import Common.Current;
import Common.UI.Trees.DataTree;
import Common.UI.Trees.TreeRenderers;
import Common.UI.UI;
import TestingSystem.SAPFOR.Json.SapforVersion_json;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import java.util.Vector;
public class SapforTasksPackageTree extends DataTree {
Current current;
SapforTasksPackageTree slave_tree = null;
public void setSlaveTree(SapforTasksPackageTree slave_tree_in) {
slave_tree = slave_tree_in;
}
public SapforTasksPackageTree(DefaultMutableTreeNode root_in, Current current_in) {
super(root_in);
current = current_in;
}
@Override
protected int getStartLine() {
return 1;
}
@Override
public TreeRenderers getRenderer() {
return TreeRenderers.RendererSapforVersion;
}
@Override
public Current getCurrent() {
return current;
}
public void selectSamePath_r(TreePath example, int index, DefaultMutableTreeNode node, Vector<DefaultMutableTreeNode> res) {
if (index < example.getPathCount()) {
DefaultMutableTreeNode exampleNode = (DefaultMutableTreeNode) example.getPathComponent(index);
if (exampleNode.toString().equals(node.toString())) {
res.add(node);
for (int i = 0; i < node.getChildCount(); ++i)
selectSamePath_r(example, index + 1, (DefaultMutableTreeNode) node.getChildAt(i), res);
}
}
}
public void selectSamePath(TreePath path_in) {
Vector<DefaultMutableTreeNode> pathNodes = new Vector<>();
selectSamePath_r(path_in, 0, root, pathNodes);
if (!pathNodes.isEmpty()) {
TreePath path = new TreePath(pathNodes.toArray());
setSelectionPath(path);
}
}
@Override
public void SelectionAction(TreePath e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getLastPathComponent();
Object o = node.getUserObject();
//---
if (slave_tree != null) {
slave_tree.selectSamePath(e);
}
//---
if (o instanceof SapforVersion_json) {
SapforVersion_json version = (SapforVersion_json) o;
Current.set(current, version);
if (current.equals(Current.SapforEtalonVersion))
UI.getMainWindow().getTestingWindow().ShowCurrentSapforPackageVersionEtalon();
else
UI.getMainWindow().getTestingWindow().ShowCurrentSapforPackageVersion();
//--
}
}
}

View File

@@ -0,0 +1,19 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import Common.UI.Trees.StyledTreeCellRenderer;
import javax.swing.*;
public class SapforVersionsTreeCellRenderer extends StyledTreeCellRenderer {
public java.awt.Component getTreeCellRendererComponent(
JTree tree, Object value,
boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (value instanceof SapforPackageTreeNode) {
SapforPackageTreeNode node = (SapforPackageTreeNode) value;
setForeground(tree.getForeground());
setFont(getFont().deriveFont((float) 14.0));
setIcon(node.getIcon());
}
return this;
}
}

View File

@@ -0,0 +1,24 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import GlobalData.Tasks.TaskState;
public class StateSummary extends SapforPackageTreeNode {
public TaskState state;
public int count = 0;
public StateSummary(TaskState state_in) {
state = state_in;
}
@Override
public String toString() {
return state.getDescription() + " : " + count;
}
@Override
public String getImageKey() {
switch (state) {
case Done:
return "DoneStateSummary";
case DoneWithErrors:
return "ErrorsStateSummary";
default:
return "UnknownStateSummary";
}
}
}

View File

@@ -0,0 +1,15 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import javax.swing.*;
import java.util.Objects;
public abstract class TreeSummary {
public String text = "";
public abstract void refreshText();
@Override
public String toString() {
return text;
}
public ImageIcon getIcon() {
return new ImageIcon(Objects.requireNonNull(getClass().getResource("/icons/versions/" + getImageKey() + ".png")));
}
public abstract String getImageKey();
}

View File

@@ -0,0 +1,20 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import TestingSystem.SAPFOR.Json.SapforVersion_json;
public class VersionSummary extends SapforPackageTreeNode{
public String version_name = "";
public String version_description = "";
public VersionSummary(SapforVersion_json version_json) {
setUserObject(version_json);
version_name = version_json.Home.getName();
version_description = version_json.description;
}
@Override
public String getImageKey() {
return "TestVersion";
}
@Override
public String toString() {
return version_name+ " : " +version_description;
}
}

View File

@@ -0,0 +1,202 @@
package TestingSystem.SAPFOR.SapforTasksPackageSupervisor;
import Common.Constants;
import Common.Current;
import Common.Global;
import Common.GlobalProperties;
import Common.Utils.Utils;
import Repository.Server.ServerCode;
import TestingSystem.Common.Test.Test;
import TestingSystem.Common.TestingPlanner;
import TestingSystem.DVM.TasksPackage.TasksPackageState;
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
import TestingSystem.SAPFOR.Json.SapforTasksPackage_json;
import TestingSystem.SAPFOR.Json.SapforTasksResults_json;
import TestingSystem.SAPFOR.Json.SapforTest_json;
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforPackageData;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
import Visual_DVM_2021.Passes.PassCode_2021;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.Date;
import java.util.Vector;
public class SapforTasksPackageSupervisor {
protected TestingPlanner planner; //планировщик.
SapforTasksPackage sapforTasksPackage = null;
public SapforTasksPackageSupervisor(TestingPlanner planner_in, SapforTasksPackage sapforTasksPackage_in) {
planner = planner_in;
sapforTasksPackage = sapforTasksPackage_in;
}
private void TestsSynchronize() throws Exception {
SapforPackageData data = (SapforPackageData) planner.ServerCommand(ServerCode.GetActualSapforPackageData, sapforTasksPackage);
if (!data.notFound.isEmpty()) {
sapforTasksPackage.summary = data.notFound;
sapforTasksPackage.state = TasksPackageState.Aborted;
return;
}
//--
System.out.println(sapforTasksPackage.id + " — TestsSynchronize");
File sapfor_src = new File(data.sapfor.call_command);
//--
SapforTasksPackage_json package_json = new SapforTasksPackage_json();
package_json.kernels = sapforTasksPackage.kernels;
for (Test test : data.tests.values()) {
SapforTest_json test_json = new SapforTest_json();
test_json.test_description = test.description;
test_json.group_description = data.groups.get(test.group_id).description;
package_json.tests.add(test_json);
}
//создание рабочего пространства для пакетного режима
File packageWorkspace = new File(Global.SapforPackagesDirectory, String.valueOf(sapforTasksPackage.id));
Utils.CheckAndCleanDirectory(packageWorkspace);
sapforTasksPackage.workspace = packageWorkspace.getAbsolutePath();
//копирование тестов по конфигурациям.
int actual_tasks_count = 0;
for (SapforConfiguration configuration: data.sapforConfigurations.values()){
//--
SapforConfiguration_json configuration_json = new SapforConfiguration_json();
configuration_json.id = configuration.id;
configuration_json.flags = configuration.getFlags();
configuration_json.codes.add(PassCode_2021.SPF_CorrectCodeStylePass); //всегда добавляется.
configuration_json.codes.addAll(configuration.getPassCodes());
//--->>
package_json.configurations.add(configuration_json);
//-->>
File configurationWorkspace = new File(packageWorkspace, String.valueOf(configuration.id));
FileUtils.forceMkdir(configurationWorkspace);
//--->>>
for (Test test : data.tests.values()) {
File test_root = new File(configurationWorkspace, test.description);
Utils.CheckAndCleanDirectory(test_root);
FileUtils.copyDirectory(new File(Global.TestsDirectory, String.valueOf(test.id)), test_root);
actual_tasks_count++;
}
}
sapforTasksPackage.tasksCount = actual_tasks_count;
//копирование SAPFOR
File sapforFile = new File(sapforTasksPackage.workspace, Utils.getDateName("SAPFOR_F"));
FileUtils.copyFile(sapfor_src, sapforFile);
if (!sapforFile.setExecutable(true))
throw new Exception("Не удалось сделать файл " + sapforFile.getName() + " исполняемым!");
sapforTasksPackage.sapfor_process_name = package_json.sapfor_drv = sapforFile.getName();
//--->>
//копирование визуализатора
File visualiser = new File(sapforTasksPackage.workspace, "VisualSapfor.jar");
FileUtils.copyFile(new File(Global.Home, "TestingSystem.jar"), visualiser);
//создание настроек
GlobalProperties properties = new GlobalProperties();
properties.Mode = Current.Mode.Package;
Utils.jsonToFile(properties, new File(sapforTasksPackage.workspace, "properties"));
//создание инструкции
File package_json_file = new File(sapforTasksPackage.workspace, "package_json");
Utils.jsonToFile(package_json, package_json_file);
//подготовка пакетного режима. Запустит его уже очередь.
Utils.createScript(packageWorkspace, packageWorkspace, "start", "java -jar VisualSapfor.jar");
//--
sapforTasksPackage.state = TasksPackageState.RunningPreparation;
}
void PackageStart() throws Exception {
System.out.println("start sapfor package " + sapforTasksPackage.id);
File workspace = new File(sapforTasksPackage.workspace);
File script = new File(sapforTasksPackage.workspace, "start");
ProcessBuilder procBuilder = new ProcessBuilder(script.getAbsolutePath());
procBuilder.directory(workspace);
procBuilder.start();
//--->>
File started = new File(sapforTasksPackage.workspace, Constants.STARTED);
while (!started.exists()) {
System.out.println("waiting for package start...");
Utils.sleep(1000);
}
//-->>
sapforTasksPackage.state = TasksPackageState.RunningExecution;
planner.UpdateSapforPackage();
System.out.println("done");
}
void CheckPackageState() throws Exception {
System.out.println("check sapfor package " + sapforTasksPackage.id);
File done = new File(sapforTasksPackage.workspace, Constants.DONE);
File aborted = new File(sapforTasksPackage.workspace, Constants.ABORTED);
if (done.exists()) {
sapforTasksPackage.state = TasksPackageState.Analysis;
planner.UpdateSapforPackage();
System.out.println("package done, start Analysis");
} else if (aborted.exists()) {
sapforTasksPackage.state = TasksPackageState.Aborted;
planner.UpdateSapforPackage();
System.out.println("package aborted");
} else {
System.out.println("package running");
}
}
//--
public boolean packageNeedsKill() throws Exception {
return (boolean) planner.ServerCommand(ServerCode.CheckPackageToKill, String.valueOf(sapforTasksPackage.id));
}
public void killPackage() throws Exception {
//----
File interrupt_file = new File(sapforTasksPackage.workspace, Constants.INTERRUPT);
//----
FileUtils.writeStringToFile(interrupt_file, new Date().toString());
File aborted_file = new File(sapforTasksPackage.workspace, Constants.ABORTED);
do {
System.out.println("waiting for interrupt...");
Thread.sleep(1000);
} while (!aborted_file.exists());
System.out.println("coup de grace..");
String kill_command = "killall -SIGKILL " + sapforTasksPackage.sapfor_process_name;
System.out.println(kill_command);
Process killer = Runtime.getRuntime().exec(kill_command);
killer.waitFor();
System.out.println("done!");
}
public void AnalysePackage() throws Exception {
File results_json_file = new File(sapforTasksPackage.workspace, Constants.results_json);
if (results_json_file.exists()) {
SapforTasksResults_json results_json = (SapforTasksResults_json) Utils.jsonFromFile(results_json_file, SapforTasksResults_json.class);
results_json.SortTasks();
//--
sapforTasksPackage.summary = results_json.getEmailSummary();
for (SapforTask task : results_json.tasks) {
//--
task.versions = null;
task.variants = null;
}
planner.ServerCommand(ServerCode.PublishSapforPackageTasks, planner.email, new Vector<>(results_json.tasks));
}
//Очистка
//очистка служебных файлов.
Utils.deleteFilesByExtensions(new File(sapforTasksPackage.workspace),
"proj", "dep", "jar", "sh", "exe", "bat");
}
public void Perform() throws Exception {
if (packageNeedsKill()) {
System.out.println("PACKAGE " + sapforTasksPackage.id + " NEEDS TO KILL");
killPackage();
sapforTasksPackage.state = TasksPackageState.Aborted;
planner.UpdateSapforPackage();
} else {
switch (sapforTasksPackage.state) {
case TestsSynchronize:
TestsSynchronize();
planner.UpdateSapforPackage();
break;
case RunningPreparation:
PackageStart();
break;
case RunningExecution:
CheckPackageState();
break;
case Analysis:
AnalysePackage();
sapforTasksPackage.state = TasksPackageState.Done;
planner.UpdateSapforPackage();
break;
default:
break;
}
}
}
}

View File

@@ -0,0 +1,33 @@
package TestingSystem.SAPFOR.ServerSapfor;
import Common.Database.riDBObject;
import Common.Utils.Utils;
import ProjectData.LanguageName;
import com.sun.org.glassfish.gmbal.Description;
import java.util.Date;
public class ServerSapfor extends riDBObject {
//--------------------------------------------------------------------->>>
@Description("IGNORE")
public static String version_command = "-ver";//команда запроса версии компилятора.
@Description("IGNORE")
public static String help_command = "-help";// команда запроса help
//--------------------------------------------------------------------->>>
public LanguageName languageName = LanguageName.fortran;
public String home_path = ""; //домашняя папка.
public String call_command = ""; //полная команда вызова.
public String version = "?";
public long buildDate = 0;
public Date getBuildDate() {
return new Date(buildDate);
}
//--
public ServerSapfor() {
}
@Override
public String toString() {
return call_command;
}
public String getVersionCommand() {
return Utils.DQuotes(call_command) + " " + version_command;
}
}

View File

@@ -0,0 +1,46 @@
package TestingSystem.SAPFOR.ServerSapfor;
import Common.Current;
import Common.Database.iDBTable;
import Common.UI.DataSetControlForm;
import Common.UI.Tables.TableRenderers;
public class ServerSapforsDBTable extends iDBTable<ServerSapfor> {
public ServerSapforsDBTable() {
super(ServerSapfor.class);
}
@Override
public String getSingleDescription() {
return "SAPFOR";
}
@Override
public String getPluralDescription() {
return "SAPFOR";
}
@Override
public Current CurrentName() {
return Current.ServerSapfor;
}
@Override
public String[] getUIColumnNames() {
return new String[]{"версия", "дата сборки"};
}
@Override
public Object getFieldAt(ServerSapfor object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.version;
case 2:
return object.getBuildDate();
}
return null;
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
protected void AdditionalInitColumns() {
// columns.get(0).setVisible(false);
columns.get(2).setRenderer(TableRenderers.RendererDate);
}
};
}
}