рефакторинг сборки Сапфора. Перевел ее в планировщик задач тестирования сапфора. осталось при проверке бд это отобразить.

This commit is contained in:
2024-05-08 01:56:17 +03:00
parent 468bfc027d
commit 8a4371fc86
5 changed files with 80 additions and 1 deletions

View File

@@ -4,8 +4,11 @@ import Common.Current;
import Common.Global;
import Common.GlobalProperties;
import Common.Utils.Utils;
import ProjectData.LanguageName;
import Repository.RepositoryRefuseException;
import Repository.Server.ServerCode;
import TestingSystem.Common.TasksPackageState;
import TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
import TestingSystem.Common.TestingPlanner;
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
import TestingSystem.SAPFOR.Json.SapforTest_json;
@@ -13,18 +16,23 @@ import TestingSystem.SAPFOR.Json.SapforTestingSet_json;
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
import javafx.util.Pair;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Paths;
import java.util.Date;
import java.util.List;
public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
File workspace;
ServerSapfor sapfor;
//--
File repo;
File repoSapforHome;
int max_version;
int current_version;
//--
File repo_bin;
File repo_out;
File repo_err;
@@ -205,14 +213,51 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
Constants.err_file +
"\n").waitFor();
}
int getSapforRepositoryVersion() throws Exception {
int res = Constants.Nan;
File versionFile = Paths.get(repo.getAbsolutePath(), "/sapfor/experts/Sapfor_2017/_src/Utils/version.h").toFile();
if (versionFile.exists()) {
List<String> data = FileUtils.readLines(versionFile);
for (String s : data) {
if (s.startsWith("#define VERSION_SPF ")) {
String[] version_data = s.split("\"");
if (version_data.length > 0) {
String version_s = version_data[1];
//-
try {
res = Integer.parseInt(version_s);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
}
return res;
}
//--------------------
public void checkServerSapforsForCompilation() throws Exception {
sapfor = null;
getServerSapforForCompilation();
if (sapfor != null) {
//---
max_version = Constants.Nan;
current_version = Constants.Nan;
//--
SyncronizeRepository();
max_version = (int) ServerCommand(ServerCode.GetMaxSapforVersion);
current_version = getSapforRepositoryVersion();
if (current_version==max_version){
System.out.println("Версия SAPFOR " + max_version + " уже собрана!");
ServerCommand(ServerCode.DeleteObjectByPK, new Pair(ServerSapfor.class,sapfor.id));
return;
}
//-
File sapforHome = new File(Global.SapforsDirectory, Utils.getDateName("sapfor"));
//--
sapfor.home_path = sapforHome.getAbsolutePath();
sapfor.languageName = LanguageName.fortran;
//--
File sapforBin = new File(sapforHome, "Sapfor_F");
File sapforOut = new File(sapforHome, Constants.out_file);
File sapforErr = new File(sapforHome, Constants.err_file);
@@ -228,6 +273,11 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
System.out.println("Сборка SAPFOR успешно выполнена");
FileUtils.copyFile(repo_bin, sapforBin);
sapforBin.setExecutable(true, false);
//--
sapfor.version= String.valueOf(current_version);
sapfor.call_command = sapforBin.getAbsolutePath();
sapfor.buildDate = new Date().getTime();
//--
UpdateSapforState(ServerSapforState.Done);
} else {
UpdateSapforState(ServerSapforState.DoneWithErrors);