Skip to content

Commit

Permalink
Add scalatest-style -z argument for filtering tests from sbt.
Browse files Browse the repository at this point in the history
  • Loading branch information
fyodorovski committed May 12, 2018
1 parent ebea42d commit e300670
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/scala/org/scalameter/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object Main {
case (acc, x) => Configuration(acc.benches ++ x.benches, acc.context ++ x.context)
}
}
def arg: Parser[Configuration] = benches | intsetting | resdir | scopefilt | flag
def arg: Parser[Configuration] = benches | intsetting | resdir | scopefilter | shortscopefilter | flag
def listOf(flagname: String, shorthand: String): Parser[Seq[String]] = "-" ~ (flagname | shorthand) ~ classnames ^^ {
case _ ~ _ ~ classnames => classnames
}
Expand All @@ -66,9 +66,12 @@ object Main {
def stringLit = "['\"]".r ~ rep("[^'']".r) ~ "['\"]".r ^^ {
case _ ~ cs ~ _ => cs.mkString
}
def scopefilt: Parser[Configuration] = "-" ~ "CscopeFilter" ~ (stringLit | failure("scopeFilter must be followed by a single or double quoted string.")) ^^ {
def scopefilter: Parser[Configuration] = "-" ~ "CscopeFilter" ~ (stringLit | failure("scopeFilter must be followed by a single or double quoted string.")) ^^ {
case _ ~ _ ~ s => Configuration(Nil, Context(scopeFilter -> s))
}
def shortscopefilter: Parser[Configuration] = "-z" ~ ("""[a-zA-Z\.]+""".r) ^^ {
case _ ~ s => Configuration(Nil, Context(scopeFilter -> s))
}
def flag: Parser[Configuration] = "-" ~ ("silent" | "verbose" | "preJDK7") ^^ {
case _ ~ "verbose" => Configuration(Nil, Context(Key.verbose -> true))
case _ ~ "silent" => Configuration(Nil, Context(Key.verbose -> false))
Expand All @@ -77,7 +80,7 @@ object Main {

parseAll(arguments, args.mkString(" ")) match {
case Success(result, _) => result
case Failure(msg, _) => sys.error("failed to parse args: " + msg)
case Failure(msg, _) => sys.error("failed to parse args " + args.mkString(", ") + ": " + msg)
case Error(msg, _) => sys.error("error while parsing args: " + msg)
}
}
Expand Down

0 comments on commit e300670

Please sign in to comment.