конвертация стандартных тестов на стороне сервера. стало быстрее.

This commit is contained in:
2023-11-25 16:51:35 +03:00
parent f0fd9335c4
commit 93ccdc3522
5 changed files with 64 additions and 156 deletions

View File

@@ -76,7 +76,7 @@ public class Test extends riDBObject {
return new File(Global.TempDirectory, temp_project_name);
}
//--
public db_project_info packCode(File dir) throws Exception {
public db_project_info packCode(File dir, boolean create_archive) throws Exception {
temp_project_name = Utils.getDateName("test");
//-
File tempProject = getTempProject();
@@ -88,14 +88,16 @@ public class Test extends riDBObject {
db_project_info project = new db_project_info(tempProject);
project.Open();
project.Close();
// UI.Info("clear data for "+project.Home.getAbsolutePath());
// UI.Info("clear data for "+project.Home.getAbsolutePath());
project.clearData();
// UI.Info("DONE");
// UI.Info("DONE");
//--
ZipFolderPass zip = new ZipFolderPass();
if (zip.Do(tempProject.getAbsolutePath(), tempArchive.getAbsolutePath())) {
project_archive_bytes = Utils.packFile(tempArchive);
} else throw new PassException("Не удалось создать архив папки с кодом.");
if (create_archive) {
ZipFolderPass zip = new ZipFolderPass();
if (zip.Do(tempProject.getAbsolutePath(), tempArchive.getAbsolutePath())) {
project_archive_bytes = Utils.packFile(tempArchive);
} else throw new PassException("Не удалось создать архив папки с кодом.");
}
return project;
}
public boolean unpackProjectOnServer() throws Exception {

View File

@@ -11,6 +11,7 @@ import GlobalData.Tasks.TaskState;
import GlobalData.User.User;
import ProjectData.LanguageName;
import ProjectData.Project.db_project_info;
import Repository.Component.Sapfor.Sapfor;
import Repository.EmailMessage;
import Repository.RepositoryRefuseException;
import Repository.RepositoryServer;
@@ -389,7 +390,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
case RefreshDVMTests:
Print("Синхронизировать репозиторий тестов ");
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = RefreshDVMTests((Account) request.object);
response.object = RefreshDVMTests((Account) request.object, Integer.parseInt(request.arg));
break;
//--
default:
@@ -422,7 +423,11 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
//->>
return new Pair<>(object, groupFiles);
}
public LinkedHashMap<Group, Vector<Test>> RefreshDVMTests(Account account) throws Exception {
public LinkedHashMap<Group, Vector<Test>> RefreshDVMTests(Account account, int sapfor_id) throws Exception {
ServerSapfor sapfor = null;
if (!db.serverSapfors.containsKey(sapfor_id))
throw new RepositoryRefuseException("Версия SAPFOR с ключом " + sapfor_id + " не найдена.");
sapfor = db.serverSapfors.get(sapfor_id);
DownloadRepository downloadRepository = new DownloadRepository();
if (!downloadRepository.Do())
throw new RepositoryRefuseException("Не удалось обновить репозиторий");
@@ -496,6 +501,38 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
File archive = test.getArchive();
ZipFolderPass zip = new ZipFolderPass();
zip.Do(testProject.getAbsolutePath(), archive.getAbsolutePath());
//---
//Определение размерности
switch (group.language) {
case fortran:
if (Sapfor.parse(Sapfor.getTempCopy(new File(sapfor.call_command)), testProject, "-noLogo")
) {
if (Sapfor.analysis(Sapfor.getTempCopy(new File(sapfor.call_command)), testProject,
PassCode_2021.SPF_GetMaxMinBlockDistribution,
"-noLogo"
)) {
for (String line : Sapfor.outputLines) {
String prefix = "GET_MIN_MAX_BLOCK_DIST: ";
if (line.startsWith(prefix)) {
String s = line.substring(prefix.length());
String[] data = s.split(" ");
test.min_dim = Math.max(Integer.parseInt(data[0]), 0);
test.max_dim = Math.max(Integer.parseInt(data[1]), 0);
db.Update(test);
break;
}
}
} else
throw new RepositoryRefuseException("Не удалось определить размерность.проекта " + Utils.Brackets(test.description));
} else {
throw new RepositoryRefuseException("Не удалось выполнить синтаксический анализ проекта " + Utils.Brackets(test.description));
}
break;
case c:
test.max_dim = Utils.getCTestMaxDim(testFile);
db.Update(test);
break;
}
}
}
}