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

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

@@ -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;
}
}