2023-11-19 02:12:44 +03:00
|
|
|
|
package TestingSystem.SAPFOR;
|
2023-10-04 22:01:09 +03:00
|
|
|
|
import Common.Constants;
|
2023-09-30 18:22:14 +03:00
|
|
|
|
import Common.Global;
|
2023-09-30 00:18:44 +03:00
|
|
|
|
import Common.Utils.Utils;
|
2023-09-30 20:56:59 +03:00
|
|
|
|
import GlobalData.Tasks.TaskState;
|
2023-11-24 00:23:12 +03:00
|
|
|
|
import Repository.Component.Sapfor.Sapfor;
|
2023-11-19 02:12:44 +03:00
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
|
|
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforVersion_json;
|
|
|
|
|
|
import TestingSystem.SAPFOR.SapforTask.SapforTask;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.Pass_2021;
|
2023-09-22 00:16:46 +03:00
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
2023-09-30 22:02:58 +03:00
|
|
|
|
import java.nio.file.Paths;
|
2023-09-30 00:18:44 +03:00
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
import java.util.Comparator;
|
2023-11-14 17:35:59 +03:00
|
|
|
|
import java.util.Date;
|
2023-09-30 00:18:44 +03:00
|
|
|
|
import java.util.Vector;
|
2023-09-30 22:02:58 +03:00
|
|
|
|
public class PerformSapforTask extends Pass_2021<SapforTask> {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getDescription() {
|
2023-11-14 16:19:31 +03:00
|
|
|
|
return "";
|
|
|
|
|
|
// "Запуск задачи SAPFOR"; Оставляем пустое описание чтобы не засорять журнал.
|
2023-09-30 22:02:58 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean needsAnimation() {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
2023-09-30 00:18:44 +03:00
|
|
|
|
File sapfor_drv;
|
2023-10-04 00:25:36 +03:00
|
|
|
|
SapforConfiguration_json sapforConfiguration_json;
|
2023-09-30 00:18:44 +03:00
|
|
|
|
//-----
|
2023-10-29 01:03:37 +03:00
|
|
|
|
File root;
|
2023-09-30 00:18:44 +03:00
|
|
|
|
File parentTask;
|
|
|
|
|
|
File task;
|
|
|
|
|
|
//-----
|
2023-09-30 22:02:58 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
|
|
|
|
sapfor_drv = (File) args[0];
|
2023-10-04 00:25:36 +03:00
|
|
|
|
sapforConfiguration_json = (SapforConfiguration_json) args[1];
|
2023-10-18 22:16:22 +03:00
|
|
|
|
target = (SapforTask) args[2];
|
2023-09-30 22:02:58 +03:00
|
|
|
|
//--->>
|
2023-11-17 22:03:13 +03:00
|
|
|
|
parentTask = Paths.get(Global.Home, String.valueOf(sapforConfiguration_json.id), target.test_description).toFile();
|
|
|
|
|
|
root = new File(Global.Home, String.valueOf(sapforConfiguration_json.id));
|
2023-09-30 22:02:58 +03:00
|
|
|
|
task = null;
|
|
|
|
|
|
//--->>
|
|
|
|
|
|
return true;
|
2023-11-24 00:23:12 +03:00
|
|
|
|
}
|
2023-09-30 00:18:44 +03:00
|
|
|
|
protected boolean parse() throws Exception {
|
2023-11-24 00:23:12 +03:00
|
|
|
|
if (Sapfor.performScript(
|
|
|
|
|
|
"parse",
|
|
|
|
|
|
sapfor_drv,
|
|
|
|
|
|
parentTask,
|
2023-09-30 00:18:44 +03:00
|
|
|
|
"-parse *.f *.for *.fdv *.f90 *.f77",
|
2023-11-24 00:23:12 +03:00
|
|
|
|
target.flags,
|
2023-10-07 00:45:09 +03:00
|
|
|
|
Constants.parse_out_file,
|
|
|
|
|
|
Constants.parse_err_file)
|
2023-09-30 00:18:44 +03:00
|
|
|
|
&& (new File(parentTask, "dvm.proj")).exists()) {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
} else {
|
2023-09-30 22:02:58 +03:00
|
|
|
|
target.state = TaskState.DoneWithErrors;
|
2023-09-30 00:18:44 +03:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-10-07 00:45:09 +03:00
|
|
|
|
//слегка изменить подход.
|
2023-09-30 00:18:44 +03:00
|
|
|
|
protected boolean transformation(PassCode_2021 code) throws Exception {
|
|
|
|
|
|
task = new File(parentTask, "v1");
|
|
|
|
|
|
Utils.CheckAndCleanDirectory(task); //папка для преобразования.
|
2023-10-07 00:45:09 +03:00
|
|
|
|
//если версия пустая, это тоже результат тестирования. Поэтому должна учитываться в древе.
|
2023-10-29 01:03:37 +03:00
|
|
|
|
target.versions.add(new SapforVersion_json(
|
|
|
|
|
|
root.getAbsolutePath(),
|
|
|
|
|
|
task.getAbsolutePath(), code.getDescription()));
|
2023-10-07 00:45:09 +03:00
|
|
|
|
//---
|
2023-11-24 00:23:12 +03:00
|
|
|
|
if (Sapfor.performScript(
|
|
|
|
|
|
"transformation",
|
|
|
|
|
|
sapfor_drv,
|
|
|
|
|
|
parentTask,
|
2023-09-30 00:18:44 +03:00
|
|
|
|
code.getTestingCommand() + " -F " + Utils.DQuotes(task.getAbsolutePath()),
|
2023-11-24 00:23:12 +03:00
|
|
|
|
target.flags,
|
2023-10-07 00:45:09 +03:00
|
|
|
|
Constants.out_file,
|
|
|
|
|
|
Constants.err_file
|
2023-09-30 00:18:44 +03:00
|
|
|
|
)) {
|
2023-09-30 22:02:58 +03:00
|
|
|
|
target.state = TaskState.Done;
|
2023-09-30 00:18:44 +03:00
|
|
|
|
parentTask = task;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2023-09-30 22:02:58 +03:00
|
|
|
|
target.state = TaskState.DoneWithErrors;
|
2023-09-30 00:18:44 +03:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2023-10-07 00:45:09 +03:00
|
|
|
|
protected void variants() throws Exception {
|
|
|
|
|
|
//папки вариантов создается самим сапфором.
|
2023-11-24 00:23:12 +03:00
|
|
|
|
target.state = Sapfor.performScript(
|
|
|
|
|
|
"create_variants",
|
|
|
|
|
|
sapfor_drv,
|
|
|
|
|
|
parentTask,
|
|
|
|
|
|
" -t 13 -allVars -tinfo",
|
|
|
|
|
|
target.flags,
|
2023-10-07 00:45:09 +03:00
|
|
|
|
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)
|
2023-10-29 01:03:37 +03:00
|
|
|
|
target.variants.add(
|
|
|
|
|
|
|
|
|
|
|
|
new SapforVersion_json(
|
|
|
|
|
|
root.getAbsolutePath(),
|
|
|
|
|
|
file.getAbsolutePath(), PassCode_2021.SPF_CreateParallelVariant.getDescription()));
|
2023-09-30 00:18:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-10-06 22:51:09 +03:00
|
|
|
|
//-------------------------------------------------->>
|
2023-09-30 22:02:58 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
protected void body() throws Exception {
|
2023-11-14 17:35:59 +03:00
|
|
|
|
target.StartDate = new Date().getTime();
|
2023-11-20 20:17:59 +03:00
|
|
|
|
target.versions.add(new SapforVersion_json(target.test_description, ""));
|
2023-10-04 00:25:36 +03:00
|
|
|
|
for (PassCode_2021 code : sapforConfiguration_json.codes) {
|
2023-09-30 00:18:44 +03:00
|
|
|
|
if (parse()) {
|
|
|
|
|
|
if (code.equals(PassCode_2021.CreateParallelVariants))
|
|
|
|
|
|
variants();
|
|
|
|
|
|
else if (!transformation(code))
|
|
|
|
|
|
break;
|
|
|
|
|
|
} else
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2023-11-14 17:35:59 +03:00
|
|
|
|
target.ChangeDate = new Date().getTime();
|
2023-10-07 00:45:09 +03:00
|
|
|
|
}
|
2023-09-21 21:17:02 +03:00
|
|
|
|
}
|