Allow the exit code from a failed test script to propagate to the Java
process, which makes it possible to track failing tests in makefiles and via scripts.
This commit is contained in:
parent
02c0b8a4e4
commit
2d973c5353
|
@ -2673,6 +2673,10 @@ public class GUI extends Observable {
|
|||
* @param askForConfirmation Should we ask for confirmation before quitting?
|
||||
*/
|
||||
public void doQuit(boolean askForConfirmation) {
|
||||
doQuit(askForConfirmation, 0);
|
||||
}
|
||||
|
||||
public void doQuit(boolean askForConfirmation, int exitCode) {
|
||||
if (isVisualizedInApplet()) {
|
||||
return;
|
||||
}
|
||||
|
@ -2726,7 +2730,7 @@ public class GUI extends Observable {
|
|||
}
|
||||
saveExternalToolsUserSettings();
|
||||
|
||||
System.exit(0);
|
||||
System.exit(exitCode);
|
||||
}
|
||||
|
||||
// // EXTERNAL TOOLS SETTINGS METHODS ////
|
||||
|
|
|
@ -101,6 +101,8 @@ public class LogScriptEngine {
|
|||
private long startRealTime;
|
||||
private long nextProgress;
|
||||
|
||||
private int exitCode = 0;
|
||||
|
||||
public LogScriptEngine(Simulation simulation) {
|
||||
this.simulation = simulation;
|
||||
}
|
||||
|
@ -369,6 +371,7 @@ public class LogScriptEngine {
|
|||
if (!scriptActive) {
|
||||
return;
|
||||
}
|
||||
exitCode = 2;
|
||||
logger.info("Timeout event @ " + t);
|
||||
engine.put("TIMEOUT", true);
|
||||
stepScript();
|
||||
|
@ -398,14 +401,14 @@ public class LogScriptEngine {
|
|||
new Thread() {
|
||||
public void run() {
|
||||
try { Thread.sleep(500); } catch (InterruptedException e) { }
|
||||
simulation.getGUI().doQuit(false);
|
||||
simulation.getGUI().doQuit(false, exitCode);
|
||||
};
|
||||
}.start();
|
||||
new Thread() {
|
||||
public void run() {
|
||||
try { Thread.sleep(2000); } catch (InterruptedException e) { }
|
||||
logger.warn("Killing Cooja");
|
||||
System.exit(1);
|
||||
System.exit(exitCode);
|
||||
};
|
||||
}.start();
|
||||
}
|
||||
|
@ -439,10 +442,12 @@ public class LogScriptEngine {
|
|||
}
|
||||
|
||||
public void testOK() {
|
||||
exitCode = 0;
|
||||
log("TEST OK\n");
|
||||
deactive();
|
||||
}
|
||||
public void testFailed() {
|
||||
exitCode = 1;
|
||||
log("TEST FAILED\n");
|
||||
deactive();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue