построение дерева версий результатов тестирования(еще с багами), и фикс мелкого бага
This commit is contained in:
@@ -3,6 +3,9 @@ import Common.Constants;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.Tasks.TaskState;
|
||||
import ProjectData.Files.DBProjectFile;
|
||||
import ProjectData.LanguageName;
|
||||
import ProjectData.Messages.Errors.MessageError;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import SapforTestingSystem.Json.SapforConfiguration_json;
|
||||
import SapforTestingSystem.Json.SapforVersion_json;
|
||||
@@ -18,6 +21,8 @@ import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Vector;
|
||||
|
||||
import static java.lang.Character.isDigit;
|
||||
public class PerformSapforTask extends Pass_2021<SapforTask> {
|
||||
@Override
|
||||
public String getDescription() {
|
||||
@@ -69,6 +74,9 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
|
||||
if (line.contains("[ERROR]")) {
|
||||
return false;
|
||||
}
|
||||
if (line.toLowerCase().contains("segmentation fault")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -76,7 +84,7 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
|
||||
process = null;
|
||||
exit_code = Constants.Nan;
|
||||
//---
|
||||
File data_workspace = new File(workspace, db_project_info.data);
|
||||
File data_workspace = new File(workspace, Constants.data);
|
||||
Utils.CheckDirectory(data_workspace);
|
||||
outputFile = new File(data_workspace, outName);
|
||||
errorsFile = new File(data_workspace, errName);
|
||||
@@ -156,11 +164,171 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
|
||||
target.state = TaskState.DoneWithErrors;
|
||||
return false;
|
||||
}
|
||||
//-------------------------------------------------->>
|
||||
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 checkVersion(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, "parse_out.txt").toFile();
|
||||
File out = Paths.get(project.Home.getAbsolutePath(), Constants.data, "out.txt").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);
|
||||
}
|
||||
//--
|
||||
}
|
||||
project.CreateVisualiserData();
|
||||
//---
|
||||
if (isTransformation && !messages.isEmpty()) {
|
||||
project.Open();
|
||||
project.db.BeginTransaction();
|
||||
// System.out.println("messages size=" + messages.size());
|
||||
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 {
|
||||
System.out.println(target.root + " " + Utils.Brackets(sapforConfiguration_json.flags));//!!
|
||||
for (PassCode_2021 code : sapforConfiguration_json.codes) {
|
||||
System.out.println(code); //!!
|
||||
// System.out.println(code); //!!
|
||||
if (parse()) {
|
||||
if (code.equals(PassCode_2021.CreateParallelVariants))
|
||||
variants();
|
||||
@@ -170,7 +338,13 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
|
||||
break;
|
||||
}
|
||||
//теперь строим деревья версий.
|
||||
|
||||
|
||||
//System.out.println("Построение дерева версий..");
|
||||
checkVersion(new SapforVersion_json(target.root, "исходная"), true);
|
||||
for (SapforVersion_json version : target.versions)
|
||||
checkVersion(version, true);
|
||||
for (SapforVersion_json version : target.variants)
|
||||
checkVersion(version, false);
|
||||
//---->>>>
|
||||
//System.out.println("DONE");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user