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

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

@@ -5,9 +5,9 @@ import Common.Database.riDBObject;
import Common.Global;
import Common.UI.UI;
import Common.Utils.Utils;
import ProjectData.Files.DBProjectFile;
import ProjectData.Files.ProjectFile;
import ProjectData.LanguageName;
import ProjectData.Project.db_project_info;
import TestingSystem.Common.Test.Test;
import TestingSystem.Common.Test.TestType;
import com.sun.org.glassfish.gmbal.Description;
@@ -51,7 +51,7 @@ public class Group extends riDBObject {
//-
public static void generateForLanguage(
String dvm_drv,
LinkedHashMap<LanguageName, Vector<DBProjectFile>> programs,
LinkedHashMap<LanguageName, Vector<ProjectFile>> programs,
LanguageName language,
Vector<String> titles,
Vector<String> objects,
@@ -63,10 +63,9 @@ public class Group extends riDBObject {
Vector<String> module_objects = new Vector<>();
String module_body = "";
int i = 1;
for (DBProjectFile program : programs.get(language)) {
for (ProjectFile program : programs.get(language)) {
//--
program.last_assembly_name = language + "_" + i + ".o";
String object = Utils.DQuotes(program.last_assembly_name);
String object = Utils.DQuotes(language + "_" + i + ".o");
module_objects.add(object);
module_body +=
object + ":\n" +
@@ -93,9 +92,9 @@ public class Group extends riDBObject {
bodies.add(module_body);
}
}
public String GenerateMakefile(db_project_info project, String dvm_drv, String flags_in) {
public String GenerateMakefile(Test test, String dvm_drv, String flags_in) {
//----->>
LinkedHashMap<LanguageName, Vector<DBProjectFile>> programs = project.getPrograms();
LinkedHashMap<LanguageName, Vector<ProjectFile>> programs = test.getPrograms();
Vector<String> titles = new Vector<>();
Vector<String> objects = new Vector<>();
Vector<String> bodies = new Vector<>();

View File

@@ -6,7 +6,10 @@ import Common.Database.riDBObject;
import Common.Global;
import Common.UI.UI;
import Common.Utils.Utils;
import ProjectData.Project.db_project_info;
import ProjectData.Files.FileState;
import ProjectData.Files.FileType;
import ProjectData.Files.ProjectFile;
import ProjectData.LanguageName;
import Repository.RepositoryRefuseException;
import Visual_DVM_2021.Passes.All.UnzipFolderPass;
import Visual_DVM_2021.Passes.All.ZipFolderPass;
@@ -15,6 +18,8 @@ import com.sun.org.glassfish.gmbal.Description;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.LinkedHashMap;
import java.util.Vector;
public class Test extends riDBObject {
@Description("DEFAULT 1")
public int min_dim = 1; //мин размерность теста.
@@ -76,7 +81,7 @@ public class Test extends riDBObject {
return new File(Global.TempDirectory, temp_project_name);
}
//--
public db_project_info packCode(File dir, boolean create_archive) throws Exception {
public File packCode(File dir, boolean create_archive) throws Exception {
temp_project_name = Utils.getDateName("test");
//-
File tempProject = getTempProject();
@@ -85,12 +90,7 @@ public class Test extends riDBObject {
FileUtils.forceMkdir(tempProject);
FileUtils.copyDirectory(dir, tempProject);
//---
db_project_info project = new db_project_info(tempProject);
project.Open();
project.Close();
// UI.Info("clear data for "+project.Home.getAbsolutePath());
project.clearData();
// UI.Info("DONE");
Utils.ClearProjectData(tempProject);
//--
if (create_archive) {
ZipFolderPass zip = new ZipFolderPass();
@@ -98,7 +98,7 @@ public class Test extends riDBObject {
project_archive_bytes = Utils.packFile(tempArchive);
} else throw new PassException("Не удалось создать архив папки с кодом.");
}
return project;
return tempProject;
}
public boolean unpackProjectOnServer() throws Exception {
File tmpArchive = new File(Global.TempDirectory, temp_project_name + ".zip");
@@ -134,4 +134,24 @@ public class Test extends riDBObject {
public String getFilesForTable() {
return files.replace("\n", ";");
}
public LinkedHashMap<LanguageName, Vector<ProjectFile>> getPrograms(){
LinkedHashMap<LanguageName, Vector<ProjectFile>> res = new LinkedHashMap<>();
//--
res.put(LanguageName.fortran, new Vector<>());
res.put(LanguageName.c, new Vector<>());
res.put(LanguageName.cpp, new Vector<>());
//--
String[] files_names = files.split("\n");
for (String file_name: files_names){
ProjectFile file = new ProjectFile(new File(file_name));
//--
if (!file.state.equals(FileState.Excluded) &&
file.fileType.equals(FileType.program) &&
(!file.languageName.equals(LanguageName.n)))
res.get(file.languageName).add(file);
}
return res;
}
}

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 =