Make processing-java return an error code if the VM failed

This still doesn't seem to return anything for exceptions inside a sketch, but a start. Error codes could be helpful for automatic regression testing of all examples.
This commit is contained in:
gohai
2015-08-15 16:01:37 +02:00
parent c5667e7f91
commit 6315a2f3da
2 changed files with 12 additions and 0 deletions

View File

@@ -275,6 +275,7 @@ public class Commander implements RunnerListener {
} else {
runner.launch(sketchArgs);
}
success = !runner.vmReturnedError();
}
} else {
success = false;

View File

@@ -59,6 +59,7 @@ public class Runner implements MessageConsumer {
// Running remote VM
protected VirtualMachine vm;
protected boolean vmReturnedError;
// Thread transferring remote error stream to our error stream
protected Thread errThread = null;
@@ -130,6 +131,14 @@ public class Runner implements MessageConsumer {
}
/**
* Whether the last invocation of launchJava() was successful or not
*/
public boolean vmReturnedError() {
return vmReturnedError;
}
/**
* Simple non-blocking launch of the virtual machine. VM starts suspended.
* @return debuggee VM or null on failure
@@ -408,6 +417,7 @@ public class Runner implements MessageConsumer {
new Thread(new Runnable() {
public void run() {
// PApplet.println("java starting");
vmReturnedError = false;
process = PApplet.exec(args);
try {
// PApplet.println("java waiting");
@@ -445,6 +455,7 @@ public class Runner implements MessageConsumer {
// changing this to separate editor and listener [091124]
//if (editor != null) {
listener.statusError("Could not run the sketch.");
vmReturnedError = true;
//}
// return null;
}