проверка версии модулей в стадии - создание рабочих папок пакета. Если версия не найдена, или меньше актуальной, модули будут пересобраны.
This commit is contained in:
@@ -9,12 +9,12 @@ import GlobalData.User.User;
|
||||
import ProjectData.Files.ProjectFile;
|
||||
import ProjectData.LanguageName;
|
||||
import Repository.Server.ServerCode;
|
||||
import TestingSystem.Common.TasksPackageState;
|
||||
import TestingSystem.Common.TestingPlanner;
|
||||
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
import TestingSystem.DVM.DVMTasks.DVMCompilationTask;
|
||||
import TestingSystem.DVM.DVMTasks.DVMRunTask;
|
||||
import TestingSystem.DVM.DVMTasks.DVMTask;
|
||||
import TestingSystem.Common.TasksPackageState;
|
||||
import Visual_DVM_2021.Passes.All.UnzipFolderPass;
|
||||
import files.ConnectionPass;
|
||||
import javafx.util.Pair;
|
||||
@@ -67,21 +67,12 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
ProjectFile projectFile = new ProjectFile(new File(file.getName()));
|
||||
if (projectFile.isNotExcludedProgram())
|
||||
res.get(projectFile.languageName).add(projectFile);
|
||||
if (projectFile.isNotExcludedProgram()) res.get(projectFile.languageName).add(projectFile);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
static void generateForLanguage(
|
||||
String dvm_drv,
|
||||
LanguageName language,
|
||||
Vector<ProjectFile> language_programs,
|
||||
Vector<String> titles,
|
||||
Vector<String> objects,
|
||||
Vector<String> bodies,
|
||||
String flags
|
||||
) {
|
||||
static void generateForLanguage(String dvm_drv, LanguageName language, Vector<ProjectFile> language_programs, Vector<String> titles, Vector<String> objects, Vector<String> bodies, String flags) {
|
||||
if (!language_programs.isEmpty()) {
|
||||
String LANG_ = language.toString().toUpperCase() + "_";
|
||||
Vector<String> module_objects = new Vector<>();
|
||||
@@ -91,27 +82,10 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
||||
//--
|
||||
String object = Utils.DQuotes(language + "_" + i + ".o");
|
||||
module_objects.add(object);
|
||||
module_body +=
|
||||
object + ":\n" +
|
||||
"\t" +
|
||||
String.join(" ",
|
||||
Utils.MFVar(LANG_ + "COMMAND"),
|
||||
Utils.MFVar(LANG_ + "FLAGS"),
|
||||
program.getStyleOptions(),
|
||||
"-c",
|
||||
program.getQSourceName(),
|
||||
"-o",
|
||||
object + "\n\n"
|
||||
);
|
||||
module_body += object + ":\n" + "\t" + String.join(" ", Utils.MFVar(LANG_ + "COMMAND"), Utils.MFVar(LANG_ + "FLAGS"), program.getStyleOptions(), "-c", program.getQSourceName(), "-o", object + "\n\n");
|
||||
++i;
|
||||
}
|
||||
titles.add(String.join("\n",
|
||||
LANG_ + "COMMAND=" + Utils.DQuotes(dvm_drv) + " " +
|
||||
language.getDVMCompile(),
|
||||
LANG_ + "FLAGS=" + flags,
|
||||
LANG_ + "OBJECTS=" + String.join(" ", module_objects),
|
||||
""
|
||||
));
|
||||
titles.add(String.join("\n", LANG_ + "COMMAND=" + Utils.DQuotes(dvm_drv) + " " + language.getDVMCompile(), LANG_ + "FLAGS=" + flags, LANG_ + "OBJECTS=" + String.join(" ", module_objects), ""));
|
||||
objects.add(Utils.MFVar(LANG_ + "OBJECTS"));
|
||||
bodies.add(module_body);
|
||||
}
|
||||
@@ -128,15 +102,7 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
||||
generateForLanguage(dvm_drv, languageName, programs.get(languageName), titles, objects, bodies, flags);
|
||||
}
|
||||
//----->>
|
||||
return String.join("\n",
|
||||
"LINK_COMMAND=" + Utils.DQuotes(dvm_drv) + " " +
|
||||
test_language.getDVMLink(),
|
||||
"LINK_FLAGS=" + flags + "\n",
|
||||
String.join("\n", titles),
|
||||
"all: " + binary,
|
||||
binary + " : " + String.join(" ", objects),
|
||||
"\t" + Utils.MFVar("LINK_COMMAND") + " " + Utils.MFVar("LINK_FLAGS") + " " + String.join(" ", objects) + " -o " + binary,
|
||||
String.join(" ", bodies));
|
||||
return String.join("\n", "LINK_COMMAND=" + Utils.DQuotes(dvm_drv) + " " + test_language.getDVMLink(), "LINK_FLAGS=" + flags + "\n", String.join("\n", titles), "all: " + binary, binary + " : " + String.join(" ", objects), "\t" + Utils.MFVar("LINK_COMMAND") + " " + Utils.MFVar("LINK_FLAGS") + " " + String.join(" ", objects) + " -o " + binary, String.join(" ", bodies));
|
||||
}
|
||||
public void getTasksInfo(List<? extends DVMTask> tasks, String file_name) throws Exception {
|
||||
LinkedHashMap<Integer, DVMTask> sorted_tasks = new LinkedHashMap<>();
|
||||
@@ -189,6 +155,10 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
||||
}
|
||||
@Override
|
||||
protected void PackageWorkspaceCreation() throws Exception {
|
||||
if (!CheckModules()) {
|
||||
return;
|
||||
}
|
||||
//--
|
||||
testingPackage.readJson();
|
||||
//--
|
||||
LinkedHashMap<Integer, File> tests = getTestsFromJson();
|
||||
@@ -213,16 +183,8 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
||||
@Override
|
||||
protected void PackageStart() throws Exception {
|
||||
user.connection.ShellCommand("ulimit -s unlimited"); // нужно, для запуска сишной части.
|
||||
String plannerStartCommand =
|
||||
String.join(" ",
|
||||
"nohup",
|
||||
Utils.DQuotes(getPlanner()),
|
||||
Utils.DQuotes(user.workspace),
|
||||
Utils.DQuotes(packageRemoteWorkspace.full_name),
|
||||
Utils.DQuotes(testingPackage.kernels),
|
||||
Utils.DQuotes(testingPackage.drv),
|
||||
"&"
|
||||
);
|
||||
///--
|
||||
String plannerStartCommand = String.join(" ", "nohup", Utils.DQuotes(getPlanner()), Utils.DQuotes(user.workspace), Utils.DQuotes(packageRemoteWorkspace.full_name), Utils.DQuotes(testingPackage.kernels), Utils.DQuotes(testingPackage.drv), "&");
|
||||
user.connection.ShellCommand(plannerStartCommand);
|
||||
RemoteFile PID = new RemoteFile(packageRemoteWorkspace, "PID");
|
||||
RemoteFile STARTED = new RemoteFile(packageRemoteWorkspace, "STARTED");
|
||||
@@ -236,7 +198,6 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
||||
}
|
||||
@Override
|
||||
protected boolean CheckNextState() throws Exception {
|
||||
|
||||
boolean progress_changed = false;
|
||||
boolean state_changed = false;
|
||||
RemoteFile progress = new RemoteFile(packageRemoteWorkspace, "progress");
|
||||
@@ -244,7 +205,7 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
||||
String s = user.connection.readFromFile(progress);
|
||||
int current_progress = Integer.parseInt(s);
|
||||
if (current_progress != testingPackage.progress) {
|
||||
Print("progress changed: "+current_progress);
|
||||
Print("progress changed: " + current_progress);
|
||||
testingPackage.progress = current_progress;
|
||||
progress_changed = true;
|
||||
}
|
||||
@@ -264,7 +225,7 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
||||
}
|
||||
//--
|
||||
user.connection.iterations++;
|
||||
if (user.connection.iterations==100) {
|
||||
if (user.connection.iterations == 100) {
|
||||
Disconnect();
|
||||
}
|
||||
//--
|
||||
@@ -284,8 +245,7 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
||||
}
|
||||
//todo привязать это к настройкам, чтобы можно было включать/выключать удаление.
|
||||
//получили результат. теперь уничтожаем папку пакета на целевой машине.
|
||||
|
||||
if ( user.connection.Exists(packageRemoteWorkspace)){
|
||||
if (user.connection.Exists(packageRemoteWorkspace)) {
|
||||
user.connection.RMDIR(packageRemoteWorkspace.full_name);
|
||||
}
|
||||
}
|
||||
@@ -364,10 +324,8 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
||||
@Override
|
||||
protected void InitSessionCredentials() {
|
||||
String machine_url = testingPackage.machine_address + ":" + testingPackage.machine_port;
|
||||
if (!machines.containsKey(machine_url))
|
||||
machines.put(machine_url, testingPackage.getMachine());
|
||||
if (!users.containsKey(testingPackage.user_name))
|
||||
users.put(testingPackage.user_name, testingPackage.getUser());
|
||||
if (!machines.containsKey(machine_url)) machines.put(machine_url, testingPackage.getMachine());
|
||||
if (!users.containsKey(testingPackage.user_name)) users.put(testingPackage.user_name, testingPackage.getUser());
|
||||
//-->>
|
||||
machine = machines.get(machine_url);
|
||||
user = users.get(testingPackage.user_name);
|
||||
@@ -377,7 +335,7 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
||||
}
|
||||
@Override
|
||||
protected boolean Connect() {
|
||||
if (user.connection==null) {
|
||||
if (user.connection == null) {
|
||||
try {
|
||||
user.connection = new UserConnection(machine, user);
|
||||
Print("Соединение c " + machine.getURL() + " " + user.login + " успешно установлено.");
|
||||
@@ -396,5 +354,34 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
||||
user.connection = null;
|
||||
}
|
||||
}
|
||||
//--
|
||||
//todo потом обобщить и для одиночных запусков. если понадобится.
|
||||
protected boolean CheckModules() throws Exception {
|
||||
RemoteFile modulesDirectory = new RemoteFile(user.workspace, "modules");
|
||||
RemoteFile version = new RemoteFile(modulesDirectory, "version.h");
|
||||
int current_version = Constants.Nan;
|
||||
int actual_version = Constants.planner_version;
|
||||
if (user.connection.Exists(version)) {
|
||||
try {
|
||||
current_version = Integer.parseInt(user.connection.readFromFile(version));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (current_version < actual_version) {
|
||||
Print("Закачка кода модулей...");
|
||||
for (String resource_name : Constants.resourses_names) {
|
||||
Print(resource_name);
|
||||
user.connection.putResource(modulesDirectory, resource_name);
|
||||
}
|
||||
//--
|
||||
Print("Сборка модулей...");
|
||||
String modules_log = user.connection.compileModules(modulesDirectory);
|
||||
if (!modules_log.isEmpty()) {
|
||||
testingPackage.description = modules_log;
|
||||
testingPackage.state = TasksPackageState.Aborted;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user