From b4fe705aa6fd74b34ea1de457a981a31b0a941c0 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 28 Feb 2013 11:49:32 -0600 Subject: more cleanup --- .../scala/org/perl8/test/harness/TestHarness.scala | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/main') diff --git a/src/main/scala/org/perl8/test/harness/TestHarness.scala b/src/main/scala/org/perl8/test/harness/TestHarness.scala index 09f780b..cd77901 100644 --- a/src/main/scala/org/perl8/test/harness/TestHarness.scala +++ b/src/main/scala/org/perl8/test/harness/TestHarness.scala @@ -5,25 +5,32 @@ object TestHarness { def main (args: Array[String]) { val opts = parseOpts(args.toList) - val multi = !opts("prefer-single").asInstanceOf[Boolean] + val single = opts("prefer-single").asInstanceOf[Boolean] - val exitCode = if (multi) { - val reporterName = opts("multi-reporter").asInstanceOf[String] - val testNames = opts("test-classes").asInstanceOf[List[String]] - val reporter = newInstance[MultiTestReporter](reporterName) - reporter.run(testNames) - } - else { + val exitCode = if (single) { val reporterName = opts("single-reporter").asInstanceOf[String] val testName = opts("test-classes").asInstanceOf[List[String]].apply(0) val reporter = newInstance[Reporter](reporterName) reporter.run(testName) } + else { + val reporterName = opts("multi-reporter").asInstanceOf[String] + val testNames = opts("test-classes").asInstanceOf[List[String]] + val reporter = newInstance[MultiTestReporter](reporterName) + reporter.run(testNames) + } sys.exit(exitCode) } def parseOpts (args: List[String]): Map[String, Any] = args match { + case Nil => Map( + "single-reporter" -> "org.perl8.test.harness.TAPReporter", + "multi-reporter" -> "org.perl8.test.harness.SummaryReporter", + "prefer-single" -> true, + "test-classes" -> Nil + ) + case "-r" :: singleReporter :: rest => parseOpts(rest) + ("single-reporter" -> singleReporter) @@ -36,14 +43,7 @@ object TestHarness { case "--help" :: rest => usage(0) - case Nil => Map( - "single-reporter" -> "org.perl8.test.harness.TAPReporter", - "multi-reporter" -> "org.perl8.test.harness.SummaryReporter", - "prefer-single" -> true, - "test-classes" -> Nil - ) - - case `unknownOption` => + case `unknownOption` :: rest => usage(1) case testClass :: rest => { -- cgit v1.2.3-54-g00ecf