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:
kshakir 2011-03-26 00:41:47 +00:00
parent fe7f45ee2e
commit fc8acd503e
5 changed files with 34 additions and 11 deletions

View File

@ -319,7 +319,7 @@ public class Utils {
else if (args.indexOf('\"') != -1) else if (args.indexOf('\"') != -1)
return escapeExpressions(args, "\""); return escapeExpressions(args, "\"");
else 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) { for (int i = 0; i < split.length - 1; i += 2) {
arg = split[i].trim(); arg = split[i].trim();
if (arg.length() > 0) // if the unescaped arg has a size 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]}); command = Utils.concatArrays(command, new String[]{split[i + 1]});
} }
arg = split[split.length - 1].trim(); arg = split[split.length - 1].trim();
if (split.length % 2 == 1) // if the command ends with a delimiter if (split.length % 2 == 1) // if the command ends with a delimiter
if (arg.length() > 0) // if the last unescaped arg has a size 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; return command;
} }

View File

@ -86,6 +86,18 @@ public class UtilsUnitTest extends BaseTest {
public void testEscapeExpressions() { public void testEscapeExpressions() {
String[] expected, actual; 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"}; expected = new String[] {"one", "two", "three four", "five", "six"};
actual = Utils.escapeExpressions("one two 'three four' five six"); actual = Utils.escapeExpressions("one two 'three four' five six");
Assert.assertEquals(actual, expected); Assert.assertEquals(actual, expected);
@ -95,6 +107,8 @@ public class UtilsUnitTest extends BaseTest {
Assert.assertEquals(actual, expected); Assert.assertEquals(actual, expected);
actual = Utils.escapeExpressions(" one two 'three four' five six "); actual = Utils.escapeExpressions(" one two 'three four' five six ");
Assert.assertEquals(actual, expected); Assert.assertEquals(actual, expected);
actual = Utils.escapeExpressions(" one two 'three four' five six ");
Assert.assertEquals(actual, expected);
expected = new String[] {"one two", "three", "four"}; expected = new String[] {"one two", "three", "four"};
actual = Utils.escapeExpressions("'one two' three four"); actual = Utils.escapeExpressions("'one two' three four");
@ -105,6 +119,8 @@ public class UtilsUnitTest extends BaseTest {
Assert.assertEquals(actual, expected); Assert.assertEquals(actual, expected);
actual = Utils.escapeExpressions(" 'one two' three four "); actual = Utils.escapeExpressions(" 'one two' three four ");
Assert.assertEquals(actual, expected); Assert.assertEquals(actual, expected);
actual = Utils.escapeExpressions(" 'one two' three four ");
Assert.assertEquals(actual, expected);
expected = new String[] {"one", "two", "three four"}; expected = new String[] {"one", "two", "three four"};
actual = Utils.escapeExpressions("one two 'three four'"); actual = Utils.escapeExpressions("one two 'three four'");
@ -115,5 +131,7 @@ public class UtilsUnitTest extends BaseTest {
Assert.assertEquals(actual, expected); Assert.assertEquals(actual, expected);
actual = Utils.escapeExpressions(" one two 'three four' "); actual = Utils.escapeExpressions(" one two 'three four' ");
Assert.assertEquals(actual, expected); Assert.assertEquals(actual, expected);
actual = Utils.escapeExpressions(" one two 'three four' ");
Assert.assertEquals(actual, expected);
} }
} }

View File

@ -150,7 +150,7 @@ object PipelineTest extends BaseTest with Logging {
println(Utils.dupString('-', 80)); println(Utils.dupString('-', 80));
executeTest(name, pipelineTest.args, pipelineTest.jobQueue, pipelineTest.expectedException) executeTest(name, pipelineTest.args, pipelineTest.jobQueue, pipelineTest.expectedException)
if (run) { 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) if (pipelineTest.evalSpec != null)
validateEval(name, pipelineTest.evalSpec) validateEval(name, pipelineTest.evalSpec)
println(" => %s PASSED".format(name)) println(" => %s PASSED".format(name))
@ -159,11 +159,11 @@ object PipelineTest extends BaseTest with Logging {
println(" => %s PASSED DRY RUN".format(name)) 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 var failed = 0
for ((file, expectedMD5) <- fileMD5s) { for ((file, expectedMD5) <- fileMD5s) {
val calculatedMD5 = BaseTest.testFileMD5(name, file, expectedMD5, false) val calculatedMD5 = BaseTest.testFileMD5(name, file, expectedMD5, parameterize)
if (expectedMD5 != "" && expectedMD5 != calculatedMD5) if (!parameterize && expectedMD5 != "" && expectedMD5 != calculatedMD5)
failed += 1 failed += 1
} }
if (failed > 0) if (failed > 0)

View File

@ -19,6 +19,9 @@ class PipelineTestSpec(var name: String = null) {
/** Expected exception from the test. */ /** Expected exception from the test. */
var expectedException: Class[_ <: Exception] = null var expectedException: Class[_ <: Exception] = null
/** If true will check the MD5s without failing. */
var parameterize = false
def this(args: String, fileMD5s: Traversable[(String, String)]) = { def this(args: String, fileMD5s: Traversable[(String, String)]) = {
this() this()
this.args = args this.args = args

View File

@ -31,12 +31,14 @@ import org.broadinstitute.sting.BaseTest
class ExampleCountLociPipelineTest { class ExampleCountLociPipelineTest {
@Test @Test
def testCountLoci { def testCountLoci {
var testOut = "count.out" val testOut = "count.out"
val spec = new PipelineTestSpec val spec = new PipelineTestSpec
spec.name = "countloci" spec.name = "countloci"
spec.args = "-S scala/qscript/examples/ExampleCountLoci.scala -R %s -I %s -o %s".format( spec.args = Array(
BaseTest.hg18Reference, BaseTest.validationDataLocation + "small_bam_for_countloci.bam", testOut " -S scala/qscript/examples/ExampleCountLoci.scala",
) " -R " + BaseTest.hg18Reference,
" -I " + BaseTest.validationDataLocation + "small_bam_for_countloci.bam",
" -o " + testOut).mkString
spec.fileMD5s += testOut -> "67823e4722495eb10a5e4c42c267b3a6" spec.fileMD5s += testOut -> "67823e4722495eb10a5e4c42c267b3a6"
PipelineTest.executeTest(spec) PipelineTest.executeTest(spec)
} }