исправил баг с запуском процессов. иногда файл скриптов запускался не сразу из за запоздалого закрытия fileutils.write

This commit is contained in:
2023-10-23 01:32:28 +03:00
parent 19370c60d9
commit 82df491e29
5 changed files with 41 additions and 15 deletions

2
.idea/workspace.xml generated
View File

@@ -9,7 +9,9 @@
<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/SapforTestingSystem/PackageModeSupervisor/PackageModeSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/PackageModeSupervisor/PackageModeSupervisor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/PerformSapforTask.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/PerformSapforTask.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/TestingSystem/TestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/TestingPlanner.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -36,17 +36,20 @@ public class PackageModeSupervisor extends ThreadsPlanner {
task.sapfor_configuration_id = sapforConfiguration_json.id;
results_json.tasks.add(task);
//---
addThread(() -> new PerformSapforTask().Do(
sapfor_drv,
sapforConfiguration_json,
task
));
addThread(() -> {
while (!task.state.isComplete()) {
task.Reset();
new PerformSapforTask().Do(
sapfor_drv,
sapforConfiguration_json,
task
);
}
});
}
}
interruptThread.start();
}
void getTaskFiles(SapforTask task) throws Exception {
}
@Override
protected void finalize() {
results_json.EndDate = new Date().getTime();

View File

@@ -100,15 +100,27 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
if (!file.setExecutable(true))
throw new Exception("Не удалось сделать файл скрипта " + name + " исполняемым!");
//--
ProcessBuilder procBuilder = new ProcessBuilder(file.getAbsolutePath());
procBuilder.directory(workspace);
process = procBuilder.start();
exit_code = process.waitFor();
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);
return (exit_code == 0) &&
checkLines(outputLines) &&
checkLines(errorsLines);
}
protected boolean parse() throws Exception {
if (performSapforScript("parse", parentTask,

View File

@@ -53,6 +53,13 @@ public class SapforTask extends DBObject {
//-----------
public SapforTask() {
}
public void Reset(){
root="";
state = TaskState.Inactive;
files.clear();
versions.clear();
variants.clear();
}
public SapforTask(SapforTask src) {
this.SynchronizeFields(src);
}

View File

@@ -277,13 +277,13 @@ public class TestingPlanner {
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByFlags = sortedTasks.get(state);
if (!tasksByFlags.isEmpty()) {
int count = 0;
if (state.equals(TaskState.DoneWithErrors)) {
if (!state.equals(TaskState.Done)) {
Vector<String> flagsLines = new Vector<>();
for (String flags : tasksByFlags.keySet()) {
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByFlags.get(flags);
for (String group : tasksByGroups.keySet()) {
Vector<SapforTask> tasks = tasksByGroups.get(group);
flagsLines.add("Группа " + group + ": "+tasks.size());
flagsLines.add("Группа " + group + ": " + tasks.size());
count += tasks.size();
for (SapforTask task : tasks)
flagsLines.add(
@@ -292,7 +292,9 @@ public class TestingPlanner {
"флаги: "
+ Utils.Brackets(flags) + " " +
"версии: " +
task.getVersionsChain());
task.getVersionsChain() + " " +
"конфигурация " + task.sapfor_configuration_id
);
}
}
result_lines.add(state.getDescription() + " :" + count);