запись результатов тестирования в файлы. пока думаю как лучше.

This commit is contained in:
2023-09-30 20:56:59 +03:00
parent ccedf38229
commit 793c4b7d93
6 changed files with 27 additions and 19 deletions

3
.idea/workspace.xml generated
View File

@@ -7,6 +7,9 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment=""> <list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/Global.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Global.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTask/SapforTask.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTask/SapforTask.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTest/SapforTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTest/SapforTest.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTest/SapforTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTest/SapforTest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" afterDir="false" />
</list> </list>

View File

@@ -359,8 +359,6 @@ public class Global {
Log.ClearLog(); Log.ClearLog();
SapforTestingPlanner planner = new SapforTestingPlanner(); SapforTestingPlanner planner = new SapforTestingPlanner();
planner.Start(); planner.Start();
System.out.println("Press any key to exit...");
System.in.read();
} }
//--- //---
public static void Init(String... args) { public static void Init(String... args) {

View File

@@ -31,7 +31,6 @@ public class SapforTask extends DBObject {
@Expose @Expose
public TaskState state = TaskState.Inactive; public TaskState state = TaskState.Inactive;
@Description("DEFAULT '0'") @Description("DEFAULT '0'")
@Expose
public int versions_tree_built = 0; public int versions_tree_built = 0;
//----------- //-----------
public SapforTask() { public SapforTask() {

View File

@@ -2,7 +2,10 @@ package SapforTestingSystem.SapforTest;
import Common.Constants.Constants; import Common.Constants.Constants;
import Common.Global; import Common.Global;
import Common.Utils.Utils; import Common.Utils.Utils;
import GlobalData.Tasks.TaskState;
import ProjectData.Project.db_project_info; import ProjectData.Project.db_project_info;
import SapforTestingSystem.Json.SapforVersion_json;
import SapforTestingSystem.SapforTask.SapforTask;
import Visual_DVM_2021.Passes.PassCode_2021; import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.PassException; import Visual_DVM_2021.Passes.PassException;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@@ -31,6 +34,7 @@ public class SapforTest {
Vector<String> outputLines; Vector<String> outputLines;
Vector<String> errorsLines; Vector<String> errorsLines;
//--- //---
public SapforTask taskResult = null;
//--- //---
public SapforTest(File sapfor_drv_in, File root_in, String flags_in, List<PassCode_2021> codes_in) { public SapforTest(File sapfor_drv_in, File root_in, String flags_in, List<PassCode_2021> codes_in) {
sapfor_drv = sapfor_drv_in; sapfor_drv = sapfor_drv_in;
@@ -63,7 +67,7 @@ public class SapforTest {
Utils.delete_with_check(outputFile); Utils.delete_with_check(outputFile);
Utils.delete_with_check(errorsFile); Utils.delete_with_check(errorsFile);
//--- //---
File file = new File(data_workspace, name + (Global.isWindows?".bat":".sh")); File file = new File(data_workspace, name + (Global.isWindows ? ".bat" : ".sh"));
FileUtils.write(file, FileUtils.write(file,
Utils.DQuotes(sapfor_drv.getAbsolutePath()) Utils.DQuotes(sapfor_drv.getAbsolutePath())
+ (flags.isEmpty() ? "" : (" " + flags)) + (flags.isEmpty() ? "" : (" " + flags))
@@ -96,7 +100,7 @@ public class SapforTest {
&& (new File(parentTask, "dvm.proj")).exists()) { && (new File(parentTask, "dvm.proj")).exists()) {
return true; return true;
} else { } else {
// taskResult.state = TaskState.DoneWithErrors; taskResult.state = TaskState.DoneWithErrors;
return false; return false;
} }
} }
@@ -108,13 +112,13 @@ public class SapforTest {
"out.txt", "out.txt",
"err.txt" "err.txt"
)) { )) {
//taskResult.state = TaskState.Done; taskResult.state = TaskState.Done;
//taskResult.versions.add(new SapforVersion_json(task.getAbsolutePath(), code.getDescription())); taskResult.versions.add(new SapforVersion_json(task.getAbsolutePath(), code.getDescription()));
parentTask = task; parentTask = task;
return true; return true;
} }
Utils.delete_with_check(task); Utils.delete_with_check(task);
// taskResult.state = TaskState.DoneWithErrors; taskResult.state = TaskState.DoneWithErrors;
return false; return false;
} }
protected boolean variants() throws Exception { protected boolean variants() throws Exception {
@@ -127,24 +131,22 @@ public class SapforTest {
if ((files_ != null) && (files_.length > 0)) { if ((files_ != null) && (files_.length > 0)) {
Vector<File> files = new Vector<>(Arrays.asList(files_)); Vector<File> files = new Vector<>(Arrays.asList(files_));
files.sort(Comparator.comparingInt(o -> Integer.parseInt(o.getName().substring(1)))); files.sort(Comparator.comparingInt(o -> Integer.parseInt(o.getName().substring(1))));
/*
taskResult.state = TaskState.Done; taskResult.state = TaskState.Done;
for (File file : files) for (File file : files)
taskResult.variants.add(new SapforVersion_json(file.getAbsolutePath(), PassCode_2021.SPF_CreateParallelVariant.getDescription())); taskResult.variants.add(new SapforVersion_json(file.getAbsolutePath(), PassCode_2021.SPF_CreateParallelVariant.getDescription()));
*/
return true; return true;
} }
} }
// taskResult.state = TaskState.DoneWithErrors; taskResult.state = TaskState.DoneWithErrors;
return false; return false;
} }
public void Do() throws Exception { public void Do() throws Exception {
parentTask = root; parentTask = root;
//-- //--
// taskResult = new SapforTask(); taskResult = new SapforTask();
// taskResult.test_description = test; taskResult.test_description = root.getName();
// taskResult.sapfortaskspackage_2023_id = Integer.parseInt(packageWorkspace.getName()); taskResult.sapfortaskspackage_2023_id = Integer.parseInt(root.getParentFile().getName());
// taskResult.versions.add(new SapforVersion_json(parentTask.getAbsolutePath(), "исходная")); taskResult.versions.add(new SapforVersion_json(parentTask.getAbsolutePath(), "исходная"));
//-- //--
System.out.println(root.getName() + " " + Utils.Brackets(flags)); System.out.println(root.getName() + " " + Utils.Brackets(flags));
for (PassCode_2021 code : codes) { for (PassCode_2021 code : codes) {
@@ -157,7 +159,9 @@ public class SapforTest {
} else } else
break; break;
} }
//--- //Запись результатов.
//results.tasks.add(taskResult); File data_workspace = new File(root, db_project_info.data);
Utils.CheckDirectory(data_workspace);
Utils.jsonToFile(taskResult, new File(data_workspace, "result.txt"));
} }
} }

View File

@@ -42,4 +42,8 @@ public class SapforTestingPlanner extends ThreadsPlanner {
//todo для надежности сделать еще один kill с внешнего процесса. //todo для надежности сделать еще один kill с внешнего процесса.
// может быть гонка, что нить успеет запустить процесс уже после интеррупта. // может быть гонка, что нить успеет запустить процесс уже после интеррупта.
} }
@Override
protected void finalize() {
System.exit(0);
}
} }

View File

@@ -228,8 +228,8 @@ public class StartSapforTests extends Pass_2021<SapforScenario> {
ShowMessage2("Создание настроек"); ShowMessage2("Создание настроек");
GlobalProperties properties = new GlobalProperties(); GlobalProperties properties = new GlobalProperties();
properties.Mode = Current.Mode.Scenario; properties.Mode = Current.Mode.Scenario;
properties.threadsNum = 1; properties.threadsNum = 4;
properties.threadsTimeout = 5000; properties.threadsTimeout = 2000;
//---- //----
Utils.jsonToFile(properties, new File(target.workspace, "properties")); Utils.jsonToFile(properties, new File(target.workspace, "properties"));
//---- //----