Added the capability to allow expressions in an integration test command (i.e. -filter 'foo') by escaping them in the command.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2132 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2009-11-24 02:34:48 +00:00
parent 903342745d
commit be6a549e7b
2 changed files with 29 additions and 1 deletions

View File

@ -541,6 +541,14 @@ public class Utils {
return new Pair<Double, Integer>(max, index);
}
public static String[] concatArrays(String[] A, String[] B) {
String[] C = new String[A.length + B.length];
System.arraycopy(A, 0, C, 0, A.length);
System.arraycopy(B, 0, C, A.length, B.length);
return C;
}
/** Returns indices of all occurrences of the specified symbol in the string */
public static int[] indexOfAll(String s, int ch) {
int[] pos = new int[64];

View File

@ -126,13 +126,33 @@ public class WalkerTest extends BaseTest {
System.out.println(String.format("Executing test %s with GATK arguments: %s", name, args));
CommandLineGATK instance = new CommandLineGATK();
CommandLineExecutable.start(instance, args.split(" "));
String[] command;
// special case for ' and " so we can allow expressions
if ( args.indexOf('\'') != -1 )
command = escapeExpressions(args, "'");
else if ( args.indexOf('\"') != -1 )
command = escapeExpressions(args, "\"");
else
command = args.split(" ");
CommandLineExecutable.start(instance, command);
if ( CommandLineExecutable.result != 0 ) {
throw new RuntimeException("Error running the GATK with arguments: " + args);
}
return new Pair<List<File>, List<String>>(tmpFiles, assertMatchingMD5s(name, tmpFiles, spec.md5s));
}
private static String[] escapeExpressions(String args, String delimiter) {
String[] command = {};
String[] split = args.split(delimiter);
for (int i = 0; i < split.length - 1; i+=2) {
command = Utils.concatArrays(command, split[i].trim().split(" "));
command = Utils.concatArrays(command, new String[] { split[i+1] } );
}
return Utils.concatArrays(command, split[split.length-1].trim().split(" "));
}
@Test