Рефакторинг конструкторов объектов тестирования.
This commit is contained in:
@@ -2,7 +2,7 @@ package Visual_DVM_2021.Passes.All;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.UI.UI;
|
||||
import Common.UI.VisualCache.ConfigurationCache;
|
||||
import Common.UI.VisualCache.DVMConfigurationCache;
|
||||
import Common.UI.VisualCache.VisualCaches;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.Compiler.CompilerType;
|
||||
@@ -13,6 +13,7 @@ import TestingSystem.Common.Test.Test;
|
||||
import TestingSystem.Common.TestingServer;
|
||||
import TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
|
||||
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
import TestingSystem.DVM.DVMSettings.DVMSettings;
|
||||
import TestingSystem.DVM.DVMTasks.DVMCompilationTask;
|
||||
import TestingSystem.DVM.DVMTasks.DVMRunTask;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
@@ -21,12 +22,6 @@ import Visual_DVM_2021.Passes.Server.PublishServerObject;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class StartSelectedDVMConfigurations extends PublishServerObject<TestingServer, DVMPackage> {
|
||||
Vector<DVMConfiguration> configurations;
|
||||
Vector<Group> groups;
|
||||
Vector<Test> tests;
|
||||
LinkedHashMap<Integer, Vector<Test>> testByGroups;
|
||||
Vector<DVMCompilationTask> tasks;
|
||||
int tasks_count;
|
||||
public StartSelectedDVMConfigurations() {
|
||||
super(Global.testingServer, DVMPackage.class);
|
||||
}
|
||||
@@ -35,89 +30,11 @@ public class StartSelectedDVMConfigurations extends PublishServerObject<TestingS
|
||||
return "/icons/Start.png";
|
||||
}
|
||||
//--
|
||||
public static String checkFlags(String flags_in) {
|
||||
if (!flags_in.contains("-shared-dvm")) {
|
||||
if (flags_in.isEmpty())
|
||||
return "-shared-dvm";
|
||||
else return flags_in + " -shared-dvm";
|
||||
} else
|
||||
return flags_in;
|
||||
}
|
||||
public static String checkEnvironments(String environmentsSet_in) {
|
||||
if (!environmentsSet_in.contains("DVMH_NO_DIRECT_COPY")) {
|
||||
if (environmentsSet_in.isEmpty())
|
||||
return "DVMH_NO_DIRECT_COPY=" + Utils.DQuotes("1");
|
||||
else
|
||||
return environmentsSet_in + " " + "DVMH_NO_DIRECT_COPY=" + Utils.DQuotes("1");
|
||||
} else
|
||||
return environmentsSet_in;
|
||||
}
|
||||
//--
|
||||
public Vector<DVMCompilationTask> createTasksCGT(
|
||||
DVMConfiguration configuration,
|
||||
Group group,
|
||||
Test test
|
||||
) {
|
||||
Vector<DVMCompilationTask> compilationTasks = new Vector<>();
|
||||
for (String flags : configuration.getFlagsArray()) {
|
||||
String checked_flags = checkFlags(flags);
|
||||
DVMCompilationTask dvmCompilationTask = new DVMCompilationTask(
|
||||
configuration,
|
||||
group,
|
||||
test,
|
||||
checked_flags
|
||||
);
|
||||
Vector<String> matrixes = configuration.getMatrixes(test.max_dim);
|
||||
Vector<String> environments = configuration.getEnvironments();
|
||||
for (String environmentSet : environments) {
|
||||
String checkedEnvironments = checkEnvironments(environmentSet);
|
||||
if (flags.trim().equalsIgnoreCase("-s")) {
|
||||
dvmCompilationTask.runTasks.add(new DVMRunTask(
|
||||
configuration,
|
||||
group,
|
||||
test,
|
||||
"",
|
||||
checked_flags,
|
||||
checkedEnvironments,
|
||||
configuration.getParamsText(),
|
||||
target.kernels
|
||||
));
|
||||
tasks_count++;
|
||||
} else
|
||||
for (String matrix : matrixes) {
|
||||
dvmCompilationTask.runTasks.add(new DVMRunTask(
|
||||
configuration,
|
||||
group,
|
||||
test,
|
||||
matrix,
|
||||
checked_flags,
|
||||
checkedEnvironments,
|
||||
configuration.getParamsText(),
|
||||
target.kernels));
|
||||
tasks_count++;
|
||||
}
|
||||
}
|
||||
compilationTasks.add(dvmCompilationTask);
|
||||
}
|
||||
return compilationTasks;
|
||||
}
|
||||
//--
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
configurations = Global.testingServer.db.dvm_configurations.getCheckedOrCurrent();
|
||||
groups = new Vector<>();
|
||||
tests = new Vector<>();
|
||||
testByGroups = new LinkedHashMap<>();
|
||||
tasks = new Vector<>();
|
||||
tasks_count = 0;
|
||||
//---
|
||||
if (!Current.getAccount().CheckRegistered(Log)) {
|
||||
return false;
|
||||
}
|
||||
if (configurations.isEmpty()) {
|
||||
Log.Writeln_("Не отмечено ни одной конфигурации, или отсутствует текущая конфигурация.");
|
||||
return false;
|
||||
}
|
||||
if (!Current.Check(Log, Current.Machine, Current.User, Current.Compiler))
|
||||
return false;
|
||||
if (!Current.getMachine().type.equals(MachineType.Server)) {
|
||||
@@ -134,50 +51,26 @@ public class StartSelectedDVMConfigurations extends PublishServerObject<TestingS
|
||||
}
|
||||
if (!Current.getCompiler().versionLoaded)
|
||||
passes.get(PassCode_2021.ShowCompilerVersion).Do(Current.getCompiler(), false);
|
||||
//--
|
||||
int max_kernels = 1;
|
||||
for (DVMConfiguration configuration : configurations){
|
||||
max_kernels = Math.max(configuration.kernels, max_kernels);
|
||||
//-----
|
||||
Vector<DVMConfiguration> configurations = Global.testingServer.db.dvm_configurations.getCheckedOrCurrent();
|
||||
if (configurations.isEmpty()) {
|
||||
Log.Writeln_("Не отмечено ни одной конфигурации, или отсутствует текущая конфигурация.");
|
||||
return false;
|
||||
}
|
||||
target = new DVMPackage(
|
||||
//---
|
||||
target= new DVMPackage(
|
||||
Current.getAccount(),
|
||||
Current.getMachine(),
|
||||
Current.getUser(),
|
||||
Current.getCompiler(),
|
||||
max_kernels
|
||||
);
|
||||
for (DVMConfiguration configuration : configurations) {
|
||||
ConfigurationCache cache = (ConfigurationCache) VisualCaches.GetCache(configuration);
|
||||
groups = cache.getGroups();
|
||||
tests = cache.getTests();
|
||||
//-
|
||||
for (Group group : groups) {
|
||||
Vector<Test> groupTests = new Vector<>();
|
||||
for (Test test : tests) {
|
||||
if (test.group_id == group.id)
|
||||
groupTests.add(test);
|
||||
}
|
||||
testByGroups.put(group.id, groupTests);
|
||||
}
|
||||
//--
|
||||
for (Group group : groups) {
|
||||
Vector<Test> groupTests = testByGroups.get(group.id);
|
||||
for (Test test : groupTests)
|
||||
tasks.addAll(createTasksCGT(configuration, group, test));
|
||||
}
|
||||
}
|
||||
|
||||
configurations,
|
||||
Global.properties.EmailOnTestingProgress ? 1 : 0
|
||||
);
|
||||
//----
|
||||
|
||||
if (tasks_count == 0) {
|
||||
if (target.tasksCount == 0) {
|
||||
Log.Writeln_("Задач не найдено.");
|
||||
return false;
|
||||
}
|
||||
if (UI.Question("Будет запущено " + tasks_count + " задач. Продолжить")){
|
||||
target.saveConfigurationsAsJson(configurations);
|
||||
target.saveTasks(tasks, tasks_count);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return UI.Question("Будет запущено " + target.tasksCount + " задач. Продолжить");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user