конвертация стандартных тестов на стороне сервера. стало быстрее.
This commit is contained in:
@@ -6,9 +6,7 @@ import Common.UI.UI;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.Settings.SettingName;
|
||||
import ProjectData.Files.DBProjectFile;
|
||||
import ProjectData.Files.FileState;
|
||||
import ProjectData.Files.LanguageStyle;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import Repository.Component.OSDComponent;
|
||||
import Repository.Component.Visualizer_2;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
@@ -124,17 +122,6 @@ public abstract class Sapfor extends OSDComponent {
|
||||
PassCode_2021.SPF_ResolveCommonBlockConflicts
|
||||
};
|
||||
}
|
||||
public static Vector<PassCode_2021> getAllTransformationsCodes() {
|
||||
Vector<PassCode_2021> res = new Vector<>();
|
||||
Collections.addAll(res, getLoopsTransformationsCodes());
|
||||
Collections.addAll(res, getPrivatesTransformationsCodes());
|
||||
Collections.addAll(res, getProceduresTransformationsCodes());
|
||||
Collections.addAll(res, getDVMTransformationsCodes());
|
||||
Collections.addAll(res, getIntervalsTransformationsCodes());
|
||||
Collections.addAll(res, getRegionsTransformationsCodes());
|
||||
Collections.addAll(res, getPreparationTransformationsCodes());
|
||||
return res;
|
||||
}
|
||||
//<editor-fold desc="компонент">
|
||||
@Override
|
||||
public void GetVersionInfo() {
|
||||
@@ -407,90 +394,6 @@ public abstract class Sapfor extends OSDComponent {
|
||||
// res.add(PassCode_2021.SPF_InsertIncludesPass);
|
||||
return res;
|
||||
}
|
||||
//--
|
||||
public int getTextMaxDim(File testFile, db_project_info target) {
|
||||
int res = Constants.Nan;
|
||||
LinkedHashMap<String, DBProjectFile> files = null;
|
||||
if (testFile != null) {
|
||||
DBProjectFile dbProjectFile = new DBProjectFile(testFile, target);
|
||||
files = new LinkedHashMap<>();
|
||||
files.put(dbProjectFile.name, dbProjectFile);
|
||||
} else
|
||||
files = target.db.files.Data;
|
||||
Vector<String> projLines = new Vector<>();
|
||||
try {
|
||||
target.CreateParserOptionsDirs();
|
||||
//-----
|
||||
Restart();
|
||||
cd(target.Home);
|
||||
//-----
|
||||
//<editor-fold desc="создание proj">
|
||||
for (DBProjectFile f : files.values()) {
|
||||
if (f.isActiveProgram()) {
|
||||
projLines.add(Utils.toU(f.file.getAbsolutePath()));
|
||||
f.CreateParserOptions();
|
||||
}
|
||||
}
|
||||
FileUtils.writeLines(target.getProjFile(), projLines, false);
|
||||
//</editor-fold>
|
||||
//-----
|
||||
RunAnalysis(
|
||||
"SPF_ParseFilesWithOrder",
|
||||
-Global.messagesServer.getPort(),
|
||||
Global.packSapforSettings(),
|
||||
target.getProjFile().getAbsolutePath());
|
||||
if (errorCode >= 0) {
|
||||
projLines.clear();
|
||||
int goodCount = 0;
|
||||
int badCount = 0;
|
||||
for (DBProjectFile f : files.values())
|
||||
if (f.isActive()) f.state = FileState.OK;
|
||||
for (DBProjectFile f : files.values()) {
|
||||
f.ReadParseMessagesNoSave(files);
|
||||
if (f.isActive()) {
|
||||
switch (f.state) {
|
||||
case OK:
|
||||
case HasNotes:
|
||||
case HasWarnings:
|
||||
if (f.isActiveProgram())
|
||||
projLines.add(Utils.toU(f.getDepFile().getAbsolutePath()));
|
||||
goodCount++;
|
||||
break;
|
||||
case HasErrors:
|
||||
badCount++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
FileUtils.writeLines(target.getProjFile(), projLines, false);
|
||||
if (badCount > 0) return res;
|
||||
if (goodCount == 0) return res;
|
||||
} else return res;
|
||||
//---
|
||||
Restart();
|
||||
cd(target.Home);
|
||||
///---
|
||||
RunAnalysis(
|
||||
"SPF_GetMaxMinBlockDistribution",
|
||||
-Global.messagesServer.getPort(),
|
||||
Global.packSapforSettings(),
|
||||
target.getProjFile().getAbsolutePath());
|
||||
if ((errorCode < 0) || target.hasErrorMessages(getOutputMessage()))
|
||||
return res;
|
||||
//--
|
||||
System.out.println(Utils.Brackets(getResult()));
|
||||
String[] data = getResult().split(" ");
|
||||
target.CreateParserOptionsDirs(); // теперь очистка.
|
||||
return Integer.parseInt(data[data.length - 1]);
|
||||
///---
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
//--
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
public String getConsoleFlags() throws Exception {
|
||||
Vector<String> res = new Vector<>();
|
||||
@@ -601,10 +504,10 @@ public abstract class Sapfor extends OSDComponent {
|
||||
Constants.err_file);
|
||||
}
|
||||
public static File temp_copy = null;
|
||||
public static File getTempCopy() throws Exception {
|
||||
public static File getTempCopy(File src) throws Exception {
|
||||
if (temp_copy == null || !temp_copy.exists()) {
|
||||
temp_copy = Utils.getTempFileName("SAPFOR" + (Global.isWindows ? ".exe" : ""));
|
||||
FileUtils.copyFile(Current.getSapfor().getFile(), temp_copy);
|
||||
FileUtils.copyFile(src, temp_copy);
|
||||
temp_copy.setExecutable(true);
|
||||
}
|
||||
return temp_copy;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.UI.UI;
|
||||
import Common.Utils.Utils;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import TestingSystem.Common.Group.Group;
|
||||
import TestingSystem.Common.Test.Test;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class ConvertCorrectnessTests extends TestingSystemPass<File> {
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
@@ -26,10 +18,14 @@ public class ConvertCorrectnessTests extends TestingSystemPass<File> {
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
if (!Current.getAccount().isAdmin())
|
||||
if (!Current.getAccount().isAdmin()) {
|
||||
Log.Writeln_("Вы не являетесь администратором");
|
||||
else return UI.Warning("Загрузить полный пакет DVM тестов на корректность и производительность.");
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
if (!Current.Check(Log, Current.ServerSapfor)){
|
||||
return false;
|
||||
}
|
||||
return UI.Warning("Загрузить полный пакет DVM тестов на корректность и производительность.");
|
||||
}
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
@@ -47,38 +43,7 @@ public class ConvertCorrectnessTests extends TestingSystemPass<File> {
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.RefreshDVMTests, "", Current.getAccount()));
|
||||
LinkedHashMap<Group, Vector<Test>> ids = (LinkedHashMap<Group, Vector<Test>>) response.object;
|
||||
ShowMessage1("Определение размерности тестов");
|
||||
for (Group group : ids.keySet()) {
|
||||
Vector<Test> tests = ids.get(group);
|
||||
for (Test test : tests) {
|
||||
ShowMessage2(group.description+" : "+test.description);
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.DownloadTest, String.valueOf(test.id)));
|
||||
File testArchive = Utils.getTempFileName(String.valueOf(test));
|
||||
response.Unpack(testArchive);
|
||||
File testProject = new File(Global.TempDirectory, String.valueOf(test.id));
|
||||
Utils.forceDeleteWithCheck(testProject);
|
||||
FileUtils.forceMkdir(testProject);
|
||||
passes.get(PassCode_2021.UnzipFolderPass).Do(testArchive.getAbsolutePath(), Global.TempDirectory.getAbsolutePath());
|
||||
//без создания бд!!
|
||||
File[] files = testProject.listFiles();
|
||||
if (files != null && files.length > 0) {
|
||||
db_project_info vizTestProject = new db_project_info(testProject, "", false);
|
||||
switch (group.language) {
|
||||
case fortran:
|
||||
test.max_dim = Current.getSapfor().getTextMaxDim(files[0], vizTestProject);
|
||||
System.out.println(test.max_dim);
|
||||
break;
|
||||
case c:
|
||||
test.max_dim = Utils.getCTestMaxDim(files[0]);
|
||||
System.out.println(test.max_dim);
|
||||
break;
|
||||
}
|
||||
}
|
||||
EditObject(test);
|
||||
}
|
||||
}
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.RefreshDVMTests, String.valueOf(Current.getServerSapfor().id), Current.getAccount()));
|
||||
}
|
||||
@Override
|
||||
protected void performFinish() throws Exception {
|
||||
|
||||
@@ -135,13 +135,13 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
|
||||
protected void body() throws Exception {
|
||||
ShowMessage1(dir.getName());
|
||||
//--
|
||||
db_project_info project = target.packCode(dir); //создание копии папки, и архивация.
|
||||
db_project_info project = target.packCode(dir, true); //создание копии папки, и архивация.
|
||||
//-- получить размерность консольным сапфором. папка уже отправлена и чистить ее не нужно!!
|
||||
ShowMessage2("Синтаксический анализ");
|
||||
if (Sapfor.parse(Sapfor.getTempCopy(), project.Home, Current.getSapfor().getConsoleFlags())
|
||||
if (Sapfor.parse(Sapfor.getTempCopy(Current.getSapfor().getFile()), project.Home, Current.getSapfor().getConsoleFlags())
|
||||
) {
|
||||
ShowMessage2("Определение размерности");
|
||||
if (Sapfor.analysis(Sapfor.getTempCopy(), project.Home,
|
||||
if (Sapfor.analysis(Sapfor.getTempCopy(Current.getSapfor().getFile()), project.Home,
|
||||
PassCode_2021.SPF_GetMaxMinBlockDistribution,
|
||||
Current.getSapfor().getConsoleFlags())) {
|
||||
for (String line : Sapfor.outputLines) {
|
||||
@@ -150,8 +150,9 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
|
||||
String s = line.substring(prefix.length());
|
||||
System.out.println(Utils.Brackets(s));
|
||||
String[] data = s.split(" ");
|
||||
target.min_dim = Integer.parseInt(data[0]);
|
||||
target.max_dim = Integer.parseInt(data[1]);
|
||||
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()));
|
||||
|
||||
Reference in New Issue
Block a user