Enabled the parameterize option for debugging PipelineTest MD5s.
Fixed escaping expressions that have more than one space between arguments. Updated example to match the wiki. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5516 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
fe7f45ee2e
commit
fc8acd503e
|
|
@ -319,7 +319,7 @@ public class Utils {
|
|||
else if (args.indexOf('\"') != -1)
|
||||
return escapeExpressions(args, "\"");
|
||||
else
|
||||
return args.split(" ");
|
||||
return args.trim().split(" +");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -335,13 +335,13 @@ public class Utils {
|
|||
for (int i = 0; i < split.length - 1; i += 2) {
|
||||
arg = split[i].trim();
|
||||
if (arg.length() > 0) // if the unescaped arg has a size
|
||||
command = Utils.concatArrays(command, arg.split(" "));
|
||||
command = Utils.concatArrays(command, arg.split(" +"));
|
||||
command = Utils.concatArrays(command, new String[]{split[i + 1]});
|
||||
}
|
||||
arg = split[split.length - 1].trim();
|
||||
if (split.length % 2 == 1) // if the command ends with a delimiter
|
||||
if (arg.length() > 0) // if the last unescaped arg has a size
|
||||
command = Utils.concatArrays(command, arg.split(" "));
|
||||
command = Utils.concatArrays(command, arg.split(" +"));
|
||||
return command;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,18 @@ public class UtilsUnitTest extends BaseTest {
|
|||
public void testEscapeExpressions() {
|
||||
String[] expected, actual;
|
||||
|
||||
expected = new String[] {"one", "two", "three"};
|
||||
actual = Utils.escapeExpressions("one two three");
|
||||
Assert.assertEquals(actual, expected);
|
||||
actual = Utils.escapeExpressions(" one two three");
|
||||
Assert.assertEquals(actual, expected);
|
||||
actual = Utils.escapeExpressions("one two three ");
|
||||
Assert.assertEquals(actual, expected);
|
||||
actual = Utils.escapeExpressions(" one two three ");
|
||||
Assert.assertEquals(actual, expected);
|
||||
actual = Utils.escapeExpressions(" one two three ");
|
||||
Assert.assertEquals(actual, expected);
|
||||
|
||||
expected = new String[] {"one", "two", "three four", "five", "six"};
|
||||
actual = Utils.escapeExpressions("one two 'three four' five six");
|
||||
Assert.assertEquals(actual, expected);
|
||||
|
|
@ -95,6 +107,8 @@ public class UtilsUnitTest extends BaseTest {
|
|||
Assert.assertEquals(actual, expected);
|
||||
actual = Utils.escapeExpressions(" one two 'three four' five six ");
|
||||
Assert.assertEquals(actual, expected);
|
||||
actual = Utils.escapeExpressions(" one two 'three four' five six ");
|
||||
Assert.assertEquals(actual, expected);
|
||||
|
||||
expected = new String[] {"one two", "three", "four"};
|
||||
actual = Utils.escapeExpressions("'one two' three four");
|
||||
|
|
@ -105,6 +119,8 @@ public class UtilsUnitTest extends BaseTest {
|
|||
Assert.assertEquals(actual, expected);
|
||||
actual = Utils.escapeExpressions(" 'one two' three four ");
|
||||
Assert.assertEquals(actual, expected);
|
||||
actual = Utils.escapeExpressions(" 'one two' three four ");
|
||||
Assert.assertEquals(actual, expected);
|
||||
|
||||
expected = new String[] {"one", "two", "three four"};
|
||||
actual = Utils.escapeExpressions("one two 'three four'");
|
||||
|
|
@ -115,5 +131,7 @@ public class UtilsUnitTest extends BaseTest {
|
|||
Assert.assertEquals(actual, expected);
|
||||
actual = Utils.escapeExpressions(" one two 'three four' ");
|
||||
Assert.assertEquals(actual, expected);
|
||||
actual = Utils.escapeExpressions(" one two 'three four' ");
|
||||
Assert.assertEquals(actual, expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ object PipelineTest extends BaseTest with Logging {
|
|||
println(Utils.dupString('-', 80));
|
||||
executeTest(name, pipelineTest.args, pipelineTest.jobQueue, pipelineTest.expectedException)
|
||||
if (run) {
|
||||
assertMatchingMD5s(name, pipelineTest.fileMD5s.map{case (file, md5) => new File(runDir(name), file) -> md5})
|
||||
assertMatchingMD5s(name, pipelineTest.fileMD5s.map{case (file, md5) => new File(runDir(name), file) -> md5}, pipelineTest.parameterize)
|
||||
if (pipelineTest.evalSpec != null)
|
||||
validateEval(name, pipelineTest.evalSpec)
|
||||
println(" => %s PASSED".format(name))
|
||||
|
|
@ -159,11 +159,11 @@ object PipelineTest extends BaseTest with Logging {
|
|||
println(" => %s PASSED DRY RUN".format(name))
|
||||
}
|
||||
|
||||
private def assertMatchingMD5s(name: String, fileMD5s: Traversable[(File, String)]) {
|
||||
private def assertMatchingMD5s(name: String, fileMD5s: Traversable[(File, String)], parameterize: Boolean) {
|
||||
var failed = 0
|
||||
for ((file, expectedMD5) <- fileMD5s) {
|
||||
val calculatedMD5 = BaseTest.testFileMD5(name, file, expectedMD5, false)
|
||||
if (expectedMD5 != "" && expectedMD5 != calculatedMD5)
|
||||
val calculatedMD5 = BaseTest.testFileMD5(name, file, expectedMD5, parameterize)
|
||||
if (!parameterize && expectedMD5 != "" && expectedMD5 != calculatedMD5)
|
||||
failed += 1
|
||||
}
|
||||
if (failed > 0)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ class PipelineTestSpec(var name: String = null) {
|
|||
/** Expected exception from the test. */
|
||||
var expectedException: Class[_ <: Exception] = null
|
||||
|
||||
/** If true will check the MD5s without failing. */
|
||||
var parameterize = false
|
||||
|
||||
def this(args: String, fileMD5s: Traversable[(String, String)]) = {
|
||||
this()
|
||||
this.args = args
|
||||
|
|
|
|||
|
|
@ -31,12 +31,14 @@ import org.broadinstitute.sting.BaseTest
|
|||
class ExampleCountLociPipelineTest {
|
||||
@Test
|
||||
def testCountLoci {
|
||||
var testOut = "count.out"
|
||||
val testOut = "count.out"
|
||||
val spec = new PipelineTestSpec
|
||||
spec.name = "countloci"
|
||||
spec.args = "-S scala/qscript/examples/ExampleCountLoci.scala -R %s -I %s -o %s".format(
|
||||
BaseTest.hg18Reference, BaseTest.validationDataLocation + "small_bam_for_countloci.bam", testOut
|
||||
)
|
||||
spec.args = Array(
|
||||
" -S scala/qscript/examples/ExampleCountLoci.scala",
|
||||
" -R " + BaseTest.hg18Reference,
|
||||
" -I " + BaseTest.validationDataLocation + "small_bam_for_countloci.bam",
|
||||
" -o " + testOut).mkString
|
||||
spec.fileMD5s += testOut -> "67823e4722495eb10a5e4c42c267b3a6"
|
||||
PipelineTest.executeTest(spec)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue