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

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

14
.idea/workspace.xml generated
View File

@@ -6,7 +6,19 @@
</artifacts-to-build> </artifacts-to-build>
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="" /> <list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/Utils/Utils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Utils/Utils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ProjectData/Files/DBProjectFile.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ProjectData/Files/DBProjectFile.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ProjectData/Files/ProjectFile.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ProjectData/Files/ProjectFile.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ProjectData/Project/db_project_info.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ProjectData/Project/db_project_info.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Component/Sapfor/Sapfor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Component/Sapfor/Sapfor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/Group/Group.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/Group/Group.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/Test/Test.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/Test/Test.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/TestingServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/ConvertCorrectnessTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/ConvertCorrectnessTests.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromDirectory.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromDirectory.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />

View File

@@ -108,6 +108,10 @@ public class Utils {
int di = fn.lastIndexOf("."); int di = fn.lastIndexOf(".");
return (di >= 0) ? fn.substring(di + 1).toLowerCase() : ""; return (di >= 0) ? fn.substring(di + 1).toLowerCase() : "";
} }
public static String getExtensionByName(String fn) {;
int di = fn.lastIndexOf(".");
return (di >= 0) ? fn.substring(di + 1).toLowerCase() : "";
}
public static String getFileNameWithoutExtension(File file) { public static String getFileNameWithoutExtension(File file) {
return getNameWithoutExtension(file.getName()); return getNameWithoutExtension(file.getName());
} }
@@ -1124,5 +1128,11 @@ public class Utils {
if (!last_dir_home.isEmpty()) if (!last_dir_home.isEmpty())
directoryChooser.SetCurrentDirectory(last_dir_home); directoryChooser.SetCurrentDirectory(last_dir_home);
} }
public static void ClearProjectData(File project_home) throws Exception {
Utils.deleteFilesByExtensions(project_home, "dep", "proj");
File project_data = new File(project_home, Constants.data);
if (project_data.exists())
FileUtils.forceDelete(project_data);
}
} }

View File

@@ -122,11 +122,9 @@ public class DBProjectFile extends ProjectFile {
//для совместимости пусть палки будут от винды всегда. //для совместимости пусть палки будут от винды всегда.
name = path.substring(father.Home.getAbsolutePath().length() + 1).replace('/', '\\'); name = path.substring(father.Home.getAbsolutePath().length() + 1).replace('/', '\\');
} }
public boolean isMakefile() { public boolean isMakefile() {
return file.getName().equalsIgnoreCase("makefile"); return file.getName().equalsIgnoreCase("makefile");
} }
public boolean isActiveProgram() { public boolean isActiveProgram() {
return fileType.equals(FileType.program) return fileType.equals(FileType.program)
&& languageName.equals(father.languageName) && !state.equals(FileState.Excluded); && languageName.equals(father.languageName) && !state.equals(FileState.Excluded);
@@ -393,9 +391,7 @@ public class DBProjectFile extends ProjectFile {
public String getQObjectName() { public String getQObjectName() {
return Utils.DQuotes(getUnixName() + ".o"); return Utils.DQuotes(getUnixName() + ".o");
} }
public String getQSourceName() {
return Utils.DQuotes(getUnixName());
}
@Override @Override
public String toString() { public String toString() {
return name; return name;
@@ -473,18 +469,5 @@ public class DBProjectFile extends ProjectFile {
return res; return res;
} }
//--- //---
public String getStyleOptions() {
if (languageName == LanguageName.fortran) {
switch (style) {
case fixed:
case extended:
return "-FI";
case free:
return "-f90";
case none:
break;
}
}
return "";
}
} }

View File

@@ -25,6 +25,9 @@ public class ProjectFile extends DBObject {
return file.getName(); return file.getName();
} }
public void AutoDetectProperties(){ public void AutoDetectProperties(){
AutoDetectProperties(file.getName());
}
public void AutoDetectProperties(String name_in) {
//проверка запретных имен. //проверка запретных имен.
String[] forbiddenNames = new String[]{ String[] forbiddenNames = new String[]{
Constants.INTERRUPT, Constants.INTERRUPT,
@@ -39,13 +42,13 @@ public class ProjectFile extends DBObject {
"Makefile" "Makefile"
}; };
for (String forbidden : forbiddenNames) { for (String forbidden : forbiddenNames) {
if (file.getName().equalsIgnoreCase(forbidden)) { if (name_in.equalsIgnoreCase(forbidden)) {
fileType = FileType.forbidden; fileType = FileType.forbidden;
return; return;
} }
} }
//- //-
switch (Utils.getExtension(file)) { switch (Utils.getExtensionByName(name_in)) {
case "f": case "f":
case "fdv": case "fdv":
case "for": case "for":
@@ -84,7 +87,7 @@ public class ProjectFile extends DBObject {
fileType = FileType.forbidden; fileType = FileType.forbidden;
break; break;
case "": case "":
if (Utils.isDigit(file.getName())) { if (Utils.isDigit(name_in)) {
fileType = FileType.forbidden; fileType = FileType.forbidden;
} else { } else {
state = FileState.Excluded; state = FileState.Excluded;
@@ -133,4 +136,21 @@ public class ProjectFile extends DBObject {
public String toString() { public String toString() {
return file.getName(); return file.getName();
} }
public String getQSourceName() {
return Utils.DQuotes(getUnixName());
}
public String getStyleOptions() {
if (languageName == LanguageName.fortran) {
switch (style) {
case fixed:
case extended:
return "-FI";
case free:
return "-f90";
case none:
break;
}
}
return "";
}
} }

View File

@@ -32,7 +32,6 @@ import ProjectData.SapforData.Regions.RegionsSet;
import ProjectData.SapforData.Variants.ParallelVariant; import ProjectData.SapforData.Variants.ParallelVariant;
import ProjectData.SapforData.Variants.VariantsSet; import ProjectData.SapforData.Variants.VariantsSet;
import TestingSystem.Common.Test.ProjectFiles_json; import TestingSystem.Common.Test.ProjectFiles_json;
import TestingSystem.Common.Test.Test;
import Visual_DVM_2021.Passes.PassCode_2021; import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.PassException; import Visual_DVM_2021.Passes.PassException;
import com.mxgraph.swing.mxGraphComponent; import com.mxgraph.swing.mxGraphComponent;
@@ -210,26 +209,6 @@ public class db_project_info extends DBObject {
ExtractStoredInfo(stored_info); ExtractStoredInfo(stored_info);
db.Disconnect(); db.Disconnect();
} }
//для запуска тестов.
public db_project_info(Test test) throws Exception {
Home = test.getServerPath();
//-
CheckVisualiserDirectories();
db = new ProjectDatabase(this);
db.Connect();
db.CreateAllTables();
db.prepareTablesStatements();
db.Synchronize(); //Отличие от обычного. тут сразу же и синхрон файлов.
db_project_info stored_info = db.LoadOnlyProjectInfo();
if (stored_info == null) {
name = Home.getName();
description = "";
creationDate = Utils.getDateNumber(); //----------------------------------------------------------------------------->>>
db.Insert(this);
} else
ExtractStoredInfo(stored_info);
db.Disconnect();
}
//- //-
public void Open() throws Exception { public void Open() throws Exception {
db.Connect(); db.Connect();
@@ -1557,16 +1536,4 @@ public class db_project_info extends DBObject {
} }
return true; return true;
} }
public void clearData() throws Exception {
File project_data = new File(Home, Constants.data);
File[] files = project_data.listFiles();
if (files != null) {
for (File file : files) {
System.out.println(file.getAbsolutePath());
if (!file.getName().equalsIgnoreCase("new_project_base.sqlite")) {
Utils.forceDeleteWithCheck(file);
}
}
}
}
} }

View File

@@ -9,6 +9,7 @@ import ProjectData.Files.DBProjectFile;
import ProjectData.Files.LanguageStyle; import ProjectData.Files.LanguageStyle;
import Repository.Component.OSDComponent; import Repository.Component.OSDComponent;
import Repository.Component.Visualizer_2; import Repository.Component.Visualizer_2;
import TestingSystem.Common.Test.Test;
import Visual_DVM_2021.Passes.PassCode_2021; import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.PassException; import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.Pass_2021; import Visual_DVM_2021.Passes.Pass_2021;
@@ -423,17 +424,16 @@ public abstract class Sapfor extends OSDComponent {
} }
return true; return true;
} }
//--- //--
public static Vector<String> outputLines = null;
public static Vector<String> errorsLines = null;
//---
public static boolean performScript(String name, //имя скрипта public static boolean performScript(String name, //имя скрипта
File sapfor_drv, //путь к сапфору File sapfor_drv, //путь к сапфору
File workspace, //проект File workspace, //проект
String command, //проход String command, //проход
String flags, //флаги String flags, //флаги
String outName, String outName,
String errName) throws Exception { String errName,
Vector<String> resultLines
) throws Exception {
Process process = null; Process process = null;
int exit_code = Constants.Nan; int exit_code = Constants.Nan;
//--- //---
@@ -441,13 +441,10 @@ public abstract class Sapfor extends OSDComponent {
Utils.CheckDirectory(data_workspace); Utils.CheckDirectory(data_workspace);
File outputFile = new File(data_workspace, outName); File outputFile = new File(data_workspace, outName);
File errorsFile = new File(data_workspace, errName); File errorsFile = new File(data_workspace, errName);
outputLines = null;
errorsLines = null;
Utils.delete_with_check(outputFile); Utils.delete_with_check(outputFile);
Utils.delete_with_check(errorsFile); Utils.delete_with_check(errorsFile);
//--- //---
File file = new File(data_workspace, name + (Global.isWindows ? ".bat" : ".sh")); File file = new File(data_workspace, name + (Global.isWindows ? ".bat" : ".sh"));
System.out.println(file.getAbsolutePath());
FileUtils.write(file, FileUtils.write(file,
Utils.DQuotes(sapfor_drv) Utils.DQuotes(sapfor_drv)
+ (flags.isEmpty() ? "" : (" " + flags)) + (flags.isEmpty() ? "" : (" " + flags))
@@ -477,12 +474,25 @@ public abstract class Sapfor extends OSDComponent {
while (!flag); while (!flag);
process = null; process = null;
//--- //---
outputLines = new Vector<>(FileUtils.readLines(outputFile)); Vector<String> outputLines = new Vector<>(FileUtils.readLines(outputFile));
errorsLines = new Vector<>(FileUtils.readLines(errorsFile)); Vector<String> errorsLines = new Vector<>(FileUtils.readLines(errorsFile));
if (resultLines != null) {
resultLines.addAll(outputLines);
}
return (exit_code == 0) && return (exit_code == 0) &&
checkLines(outputLines) && checkLines(outputLines) &&
checkLines(errorsLines); checkLines(errorsLines);
} }
public static boolean performScript(String name, //имя скрипта
File sapfor_drv, //путь к сапфору
File workspace, //проект
String command, //проход
String flags, //флаги
String outName,
String errName
) throws Exception {
return performScript(name, sapfor_drv, workspace, command, flags, outName, errName, null);
}
public static boolean parse(File sapfor_drv, File workspace, String flags) throws Exception { public static boolean parse(File sapfor_drv, File workspace, String flags) throws Exception {
return performScript( return performScript(
"parse", "parse",
@@ -494,14 +504,16 @@ public abstract class Sapfor extends OSDComponent {
Constants.parse_err_file) Constants.parse_err_file)
&& (new File(workspace, "dvm.proj")).exists(); && (new File(workspace, "dvm.proj")).exists();
} }
public static boolean analysis(File sapfor_drv, File workspace, PassCode_2021 code, String flags) throws Exception { public static boolean analysis(File sapfor_drv, File workspace, PassCode_2021 code, String flags, Vector<String> result_lines) throws Exception {
return performScript("analysis", return performScript("analysis",
sapfor_drv, sapfor_drv,
workspace, workspace,
code.getTestingCommand(), code.getTestingCommand(),
flags, flags,
Constants.out_file, Constants.out_file,
Constants.err_file); Constants.err_file,
result_lines
);
} }
public static File temp_copy = null; public static File temp_copy = null;
public static File getTempCopy(File src) throws Exception { public static File getTempCopy(File src) throws Exception {
@@ -512,4 +524,27 @@ public abstract class Sapfor extends OSDComponent {
} }
return temp_copy; return temp_copy;
} }
//--
public static boolean getMinMaxDim(File sapfor_drv, File workspace, Test test) throws Exception {
File sapfor = Sapfor.getTempCopy(sapfor_drv);
String flags = "-noLogo";
if (Sapfor.parse(sapfor, workspace, flags)
) {
Vector<String> outputLines = new Vector<>();
if (Sapfor.analysis(sapfor, workspace, PassCode_2021.SPF_GetMaxMinBlockDistribution, flags, outputLines)) {
//---
for (String line : 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);
return true;
}
}
}
}
return false;
}
} }

View File

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

View File

@@ -6,7 +6,10 @@ import Common.Database.riDBObject;
import Common.Global; import Common.Global;
import Common.UI.UI; import Common.UI.UI;
import Common.Utils.Utils; 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 Repository.RepositoryRefuseException;
import Visual_DVM_2021.Passes.All.UnzipFolderPass; import Visual_DVM_2021.Passes.All.UnzipFolderPass;
import Visual_DVM_2021.Passes.All.ZipFolderPass; 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 org.apache.commons.io.FileUtils;
import java.io.File; import java.io.File;
import java.util.LinkedHashMap;
import java.util.Vector;
public class Test extends riDBObject { public class Test extends riDBObject {
@Description("DEFAULT 1") @Description("DEFAULT 1")
public int min_dim = 1; //мин размерность теста. public int min_dim = 1; //мин размерность теста.
@@ -76,7 +81,7 @@ public class Test extends riDBObject {
return new File(Global.TempDirectory, temp_project_name); 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"); temp_project_name = Utils.getDateName("test");
//- //-
File tempProject = getTempProject(); File tempProject = getTempProject();
@@ -85,12 +90,7 @@ public class Test extends riDBObject {
FileUtils.forceMkdir(tempProject); FileUtils.forceMkdir(tempProject);
FileUtils.copyDirectory(dir, tempProject); FileUtils.copyDirectory(dir, tempProject);
//--- //---
db_project_info project = new db_project_info(tempProject); Utils.ClearProjectData(tempProject);
project.Open();
project.Close();
// UI.Info("clear data for "+project.Home.getAbsolutePath());
project.clearData();
// UI.Info("DONE");
//-- //--
if (create_archive) { if (create_archive) {
ZipFolderPass zip = new ZipFolderPass(); ZipFolderPass zip = new ZipFolderPass();
@@ -98,7 +98,7 @@ public class Test extends riDBObject {
project_archive_bytes = Utils.packFile(tempArchive); project_archive_bytes = Utils.packFile(tempArchive);
} else throw new PassException("Не удалось создать архив папки с кодом."); } else throw new PassException("Не удалось создать архив папки с кодом.");
} }
return project; return tempProject;
} }
public boolean unpackProjectOnServer() throws Exception { public boolean unpackProjectOnServer() throws Exception {
File tmpArchive = new File(Global.TempDirectory, temp_project_name + ".zip"); File tmpArchive = new File(Global.TempDirectory, temp_project_name + ".zip");
@@ -134,4 +134,24 @@ public class Test extends riDBObject {
public String getFilesForTable() { public String getFilesForTable() {
return files.replace("\n", ";"); 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.Tasks.TaskState;
import GlobalData.User.User; import GlobalData.User.User;
import ProjectData.LanguageName; import ProjectData.LanguageName;
import ProjectData.Project.db_project_info;
import Repository.Component.Sapfor.Sapfor; import Repository.Component.Sapfor.Sapfor;
import Repository.EmailMessage; import Repository.EmailMessage;
import Repository.RepositoryRefuseException; import Repository.RepositoryRefuseException;
@@ -390,7 +389,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
case RefreshDVMTests: case RefreshDVMTests:
Print("Синхронизировать репозиторий тестов "); Print("Синхронизировать репозиторий тестов ");
response = new ServerExchangeUnit_2021(ServerCode.OK); 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; break;
//-- //--
default: default:
@@ -423,7 +422,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
//->> //->>
return new Pair<>(object, groupFiles); 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; ServerSapfor sapfor = null;
if (!db.serverSapfors.containsKey(sapfor_id)) if (!db.serverSapfors.containsKey(sapfor_id))
throw new RepositoryRefuseException("Версия SAPFOR с ключом " + sapfor_id + " не найдена."); throw new RepositoryRefuseException("Версия SAPFOR с ключом " + sapfor_id + " не найдена.");
@@ -489,44 +488,33 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
test.sender_name = account.name; test.sender_name = account.name;
test.sender_address = account.email; test.sender_address = account.email;
test.group_id = group.id; test.group_id = group.id;
test.files=file.getName();
db.Insert(test); db.Insert(test);
testsIds.add(test); testsIds.add(test);
//->> //->>
File testProject = new File(Global.TestsDirectory, String.valueOf(test.id)); File testDirectory = new File(Global.TestsDirectory, String.valueOf(test.id));
Utils.CheckAndCleanDirectory(testProject); Utils.CheckAndCleanDirectory(testDirectory);
File testFile = Paths.get(testProject.getAbsolutePath(), file.getName()).toFile(); File testFile = Paths.get(testDirectory.getAbsolutePath(), file.getName()).toFile();
FileUtils.copyFile(file, testFile); FileUtils.copyFile(file, testFile);
//---- //----
//архивация. //архивация.
File archive = test.getArchive(); File archive = test.getArchive();
ZipFolderPass zip = new ZipFolderPass(); ZipFolderPass zip = new ZipFolderPass();
zip.Do(testProject.getAbsolutePath(), archive.getAbsolutePath()); zip.Do(testDirectory.getAbsolutePath(), archive.getAbsolutePath());
//--- //---
//Определение размерности //Определение размерности
switch (group.language) { switch (group.language) {
case fortran: case fortran:
if (Sapfor.parse(Sapfor.getTempCopy(new File(sapfor.call_command)), testProject, "-noLogo") // временная папка для анализа. чтобы не засорять нормальную.
) { File tempProject = Utils.getTempFileName("test");
if (Sapfor.analysis(Sapfor.getTempCopy(new File(sapfor.call_command)), testProject, FileUtils.forceMkdir(tempProject);
PassCode_2021.SPF_GetMaxMinBlockDistribution, FileUtils.copyDirectory(testDirectory, tempProject);
"-noLogo" //--
)) { if (Sapfor.getMinMaxDim(Sapfor.getTempCopy(new File(sapfor.call_command)), tempProject, test)) {
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); db.Update(test);
break;
}
}
} else
throw new RepositoryRefuseException("Не удалось определить размерность.проекта " + Utils.Brackets(test.description));
} else {
throw new RepositoryRefuseException("Не удалось выполнить синтаксический анализ проекта " + Utils.Brackets(test.description));
} }
else
throw new RepositoryRefuseException("Не удалось определить размерность теста " + Utils.Brackets(test.description));
break; break;
case c: case c:
test.max_dim = Utils.getCTestMaxDim(testFile); test.max_dim = Utils.getCTestMaxDim(testFile);
@@ -536,7 +524,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
} }
} }
} }
return res;
} }
//-------------------------------------------------------------------------------------->>> //-------------------------------------------------------------------------------------->>>
@Override @Override
@@ -570,7 +557,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
for (int test_id : group_tasks.keySet()) { for (int test_id : group_tasks.keySet()) {
if (db.tests.containsKey(test_id)) { if (db.tests.containsKey(test_id)) {
Test test = db.tests.get(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)) { for (TestCompilationTask task : group_tasks.get(test_id)) {
Print("принять задачу на компиляцию " + group_id + ":" + test_id + ":" + task.flags); Print("принять задачу на компиляцию " + group_id + ":" + test_id + ":" + task.flags);
@@ -578,7 +564,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
task.state = TaskState.Waiting; task.state = TaskState.Waiting;
task.id = db.IncKey(SettingName.TaskMaxId); task.id = db.IncKey(SettingName.TaskMaxId);
task.taskspackage_id = tasksPackage.id; 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.test_home = tasksPackage.user_workspace + "/projects/" + test_id;
//-->> //-->>
task.remote_workspace = task.remote_workspace =

View File

@@ -17,6 +17,10 @@ public class ConvertCorrectnessTests extends TestingSystemPass<File> {
return ""; return "";
} }
@Override @Override
protected int getTimeout() {
return 0;
}
@Override
protected boolean canStart(Object... args) throws Exception { protected boolean canStart(Object... args) throws Exception {
if (!Current.getAccount().isAdmin()) { if (!Current.getAccount().isAdmin()) {
Log.Writeln_("Вы не являетесь администратором"); Log.Writeln_("Вы не являетесь администратором");

View File

@@ -5,7 +5,7 @@ import Common.Utils.Files.VDirectoryChooser;
import Common.Utils.Utils; import Common.Utils.Utils;
import GlobalData.Settings.SettingName; import GlobalData.Settings.SettingName;
import ProjectData.Files.ProjectFile; import ProjectData.Files.ProjectFile;
import ProjectData.Project.db_project_info; import ProjectData.LanguageName;
import Repository.Component.Sapfor.Sapfor; import Repository.Component.Sapfor.Sapfor;
import TestingSystem.Common.Group.Group; import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Test.Test; import TestingSystem.Common.Test.Test;
@@ -116,7 +116,9 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
return false; return false;
} }
if (other_project_files > 0) { if (other_project_files > 0) {
Log.Writeln_("Папка содержит файлы, не являющиеся программами на языке FORTRAN, или заголовочными."); Log.Writeln_("Папка содержит файлы, не являющиеся программами на языке " +
group.language.getDescription() +
", или заголовочными.");
return false; return false;
} }
//----- //-----
@@ -135,30 +137,11 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
protected void body() throws Exception { protected void body() throws Exception {
ShowMessage1(dir.getName()); ShowMessage1(dir.getName());
//-- //--
db_project_info project = target.packCode(dir, true); //создание копии папки, и архивация. File tempProject = target.packCode(dir, true); //создание копии папки, и архивация.
//-- получить размерность консольным сапфором. папка уже отправлена и чистить ее не нужно!! //-- получить размерность консольным сапфором. папка уже отправлена и чистить ее не нужно!!
ShowMessage2("Синтаксический анализ"); ShowMessage2("Синтаксический анализ и определение размерности");
if (Sapfor.parse(Sapfor.getTempCopy(Current.getSapfor().getFile()), project.Home, Current.getSapfor().getConsoleFlags()) if (group.language.equals(LanguageName.fortran)&&!Sapfor.getMinMaxDim(Sapfor.getTempCopy(Current.getSapfor().getFile()), tempProject, target))
) { Log.Writeln_("Не удалось определить размерность теста " + Utils.Brackets(tempProject.getName()));
ShowMessage2("Определение размерности");
if (Sapfor.analysis(Sapfor.getTempCopy(Current.getSapfor().getFile()), project.Home,
PassCode_2021.SPF_GetMaxMinBlockDistribution,
Current.getSapfor().getConsoleFlags())) {
for (String line : Sapfor.outputLines) {
String prefix = "GET_MIN_MAX_BLOCK_DIST: ";
if (line.startsWith(prefix)) {
String s = line.substring(prefix.length());
System.out.println(Utils.Brackets(s));
String[] data = s.split(" ");
target.min_dim = Math.max(Integer.parseInt(data[0]),0);
target.max_dim = Math.max(Integer.parseInt(data[1]),0);
break;
}
}
} else Log.Writeln_("Не удалось определить размерность.проекта " + Utils.Brackets(dir.getName()));
} else {
Log.Writeln_("Не удалось выполнить синтаксический анализ проекта " + Utils.Brackets(dir.getName()));
}
} }
@Override @Override
protected boolean validate() { protected boolean validate() {