Перенос.
This commit is contained in:
160
src/GlobalData/Tasks/RunTask/RunTask.java
Normal file
160
src/GlobalData/Tasks/RunTask/RunTask.java
Normal file
@@ -0,0 +1,160 @@
|
||||
package GlobalData.Tasks.RunTask;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.Utils.StringTemplate;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.Compiler.CompilerType;
|
||||
import GlobalData.RunConfiguration.RunConfiguration;
|
||||
import GlobalData.Tasks.CompilationTask.CompilationTask;
|
||||
import GlobalData.Tasks.Task;
|
||||
import GlobalData.Tasks.TaskState;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import TestingSystem.Tasks.TestRunTaskInterface;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
public class RunTask extends Task {
|
||||
public int compilation_task_id = Utils.Nan; //нужна для бинарника
|
||||
public int run_configuration_id = Utils.Nan;
|
||||
@Description("DEFAULT ''")
|
||||
public String last_sts_name = "";
|
||||
@Description("DEFAULT 0")
|
||||
public double CleanTime;
|
||||
@Description("IGNORE")
|
||||
public boolean hasDvmSts = false;
|
||||
@Description("IGNORE")
|
||||
public boolean hasGCOV = false;
|
||||
//-------------------------------------
|
||||
@Description("DEFAULT ''")
|
||||
public String matrix = "";
|
||||
//-------------------------------------
|
||||
@Override
|
||||
public void DropResults() throws Exception {
|
||||
super.DropResults();
|
||||
Utils.forceDeleteWithCheck(getLocalStsFile());
|
||||
CleanTime = 0;
|
||||
Global.db.Update(this);
|
||||
}
|
||||
@Override
|
||||
public File getHome() {
|
||||
return Global.RunTasksDirectory;
|
||||
}
|
||||
@Override
|
||||
public String getFullCommand() {
|
||||
return getRunConfiguration().getLaunchScriptText(getCompilationTask().binary_name, matrix);
|
||||
}
|
||||
//---------------------------------------
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return
|
||||
Current.CheckID(Current.Machine, machine_id) &&
|
||||
Current.CheckID(Current.User, user_id) &&
|
||||
Current.CheckID(Current.RunConfiguration, run_configuration_id) &&
|
||||
Current.HasProject() &&
|
||||
belongsToProject(Current.getProject()) &&
|
||||
Current.HasCompilationTask() &&
|
||||
compilation_task_id == Current.getCompilationTask().id;
|
||||
}
|
||||
public RunConfiguration getRunConfiguration() {
|
||||
return Global.db.runConfigurations.Data.get(run_configuration_id);
|
||||
}
|
||||
public CompilationTask getCompilationTask() {
|
||||
return Global.db.compilationTasks.Data.get(compilation_task_id);
|
||||
}
|
||||
public void UpdateLastStsName(String file_name) {
|
||||
if (!last_sts_name.equals(file_name)) {
|
||||
last_sts_name = file_name;
|
||||
try {
|
||||
Global.db.Update(this);
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
public File getLocalStsFile() {
|
||||
return Paths.get(getLocalWorkspace().getAbsolutePath(), last_sts_name).toFile();
|
||||
}
|
||||
public File getLocalStsTextFile() {
|
||||
return Paths.get(getLocalWorkspace().getAbsolutePath(), "statistic.txt").toFile();
|
||||
}
|
||||
public String getLocalStsText() {
|
||||
return getTextResult(getLocalStsTextFile());
|
||||
}
|
||||
public void parseCleanTime() {
|
||||
StringTemplate template = new StringTemplate("Time in seconds =", "");
|
||||
String p = template.check_and_get_param(Utils.ReadAllText(getOutputFile()));
|
||||
try {
|
||||
if (p != null) CleanTime = Double.parseDouble(p);
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void AnalyzeOutFile(db_project_info project) throws Exception {
|
||||
List<String> lines = FileUtils.readLines(getOutputFile());
|
||||
if (lines.stream().anyMatch(TestRunTaskInterface::isCrushedLine)
|
||||
) {
|
||||
state = TaskState.Crushed;
|
||||
return;
|
||||
}
|
||||
//->>
|
||||
//тест на корректность.
|
||||
if (!lines.isEmpty() && lines.get(0).toUpperCase().contains("START OF ")) {
|
||||
int complete = 0;
|
||||
int errors = 0;
|
||||
for (int i = 1; i < lines.size(); ++i) {
|
||||
String line_ = lines.get(i).toUpperCase();
|
||||
if (line_.endsWith("COMPLETE")) {
|
||||
complete++;
|
||||
} else if (line_.endsWith("ERROR")) {
|
||||
errors++;
|
||||
} else if (line_.contains("END OF")) {
|
||||
if (errors > 0) state = TaskState.DoneWithErrors;
|
||||
else if (complete > 0) state = TaskState.Done;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
//тест на производительность.
|
||||
StringTemplate stringTemplate = new StringTemplate("Verification =", "");
|
||||
for (String line : lines) {
|
||||
String param = stringTemplate.check_and_get_param(line);
|
||||
if (param != null) {
|
||||
switch (param) {
|
||||
case "SUCCESSFUL":
|
||||
state = TaskState.Done;
|
||||
return;
|
||||
case "UNSUCCESSFUL":
|
||||
state = TaskState.DoneWithErrors;
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void AnalyzeErrorsFile(db_project_info project) throws Exception {
|
||||
List<String> lines = FileUtils.readLines(getErrorsFile());
|
||||
if (lines.stream().anyMatch(TestRunTaskInterface::isCrushedLine))
|
||||
state = TaskState.Crushed;
|
||||
}
|
||||
@Override
|
||||
public void Reset() {
|
||||
super.Reset();
|
||||
CleanTime = 0.0;
|
||||
hasDvmSts = false;
|
||||
hasGCOV = false;
|
||||
}
|
||||
public boolean hasDVMPar() {
|
||||
RunConfiguration config = getRunConfiguration();
|
||||
return
|
||||
config.compiler_id != Utils.Nan &&
|
||||
config.getCompiler().type.equals(CompilerType.dvm) &&
|
||||
!config.getParList().isEmpty()
|
||||
;
|
||||
}
|
||||
}
|
||||
88
src/GlobalData/Tasks/RunTask/RunTasksDBTable.java
Normal file
88
src/GlobalData/Tasks/RunTask/RunTasksDBTable.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package GlobalData.Tasks.RunTask;
|
||||
import Common.Current;
|
||||
import Common.Database.iDBTable;
|
||||
import Common.UI.DataSetControlForm;
|
||||
import Common.UI.Menus.TableMenu;
|
||||
import Common.UI.UI;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import static Common.UI.Tables.TableRenderers.RendererDate;
|
||||
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
|
||||
public class RunTasksDBTable extends iDBTable<RunTask> {
|
||||
public RunTasksDBTable() {
|
||||
super(RunTask.class);
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "задача на запуск";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "задачи на запуск";
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
public boolean hasCheckBox() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
columns.get(6).setRenderer(RendererDate);
|
||||
columns.get(7).setRenderer(RendererStatusEnum);
|
||||
}
|
||||
@Override
|
||||
public void ShowCurrentObject() throws Exception {
|
||||
super.ShowCurrentObject();
|
||||
UI.getMainWindow().getTestingWindow().ShowCurrentRunTask();
|
||||
}
|
||||
@Override
|
||||
public void ShowNoCurrentObject() throws Exception {
|
||||
super.ShowNoCurrentObject();
|
||||
UI.getMainWindow().getTestingWindow().ShowNoCurrentRunTask();
|
||||
}
|
||||
@Override
|
||||
public void CreateControl() {
|
||||
super.CreateControl();
|
||||
TableMenu dataTableMenu = new TableMenu(control);
|
||||
dataTableMenu.add(Pass_2021.passes.get(PassCode_2021.DeleteSelectedRunTasks).createMenuItem());
|
||||
control.setComponentPopupMenu(dataTableMenu);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{
|
||||
"Матрица",
|
||||
"Лимит(с)",
|
||||
"Время(с)",
|
||||
"Чистое время",
|
||||
"Дата",
|
||||
"Статус"};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(RunTask object, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 2:
|
||||
return object.matrix;
|
||||
case 3:
|
||||
return object.maxtime;
|
||||
case 4:
|
||||
return object.Time;
|
||||
case 5:
|
||||
return object.CleanTime;
|
||||
case 6:
|
||||
return object.getEndDate();
|
||||
case 7:
|
||||
return object.state;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.RunTask;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user