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:
Adam Dunkels 2013-07-28 20:32:17 +02:00
parent 02c0b8a4e4
commit 2d973c5353
2 changed files with 12 additions and 3 deletions

View File

@ -2673,6 +2673,10 @@ public class GUI extends Observable {
* @param askForConfirmation Should we ask for confirmation before quitting? * @param askForConfirmation Should we ask for confirmation before quitting?
*/ */
public void doQuit(boolean askForConfirmation) { public void doQuit(boolean askForConfirmation) {
doQuit(askForConfirmation, 0);
}
public void doQuit(boolean askForConfirmation, int exitCode) {
if (isVisualizedInApplet()) { if (isVisualizedInApplet()) {
return; return;
} }
@ -2726,7 +2730,7 @@ public class GUI extends Observable {
} }
saveExternalToolsUserSettings(); saveExternalToolsUserSettings();
System.exit(0); System.exit(exitCode);
} }
// // EXTERNAL TOOLS SETTINGS METHODS //// // // EXTERNAL TOOLS SETTINGS METHODS ////

View File

@ -101,6 +101,8 @@ public class LogScriptEngine {
private long startRealTime; private long startRealTime;
private long nextProgress; private long nextProgress;
private int exitCode = 0;
public LogScriptEngine(Simulation simulation) { public LogScriptEngine(Simulation simulation) {
this.simulation = simulation; this.simulation = simulation;
} }
@ -369,6 +371,7 @@ public class LogScriptEngine {
if (!scriptActive) { if (!scriptActive) {
return; return;
} }
exitCode = 2;
logger.info("Timeout event @ " + t); logger.info("Timeout event @ " + t);
engine.put("TIMEOUT", true); engine.put("TIMEOUT", true);
stepScript(); stepScript();
@ -398,14 +401,14 @@ public class LogScriptEngine {
new Thread() { new Thread() {
public void run() { public void run() {
try { Thread.sleep(500); } catch (InterruptedException e) { } try { Thread.sleep(500); } catch (InterruptedException e) { }
simulation.getGUI().doQuit(false); simulation.getGUI().doQuit(false, exitCode);
}; };
}.start(); }.start();
new Thread() { new Thread() {
public void run() { public void run() {
try { Thread.sleep(2000); } catch (InterruptedException e) { } try { Thread.sleep(2000); } catch (InterruptedException e) { }
logger.warn("Killing Cooja"); logger.warn("Killing Cooja");
System.exit(1); System.exit(exitCode);
}; };
}.start(); }.start();
} }
@ -439,10 +442,12 @@ public class LogScriptEngine {
} }
public void testOK() { public void testOK() {
exitCode = 0;
log("TEST OK\n"); log("TEST OK\n");
deactive(); deactive();
} }
public void testFailed() { public void testFailed() {
exitCode = 1;
log("TEST FAILED\n"); log("TEST FAILED\n");
deactive(); deactive();
} }