After this checkout i am trying to put all the executeTest stuff inside a thread.

Before this checkout, it did not work exactly
This commit is contained in:
boccioli_m
2015-06-30 15:06:49 +02:00
parent 4353a4a464
commit df5b42a266

View File

@@ -714,7 +714,7 @@ public class TestingList extends Panel {
//returns the amount of tests currently in Pending state
public int successTestsCount(){
return testsStatusCount(TestStatus.SUCCESS);
}
}
//returns the amount of tests currently in "status" state
private int testsStatusCount(TestStatus status){
@@ -730,7 +730,13 @@ public class TestingList extends Panel {
}
return iPendingTestsCount;
}
private void setToStopped(){
//No more tests to play. Stop
setButtonToStop();
logger.log(Level.INFO, "End of tests.");
}
/**
* find the test currently in progress
*
@@ -900,16 +906,9 @@ public class TestingList extends Panel {
executeTest(position + 1);
}
}
}
}
}
}
private void setToStopped(){
//No more tests to play. Stop
setButtonToStop();
logger.log(Level.INFO, "End of tests.");
}
//start all the tests in the rowsToExecute
private int executeParallelTestsGroup(int[] rowsToExecute) {
@@ -975,8 +974,9 @@ public class TestingList extends Panel {
}
public class RunTest implements Runnable {
//delete this
/*
public class RunTest_old implements Runnable {
private String sDeviceName, sTestPath;
private HashMap mParameters;
@@ -1058,6 +1058,91 @@ public class TestingList extends Panel {
}
}
*/
public class RunTest implements Runnable {
private String sDeviceName, sTestPath;
private HashMap mParameters;
private HashMap<String,Object> args;
private HashMap<String,HashMap> hTests;
public RunTest(String sTestPath, HashMap<String,Object> args) {
System.out.println("A1");
this.sDeviceName = args.get("device").toString();
System.out.println("A2");
this.sTestPath = sTestPath;
System.out.println("A3");
this.mParameters = (HashMap) args.get("parameters");
this.args = args;
}
public RunTest(String sTestPath) {
this.sDeviceName = sTestPath;
this.sTestPath = sTestPath;
this.mParameters.put("a", 1);
}
public RunTest(HashMap<String,HashMap> args) {
System.out.println("A0");
this.hTests = (HashMap) args;
}
public void run() {
// code in the other thread, can reference "var" variable
int iLastExecutedTestIndex = -1;
final String sParallelizeBegin = "(run,(str('";
final String sParallelizeEnd = "'),))";
try {
System.out.println("A0.1");
String sParallelizeCommand = "parallelize(";
int i = 0;
int iTotalEntries = hTests.entrySet().size();
for(Map.Entry<String, HashMap> hTest : hTests.entrySet()){
setGlobalsVars(hTest.getValue());
sTestPath = hTest.getKey().toString();
sTestPath = sTestPath.replace("\\","\\\\");
sParallelizeCommand = sParallelizeCommand + "(run,(str('" + sTestPath;
i++;
System.out.println("Parameters passed: " + String.valueOf(hTest.getValue().get("parameters")));
System.out.println("A"+i);
if (i<iTotalEntries){
sParallelizeCommand = sParallelizeCommand + "'),,locals='pio')),"; //between each "run" command
}else{
sParallelizeCommand = sParallelizeCommand + "'),)))"; //very last part of command "parallelize"
}
}
System.out.println(sParallelizeCommand);
Object ret = eval(sParallelizeCommand);
// Object ret = eval("parallelize((run,(str('"+sTestPath+"'),)), (run,('Motor Test 3 200ms',)))");
System.out.println("Ret = " + String.valueOf(ret));
String sTestResult, sTestStatus, sTestName;
//read the return mapping and put the result in the right table row
for(Object oTestRet : (ArrayList) ret){
sTestPath = String.valueOf(((List<PyList>) oTestRet).get(0));
sTestStatus = String.valueOf(((List<PyList>) oTestRet).get(1));
sTestResult = String.valueOf(((List<PyList>) oTestRet).get(2));
HashMap<String, HashMap> hTest = hTests.get(sTestPath);
sDeviceName = String.valueOf(hTest.get("device"));
sTestName = String.valueOf(hTest.get("test"));
System.out.println(sDeviceName + "|" + sTestPath + "|" + sTestResult + "|" + sTestStatus);
iLastExecutedTestIndex = showResult(sDeviceName, sTestPath, sTestResult, sTestStatus) ;
}
} catch (Exception ex) {
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
SwingUtils.showMessage(TestingList.this.getComponent(), "runTest()", ex.toString());
System.out.println(String.valueOf(ex));
}
}
}
//delete this
private void runTest(String sDeviceName, String sTestPath, HashMap mParameters) {
HashMap args = new HashMap();