убрал наличие бд в тестах.

This commit is contained in:
2023-11-26 00:30:43 +03:00
parent 93ccdc3522
commit 253de8526a
11 changed files with 165 additions and 146 deletions

View File

@@ -10,7 +10,6 @@ import GlobalData.Settings.SettingName;
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;
@@ -390,7 +389,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
case RefreshDVMTests:
Print("Синхронизировать репозиторий тестов ");
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = RefreshDVMTests((Account) request.object, Integer.parseInt(request.arg));
RefreshDVMTests((Account) request.object, Integer.parseInt(request.arg));
break;
//--
default:
@@ -423,7 +422,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
//->>
return new Pair<>(object, groupFiles);
}
public LinkedHashMap<Group, Vector<Test>> RefreshDVMTests(Account account, int sapfor_id) throws Exception {
public void RefreshDVMTests(Account account, int sapfor_id) throws Exception {
ServerSapfor sapfor = null;
if (!db.serverSapfors.containsKey(sapfor_id))
throw new RepositoryRefuseException("Версия SAPFOR с ключом " + sapfor_id + " не найдена.");
@@ -489,45 +488,34 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
test.sender_name = account.name;
test.sender_address = account.email;
test.group_id = group.id;
test.files=file.getName();
db.Insert(test);
testsIds.add(test);
//->>
File testProject = new File(Global.TestsDirectory, String.valueOf(test.id));
Utils.CheckAndCleanDirectory(testProject);
File testFile = Paths.get(testProject.getAbsolutePath(), file.getName()).toFile();
File testDirectory = new File(Global.TestsDirectory, String.valueOf(test.id));
Utils.CheckAndCleanDirectory(testDirectory);
File testFile = Paths.get(testDirectory.getAbsolutePath(), file.getName()).toFile();
FileUtils.copyFile(file, testFile);
//----
//архивация.
File archive = test.getArchive();
ZipFolderPass zip = new ZipFolderPass();
zip.Do(testProject.getAbsolutePath(), archive.getAbsolutePath());
zip.Do(testDirectory.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;
// временная папка для анализа. чтобы не засорять нормальную.
File tempProject = Utils.getTempFileName("test");
FileUtils.forceMkdir(tempProject);
FileUtils.copyDirectory(testDirectory, tempProject);
//--
if (Sapfor.getMinMaxDim(Sapfor.getTempCopy(new File(sapfor.call_command)), tempProject, test)) {
db.Update(test);
}
else
throw new RepositoryRefuseException("Не удалось определить размерность теста " + Utils.Brackets(test.description));
break;
case c:
test.max_dim = Utils.getCTestMaxDim(testFile);
db.Update(test);
@@ -536,7 +524,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
}
}
}
return res;
}
//-------------------------------------------------------------------------------------->>>
@Override
@@ -570,7 +557,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
for (int test_id : group_tasks.keySet()) {
if (db.tests.containsKey(test_id)) {
Test test = db.tests.get(test_id);
db_project_info project = new db_project_info(test);//Открытие бд проекта и ее синхронизация. неизбежно.
//---
for (TestCompilationTask task : group_tasks.get(test_id)) {
Print("принять задачу на компиляцию " + group_id + ":" + test_id + ":" + task.flags);
@@ -578,7 +564,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
task.state = TaskState.Waiting;
task.id = db.IncKey(SettingName.TaskMaxId);
task.taskspackage_id = tasksPackage.id;
task.makefile_text = group.GenerateMakefile(project, tasksPackage.dvm_drv, task.flags);
task.makefile_text = group.GenerateMakefile(test, tasksPackage.dvm_drv, task.flags);
task.test_home = tasksPackage.user_workspace + "/projects/" + test_id;
//-->>
task.remote_workspace =