Startup
This commit is contained in:
@@ -71,13 +71,7 @@ public class TestingList extends Panel {
|
||||
return testingList;
|
||||
}
|
||||
|
||||
/**
|
||||
* listen to script end of execution and get return value
|
||||
*
|
||||
* @param fileName
|
||||
* @param result
|
||||
* @param exception
|
||||
*/
|
||||
//delete this
|
||||
@Override
|
||||
protected void onExecutedFile(String fileName, Object result) {
|
||||
int iCurrentTestPos = 0;
|
||||
@@ -537,7 +531,7 @@ public class TestingList extends Panel {
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Object ret = eval("parallelize((run,('Motor Test 3 100ms',)), (run,('Motor Test 3 200ms',)))");
|
||||
Object ret = eval("parallelize((run,('testLocalVar1',globals(),{'a':21, 'b':34})), (run,('testLocalVar2',globals(),{'a':231, 'b':234})))");
|
||||
Object ret1 = ((ArrayList) ret).get(0);
|
||||
Object ret2 = ((ArrayList) ret).get(1);
|
||||
System.out.println(String.valueOf(ret1));
|
||||
@@ -826,6 +820,7 @@ public class TestingList extends Panel {
|
||||
private HashMap<String,Object> args;
|
||||
private HashMap<String,HashMap> hTests;
|
||||
|
||||
//delete this
|
||||
public RunTest(String sTestPath, HashMap<String,Object> args) {
|
||||
System.out.println("A1");
|
||||
this.sDeviceName = args.get("device").toString();
|
||||
@@ -835,15 +830,18 @@ public class TestingList extends Panel {
|
||||
this.mParameters = (HashMap) args.get("parameters");
|
||||
this.args = args;
|
||||
}
|
||||
//delete this
|
||||
public RunTest(String sTestPath) {
|
||||
this.sDeviceName = sTestPath;
|
||||
this.sTestPath = sTestPath;
|
||||
this.mParameters.put("a", 1);
|
||||
}
|
||||
//delete this
|
||||
public RunTest(HashMap<String,HashMap> args) {
|
||||
System.out.println("A0");
|
||||
this.hTests = (HashMap) args;
|
||||
}
|
||||
|
||||
public RunTest() {
|
||||
//System.out.println("A0");
|
||||
}
|
||||
@@ -904,7 +902,7 @@ public class TestingList extends Panel {
|
||||
String sTestCaseName = jTable1.getValueAt(row, COL.TESTSUITE.ordinal()).toString();
|
||||
String sTestPath = jTable1.getValueAt(row, COL.TESTPATH.ordinal()).toString();
|
||||
HashMap mParameters = buildParametersMap(String.valueOf(jTable1.getValueAt(row, COL.TESTPARAMS.ordinal())));
|
||||
System.out.println(String.valueOf(row) + "\t" + sDeviceName + "\t" + sTestName + "\t" + sTestCaseName + "\t" + String.valueOf(rowsToExecute.length));
|
||||
//System.out.println(String.valueOf(row) + "\t" + sDeviceName + "\t" + sTestName + "\t" + sTestCaseName + "\t" + String.valueOf(rowsToExecute.length));
|
||||
try {
|
||||
File f = new File(sTestPath);
|
||||
if (!f.exists() || f.isDirectory()) {
|
||||
@@ -942,6 +940,7 @@ public class TestingList extends Panel {
|
||||
int iLastExecutedTestIndex = -1;
|
||||
final String sParallelizeBegin = "(run,(str('";
|
||||
final String sParallelizeEnd = "'),))";
|
||||
String sParallelizeArguments;
|
||||
try {
|
||||
//System.out.println("A0.1");
|
||||
String sParallelizeCommand = "parallelize(";
|
||||
@@ -951,14 +950,20 @@ public class TestingList extends Panel {
|
||||
setGlobalsVars(hTest.getValue());
|
||||
sTestPath = hTest.getKey().toString();
|
||||
sTestPath = sTestPath.replace("\\","\\\\");
|
||||
System.out.println(hTest.getValue().get("test"));
|
||||
sParallelizeCommand = sParallelizeCommand + "(run,(str('" + sTestPath;
|
||||
i++;
|
||||
System.out.println("Parameters passed: " + String.valueOf(hTest.getValue().get("parameters")));
|
||||
//System.out.println("A"+i);
|
||||
sParallelizeArguments = "globals(),{parameters:'"+hTest.getValue().get("parameters")+
|
||||
"',test:'"+hTest.getValue().get("test")+
|
||||
"',device:'"+hTest.getValue().get("device")+
|
||||
"',status:'"+hTest.getValue().get("status")+"'}";
|
||||
if (i<iTotalEntries){
|
||||
sParallelizeCommand = sParallelizeCommand + "'),)),"; //between each "run" command
|
||||
sParallelizeCommand = sParallelizeCommand +
|
||||
"'),"+sParallelizeArguments+")),"; //between each "run" command
|
||||
}else{
|
||||
sParallelizeCommand = sParallelizeCommand + "'),)))"; //very last part of command "parallelize"
|
||||
sParallelizeCommand = sParallelizeCommand + "'),"+sParallelizeArguments+")))"; //very last part of command "parallelize"
|
||||
}
|
||||
}
|
||||
System.out.println(sParallelizeCommand);
|
||||
@@ -967,20 +972,25 @@ public class TestingList extends Panel {
|
||||
//System.out.println("Ret = " + String.valueOf(ret));
|
||||
String sTestResult, sTestStatus, sTestName;
|
||||
//read the return mapping and put the result in the right table row
|
||||
System.out.println("ret type "+ret.getClass().toString() );
|
||||
for(Object oTestRet : (ArrayList) ret){
|
||||
if(oTestRet.getClass().toString() == "org.python.core.PyList" && ((List<PyList>) oTestRet).size()>=3){
|
||||
//System.out.println("ret type "+ret.getClass().toString() );
|
||||
//scan through all return mappings of all run tests
|
||||
for(Object oTestRet : (ArrayList) ret){
|
||||
//check if the mapping of the selected test has all expected return values
|
||||
if(((List<PyList>) oTestRet).size()>=4){
|
||||
//extract return data of the current test
|
||||
sTestPath = String.valueOf(((List<PyList>) oTestRet).get(0));
|
||||
sTestStatus = String.valueOf(((List<PyList>) oTestRet).get(1));
|
||||
sDeviceName = String.valueOf(((List<PyList>) oTestRet).get(1));
|
||||
sTestResult = String.valueOf(((List<PyList>) oTestRet).get(2));
|
||||
sTestStatus = String.valueOf(((List<PyList>) oTestRet).get(3));
|
||||
//from the map of executed tests, get the test name (key is test path)
|
||||
HashMap<String, HashMap> hTest = hTests.get(sTestPath);
|
||||
sDeviceName = String.valueOf(hTest.get("device"));
|
||||
sTestName = String.valueOf(hTest.get("test"));
|
||||
} else{ //problem, the test script does not return all the expected return values
|
||||
String sErrorText = "Test "+ sTestPath+" did not return all requird return values";
|
||||
String sErrorText = "Test "+ sTestPath+" did not return all required return values";
|
||||
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, sErrorText);
|
||||
SwingUtils.showMessage(TestingList.this.getComponent(), "executeParallelTestsGroup()", sErrorText);
|
||||
System.out.println(String.valueOf(sErrorText));
|
||||
//try to fetch at least first element of returned map. If fails, it will go to catch
|
||||
sTestPath = String.valueOf(((List<PyList>) oTestRet).get(0));
|
||||
sTestStatus = sErrorText;
|
||||
sTestResult = "false";
|
||||
@@ -1014,21 +1024,6 @@ public class TestingList extends Panel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//delete this
|
||||
private void runTest(String sDeviceName, String sTestPath, HashMap mParameters) {
|
||||
HashMap args = new HashMap();
|
||||
args.put("parameters", mParameters);
|
||||
args.put("device", sDeviceName);
|
||||
args.put("ret", "");
|
||||
args.put("status", false);
|
||||
System.out.println("Parameters passed: " + String.valueOf(mParameters));
|
||||
try {
|
||||
runAsync(sTestPath, args);
|
||||
} catch (Controller.ControllerStateException ex) {
|
||||
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* table management
|
||||
|
||||
Reference in New Issue
Block a user