распаковка сообщений от консольного режима. фикс подсчета ошибок,различия считались за ошибки, но для них уже давно есть отдельное поле

++
This commit is contained in:
2025-06-06 14:06:29 +03:00
parent b418066932
commit 3090e80f72
5 changed files with 30 additions and 135 deletions

View File

@@ -3,7 +3,7 @@ import Common.Utils.Vector_;
import java.util.Vector;
public class Constants {
public static final int version = 1250;
public static final int version = 1252;
public static final int planner_version = 24;
public static final int testingMaxKernels = 64;
//--

View File

@@ -8,6 +8,9 @@ import _VisualDVM.ProjectData.Files.FileType;
import _VisualDVM.ProjectData.Files.ProjectFile;
import _VisualDVM.ProjectData.LanguageName;
import _VisualDVM.ProjectData.Messages.Errors.MessageError;
import _VisualDVM.ProjectData.Messages.FileMessagesJson;
import _VisualDVM.ProjectData.Messages.Message;
import _VisualDVM.ProjectData.Messages.MessagesJson;
import _VisualDVM.ProjectData.Project.db_project_info;
import _VisualDVM.TestingSystem.SAPFOR.SapforTask.SapforTask;
import _VisualDVM.Utils;
@@ -187,130 +190,9 @@ public class SapforVersion_json implements Serializable {
ex.printStackTrace();
}
return text1.equalsIgnoreCase(text2);
// if (!Utils.compareFortranTexts(text1, text2)) {
// return false;
// }
}
return true;
}
public MessageError unpackMessage(String line_in) throws Exception {
MessageError res = new MessageError();
res.file = "";
res.line = CommonConstants.Nan;
res.value = "";
String line = line_in.substring(9);
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()) {
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 = res.getGroup_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_ = Utils_.isWindows() ? Utils_.toW(version) : Utils_.toU(version);
@@ -327,20 +209,19 @@ public class SapforVersion_json implements Serializable {
}
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();
File messages_dump = Paths.get(project.Home.getAbsolutePath(), Constants.data, "error_messages.json").toFile();
MessagesJson messagesJson = null;
//--
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())
@@ -348,19 +229,33 @@ public class SapforVersion_json implements Serializable {
if (err.exists())
project.Log += "\n" + FileUtils.readFileToString(err);
//--
if (messages_dump.exists()){
try {
String packed = FileUtils.readFileToString(messages_dump);
messagesJson = Utils_.gson.fromJson(packed, MessagesJson.class);
}
catch (Exception ex){
ex.printStackTrace();
}
}
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);
if (messagesJson!=null){
project.db.BeginTransaction();
//-
for (FileMessagesJson fileMessagesJson: messagesJson.allMessages){
fileMessagesJson.file = Utils_.toW(fileMessagesJson.file);
//--
DBProjectFile file = project.db.files.Data.get(fileMessagesJson.file);
for (Message message: fileMessagesJson.messages) {
file.CreateAndAddNewMessage(1, message.value, message.line, message.group);
}
//update file
project.db.Update(file);
}
project.db.Commit();
}
project.db.Commit();
project.db.Disconnect();
}
}

View File

@@ -195,7 +195,7 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
Print("сравнение завершено");
log.Writeln_("Различий с эталоном: " + testingPackage.mismatchesCount);
if (testingPackage.mismatchesCount > 0) {
testingPackage.doneTasksCount -= testingPackage.mismatchesCount;
// testingPackage.doneTasksCount -= testingPackage.mismatchesCount;
testingPackage.state = TasksPackageState.DoneWithErrors;
}
return;