Skip to content

Commit

Permalink
maxima output filter to fail more quickly on errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sowiso committed May 8, 2017
1 parent 3f44270 commit 8c7abff
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/fi/aalto/maximapool/MaximaProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ boolean doAndDie(String command, long timeout, String plotUrlBase) {
} catch (Exception ee) {

}
if (output.currentValue().contains(config.killString)) {
if (
output.currentValue().contains(config.killString) ||
counterString(output.currentValue(),config.useReady) >= 2 ||
output.currentValue().contains("incorrect syntax") ||
output.currentValue().contains("positive, negative or zero") ||
output.currentValue().contains("concat(--COMPLETED--k, ill--PROCESS--)")
) {
output.close();
kill();
return true;
Expand Down Expand Up @@ -195,6 +201,21 @@ boolean doAndDie(String command, long timeout, String plotUrlBase) {
return true;
}


/**
* Helper method. Checks if test occurs twice in string
* @param test string to look for in the output.
*/
private int counterString(String s,String search) {
int times = 0;
int index = s.indexOf(search,0);
while(index != -1) {
index = s.indexOf(search,index+1);
++times;
}
return times;
}

/**
* Helper method. Waits until a particular string is detected in the output,
* before returning.
Expand Down

0 comments on commit 8c7abff

Please sign in to comment.