При анализе результатов добавлен учет версий и вариантов, при неудачном завершении процесса.

This commit is contained in:
2023-10-07 00:45:09 +03:00
parent 2eadbbd3fa
commit cef74a241c
4 changed files with 52 additions and 48 deletions

View File

@@ -18,6 +18,8 @@ public class Constants {
public final static String DONE = "DONE";
public final static String TIMEOUT = "TIMEOUT";
//-вывод задач
public final static String parse_out_file = "parse_out.txt";
public final static String parse_err_file = "parse_err.txt";
public final static String out_file = "out.txt";
public final static String err_file = "err.txt";
public final static String time_file = "total_time";

View File

@@ -2,7 +2,10 @@ package ProjectData.Messages.Errors;
import ProjectData.Messages.Message;
public class MessageError extends Message {
public MessageError(String file_in, int line_in, String value_in, int group_in) throws Exception {
super(file_in, line_in, value_in, group_in);
super(file_in,
line_in,
value_in,
group_in);
}
public MessageError() {
}

View File

@@ -11,7 +11,6 @@ import SapforTestingSystem.Json.SapforConfiguration_json;
import SapforTestingSystem.Json.SapforVersion_json;
import SapforTestingSystem.SapforTask.SapforTask;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.Pass_2021;
import org.apache.commons.io.FileUtils;
@@ -109,18 +108,17 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
procBuilder.directory(workspace);
process = procBuilder.start();
exit_code = process.waitFor();
if (exit_code != 0)
throw new PassException("Процесс завершился с кодом " + exit_code);
process = null;
//---
outputLines = new Vector<>(FileUtils.readLines(outputFile));
errorsLines = new Vector<>(FileUtils.readLines(errorsFile));
return checkLines(outputLines) && checkLines(errorsLines);
return (exit_code == 0) && checkLines(outputLines) && checkLines(errorsLines);
}
protected boolean parse() throws Exception {
if (performSapforScript("parse", parentTask,
"-parse *.f *.for *.fdv *.f90 *.f77",
"parse_out.txt", "parse_err.txt")
Constants.parse_out_file,
Constants.parse_err_file)
&& (new File(parentTask, "dvm.proj")).exists()) {
return true;
} else {
@@ -128,16 +126,19 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
return false;
}
}
//слегка изменить подход.
protected boolean transformation(PassCode_2021 code) throws Exception {
task = new File(parentTask, "v1");
Utils.CheckAndCleanDirectory(task); //папка для преобразования.
//если версия пустая, это тоже результат тестирования. Поэтому должна учитываться в древе.
target.versions.add(new SapforVersion_json(task.getAbsolutePath(), code.getDescription()));
//---
if (performSapforScript("transformation", parentTask,
code.getTestingCommand() + " -F " + Utils.DQuotes(task.getAbsolutePath()),
"out.txt",
"err.txt"
Constants.out_file,
Constants.err_file
)) {
target.state = TaskState.Done;
target.versions.add(new SapforVersion_json(task.getAbsolutePath(), code.getDescription()));
parentTask = task;
return true;
}
@@ -145,24 +146,20 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
target.state = TaskState.DoneWithErrors;
return false;
}
protected boolean variants() throws Exception {
if (performSapforScript("create_variants", parentTask, " -t 13 -allVars",
"out.txt",
"err.txt"
)) {
//найти папки с вариантами.
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))));
target.state = TaskState.Done;
for (File file : files)
target.variants.add(new SapforVersion_json(file.getAbsolutePath(), PassCode_2021.SPF_CreateParallelVariant.getDescription()));
return true;
}
protected void variants() throws Exception {
//папки вариантов создается самим сапфором.
target.state = performSapforScript("create_variants", parentTask, " -t 13 -allVars",
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(file.getAbsolutePath(), PassCode_2021.SPF_CreateParallelVariant.getDescription()));
}
target.state = TaskState.DoneWithErrors;
return false;
}
//-------------------------------------------------->>
public MessageError unpackMessage(String line_in) throws Exception {
@@ -281,7 +278,9 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
}
}
}
protected void checkVersion(SapforVersion_json version, boolean isTransformation) throws Exception {
//--
protected void createVersionProjectData(SapforVersion_json version, boolean isTransformation) throws Exception {
System.out.println("Checking version " + version);
db_project_info project = new db_project_info();
project.Home = new File(version.version);
project.name = project.Home.getName();
@@ -292,8 +291,10 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
Vector<MessageError> messages = new Vector<>();
//--
if (isTransformation) {
File p_out = Paths.get(project.Home.getAbsolutePath(), Constants.data, "parse_out.txt").toFile();
File out = Paths.get(project.Home.getAbsolutePath(), Constants.data, "out.txt").toFile();
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));
@@ -303,9 +304,15 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
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();
System.out.println("visualiser data created");
//---
if (isTransformation && !messages.isEmpty()) {
project.Open();
@@ -327,8 +334,9 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
@Override
protected void body() throws Exception {
System.out.println(target.root + " " + Utils.Brackets(sapforConfiguration_json.flags));//!!
target.versions.add(new SapforVersion_json(target.root, "исходная"));
for (PassCode_2021 code : sapforConfiguration_json.codes) {
// System.out.println(code); //!!
System.out.println(code); //!!
if (parse()) {
if (code.equals(PassCode_2021.CreateParallelVariants))
variants();
@@ -337,14 +345,16 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
} else
break;
}
//теперь строим деревья версий.
//System.out.println("Построение дерева версий..");
checkVersion(new SapforVersion_json(target.root, "исходная"), true);
}
@Override
protected void performFinish() throws Exception {
//теперь строим деревья версий. нельзя делать в body. так как могут быть исключения например неверный код процесса.
System.out.println("Построение дерева версий..");
for (SapforVersion_json version : target.versions)
checkVersion(version, true);
createVersionProjectData(version, true);
for (SapforVersion_json version : target.variants)
checkVersion(version, false);
createVersionProjectData(version, false);
//---->>>>
//System.out.println("DONE");
System.out.println("DONE");
}
}