aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/scala/org/perl8/test/harness/TestHarness.scala
blob: 4865c2c9ac0de81672cc668d8ae14526a89c1595 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.perl8.test.harness

object TestHarness {
  import org.perl8.test.Test

  def main (args: Array[String]) {
    val (reporterName, idx, multi) = if (args.length >= 2 && args(0) == "-r") {
      (args(1), 2, false)
    }
    else if (args.length >= 2 && args(0) == "-R") {
      (args(1), 2, true)
    }
    else if (args.length > 1) {
      ("org.perl8.test.harness.SummaryReporter", 0, true)
    }
    else if (args.length == 1) {
      ("org.perl8.test.harness.TAPReporter", 0, false)
    }
    else {
      println("No tests specified!")
      sys.exit(1)
    }

    val exitCode = if (multi) {
      val testNames = args.drop(idx)
      val reporter = newInstance[MultiTestReporter](reporterName)
      reporter.run(testNames)
    }
    else {
      val testName = args(idx)
      val reporter = newInstance[Reporter](reporterName)
      reporter.run(testName)
    }

    sys.exit(exitCode)
  }
}