сборка сапфора для тестирования пользователем
This commit is contained in:
@@ -9,10 +9,13 @@ import GlobalData.Tasks.TaskState;
|
||||
import GlobalData.User.User;
|
||||
import ProjectData.LanguageName;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import Repository.Component.Component;
|
||||
import Repository.Component.Sapfor.Sapfor_F;
|
||||
import Repository.RepositoryRefuseException;
|
||||
import Repository.RepositoryServer;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import SapforTestingSystem.ServerSapfor.ServerSapfor;
|
||||
import TestingSystem.Group.Group;
|
||||
import TestingSystem.Group.GroupInterface;
|
||||
import TestingSystem.Tasks.TestCompilationTask;
|
||||
@@ -23,6 +26,7 @@ import TestingSystem.TasksPackageToKill.TasksPackageToKill;
|
||||
import TestingSystem.Test.Test;
|
||||
import TestingSystem.Test.TestInterface;
|
||||
import TestingSystem.Test.TestType;
|
||||
import Visual_DVM_2021.Passes.All.BuildComponent;
|
||||
import Visual_DVM_2021.Passes.All.DownloadRepository;
|
||||
import Visual_DVM_2021.Passes.All.UnzipFolderPass;
|
||||
import Visual_DVM_2021.Passes.All.ZipFolderPass;
|
||||
@@ -195,10 +199,151 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
}
|
||||
//--->>
|
||||
@Override
|
||||
protected void startAdditionalThreads() {
|
||||
testingThread.start();
|
||||
}
|
||||
protected TestingPlanner testingPlanner = new TestingPlanner();
|
||||
protected Thread testingThread = new Thread(() -> testingPlanner.Perform());
|
||||
//------>>>
|
||||
public static boolean checkTasks = false;
|
||||
//--
|
||||
public static void switchTimer(boolean on) {
|
||||
if (on)
|
||||
TimerOn();
|
||||
else
|
||||
TimerOff();
|
||||
}
|
||||
public static int checkIntervalSecond = 10;
|
||||
public static Timer checkTimer = null;
|
||||
public static void TimerOn() {
|
||||
checkTasks = true;
|
||||
checkTimer = new Timer(checkIntervalSecond * 1000, e -> {
|
||||
Pass_2021.passes.get(PassCode_2021.ActualizePackages).Do();
|
||||
});
|
||||
checkTimer.start();
|
||||
}
|
||||
public static void TimerOff() {
|
||||
System.out.println("timer off");
|
||||
if (checkTimer != null)
|
||||
checkTimer.stop();
|
||||
checkTasks = false;
|
||||
}
|
||||
public static void ResetTimer() {
|
||||
TimerOff();
|
||||
TimerOn();
|
||||
}
|
||||
//->>
|
||||
Group ConvertDirectoryToGroup(File src, LanguageName languageName, TestType testType) throws Exception {
|
||||
Group object = new Group();
|
||||
//->>
|
||||
object.description = src.getName();
|
||||
object.language = languageName;
|
||||
object.type = testType;
|
||||
//-->>
|
||||
//->>
|
||||
File[] testsFiles = src.listFiles(pathname ->
|
||||
pathname.isFile()
|
||||
&& !pathname.getName().equals("settings")
|
||||
&& !pathname.getName().equals("test-analyzer.sh")
|
||||
&& Utils.getExtension(pathname).startsWith(languageName.getDVMCompile()));
|
||||
;
|
||||
if (testsFiles != null) {
|
||||
for (File testFile : testsFiles)
|
||||
object.testsFiles.put(testFile.getName(), Utils.packFile(testFile));
|
||||
}
|
||||
//->>
|
||||
return object;
|
||||
}
|
||||
//->>
|
||||
public Vector<Group> getRepoGroupsInfo() throws Exception {
|
||||
Vector<Group> groups = new Vector<>();
|
||||
File testsSrc = Paths.get(
|
||||
Global.RepoDirectory.getAbsolutePath(),
|
||||
"dvm", "tools", "tester", "trunk", "test-suite").toFile();
|
||||
LanguageName[] supportedLanguages = new LanguageName[]{LanguageName.fortran, LanguageName.c};
|
||||
for (LanguageName languageName : supportedLanguages) {
|
||||
for (TestType testType : TestType.values()) {
|
||||
File groupsSrc = null;
|
||||
switch (testType) {
|
||||
case Correctness:
|
||||
String languageSrcName = null;
|
||||
switch (languageName) {
|
||||
case fortran:
|
||||
languageSrcName = "Fortran";
|
||||
break;
|
||||
case c:
|
||||
languageSrcName = "C";
|
||||
break;
|
||||
}
|
||||
if (languageSrcName != null) {
|
||||
groupsSrc = Paths.get(testsSrc.getAbsolutePath(), "Correctness", languageSrcName).toFile();
|
||||
File[] groupsDirs = groupsSrc.listFiles(File::isDirectory);
|
||||
if (groupsDirs != null) {
|
||||
for (File groupDir : groupsDirs)
|
||||
groups.add(ConvertDirectoryToGroup(groupDir, languageName, testType));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Performance:
|
||||
File groupDir = Paths.get(testsSrc.getAbsolutePath(), "Performance").toFile();
|
||||
groups.add(ConvertDirectoryToGroup(groupDir, languageName, testType));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
groups.sort(Comparator.comparing(o -> o.description));
|
||||
return groups;
|
||||
}
|
||||
public ServerSapfor InstallSapforForTesting() throws Exception {
|
||||
Sapfor_F sapfor_f = new Sapfor_F();
|
||||
//--->>
|
||||
DownloadRepository downloadRepository = new DownloadRepository(){
|
||||
@Override
|
||||
public PassCode_2021 code() {
|
||||
return PassCode_2021.DownloadRepository;
|
||||
}
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
BuildComponent buildComponent = new BuildComponent() {
|
||||
@Override
|
||||
public PassCode_2021 code() {
|
||||
return PassCode_2021.BuildComponent;
|
||||
}
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected PassCode_2021 necessary() {
|
||||
return null; //тут схема с проходами не работает. возможно для сервера сделать урезанный список?
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
target = (Component) args[0];
|
||||
return true;
|
||||
}
|
||||
};
|
||||
if (!downloadRepository.Do())
|
||||
throw new RepositoryRefuseException("Не удалось загрузить репозиторий.");
|
||||
if (!buildComponent.Do(sapfor_f))
|
||||
throw new RepositoryRefuseException("Не удалось собрать версию SAPFOR.");
|
||||
//-->>
|
||||
//реализовать локально. вернуть готовый объект.
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected void Session() throws Exception {
|
||||
DBObject dbObject = null;
|
||||
Test test = null;
|
||||
switch (code) {
|
||||
case InstallSapforForTesting:
|
||||
Print("Установка SAPFOR для тестирования");
|
||||
InstallSapforForTesting();
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
break;
|
||||
case SynchronizeTests:
|
||||
//временный проход. синхронизирует тесты на заданной машине, с сервера.
|
||||
Print("Синхронизация тестов");
|
||||
@@ -350,100 +495,4 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void startAdditionalThreads() {
|
||||
testingThread.start();
|
||||
}
|
||||
protected TestingPlanner testingPlanner = new TestingPlanner();
|
||||
protected Thread testingThread = new Thread(() -> testingPlanner.Perform());
|
||||
//------>>>
|
||||
public static boolean checkTasks = false;
|
||||
//--
|
||||
public static void switchTimer(boolean on) {
|
||||
if (on)
|
||||
TimerOn();
|
||||
else
|
||||
TimerOff();
|
||||
}
|
||||
public static int checkIntervalSecond = 10;
|
||||
public static Timer checkTimer = null;
|
||||
public static void TimerOn() {
|
||||
checkTasks = true;
|
||||
checkTimer = new Timer(checkIntervalSecond * 1000, e -> {
|
||||
Pass_2021.passes.get(PassCode_2021.ActualizePackages).Do();
|
||||
});
|
||||
checkTimer.start();
|
||||
}
|
||||
public static void TimerOff() {
|
||||
System.out.println("timer off");
|
||||
if (checkTimer != null)
|
||||
checkTimer.stop();
|
||||
checkTasks = false;
|
||||
}
|
||||
public static void ResetTimer() {
|
||||
TimerOff();
|
||||
TimerOn();
|
||||
}
|
||||
//->>
|
||||
Group ConvertDirectoryToGroup(File src, LanguageName languageName, TestType testType) throws Exception {
|
||||
Group object = new Group();
|
||||
//->>
|
||||
object.description = src.getName();
|
||||
object.language = languageName;
|
||||
object.type = testType;
|
||||
//-->>
|
||||
//->>
|
||||
File[] testsFiles = src.listFiles(pathname ->
|
||||
pathname.isFile()
|
||||
&& !pathname.getName().equals("settings")
|
||||
&& !pathname.getName().equals("test-analyzer.sh")
|
||||
&& Utils.getExtension(pathname).startsWith(languageName.getDVMCompile()));
|
||||
;
|
||||
if (testsFiles != null) {
|
||||
for (File testFile : testsFiles)
|
||||
object.testsFiles.put(testFile.getName(), Utils.packFile(testFile));
|
||||
}
|
||||
//->>
|
||||
return object;
|
||||
}
|
||||
//->>
|
||||
public Vector<Group> getRepoGroupsInfo() throws Exception {
|
||||
Vector<Group> groups = new Vector<>();
|
||||
File testsSrc = Paths.get(
|
||||
Global.RepoDirectory.getAbsolutePath(),
|
||||
"dvm", "tools", "tester", "trunk", "test-suite").toFile();
|
||||
LanguageName[] supportedLanguages = new LanguageName[]{LanguageName.fortran, LanguageName.c};
|
||||
for (LanguageName languageName : supportedLanguages) {
|
||||
for (TestType testType : TestType.values()) {
|
||||
File groupsSrc = null;
|
||||
switch (testType) {
|
||||
case Correctness:
|
||||
String languageSrcName = null;
|
||||
switch (languageName) {
|
||||
case fortran:
|
||||
languageSrcName = "Fortran";
|
||||
break;
|
||||
case c:
|
||||
languageSrcName = "C";
|
||||
break;
|
||||
}
|
||||
if (languageSrcName != null) {
|
||||
groupsSrc = Paths.get(testsSrc.getAbsolutePath(), "Correctness", languageSrcName).toFile();
|
||||
File[] groupsDirs = groupsSrc.listFiles(File::isDirectory);
|
||||
if (groupsDirs != null) {
|
||||
for (File groupDir : groupsDirs)
|
||||
groups.add(ConvertDirectoryToGroup(groupDir, languageName, testType));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Performance:
|
||||
File groupDir = Paths.get(testsSrc.getAbsolutePath(), "Performance").toFile();
|
||||
groups.add(ConvertDirectoryToGroup(groupDir, languageName, testType));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
groups.sort(Comparator.comparing(o -> o.description));
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user