Permalink
Browse files

Added creation of options list

The inputs args are now parsed for tags, options and names.

Tags begin with `@` or `~@`
Options either begin with `--` or match `-[a-z]`
Names are all those args that are neither a Tag or an Option

The new Options list is now appended to the runner args.
  • Loading branch information...
Tim Sheppard
Tim Sheppard committed Jan 31, 2013
1 parent 08980a7 commit 046c5b1d0dd86ef6bf31e04ef05196043f34ff68
Showing with 12 additions and 5 deletions.
  1. +12 −5 plugin/src/main/scala/templemore/sbt/cucumber/Integration.scala
@@ -9,6 +9,7 @@ import templemore.sbt.util._
* cucumber as both a forked JVM and within the current JVM process.
*
* @author Chris Turner
+ * @author RandomCoder
*/
trait Integration {
@@ -38,14 +39,18 @@ trait Integration {
output: Output,
log: Logger) = {
def tagsFromArgs = args.filter(isATag).toList
- def namesFromArgs = args.filter(isNotATag).toList
+ def optsFromArgs = args.filter(isAnOption).toList
+ def namesFromArgs = args.filter(isAName).toList
- def isATag(arg: String) = arg.startsWith("@") || arg.startsWith("~")
- def isNotATag(arg: String) = !isATag(arg)
+ val optionPattern = """-[a-z]""".r.pattern
+
+ def isAnOption(arg: String) = (arg.startsWith("--") || optionPattern.matcher(arg).matches())
+ def isATag(arg: String) = arg.startsWith("@") || arg.startsWith("~@")
+ def isAName(arg:String) = !isATag(arg) && !isAnOption(arg)
log.info("Running cucumber...")
options.beforeFunc()
- val result = launchCucumberInSeparateJvm(jvmSettings, options, output, tagsFromArgs, namesFromArgs)
+ val result = launchCucumberInSeparateJvm(jvmSettings, options, output, tagsFromArgs, namesFromArgs, optsFromArgs)
options.afterFunc()
result
}
@@ -54,14 +59,16 @@ trait Integration {
options: Options,
output: Output,
tags: List[String],
- names: List[String]): Int = {
+ names: List[String],
+ cucumberOptions: List[String]): Int = {
def makeOptionsList(options: List[String], flag: String) = options flatMap(List(flag, _))
val cucumberParams = ("--glue" :: options.basePackage :: Nil) ++
options.extraOptions ++
output.options ++
makeOptionsList(tags, "--tags") ++
makeOptionsList(names, "--name") ++
+ cucumberOptions ++
(options.featuresLocation :: Nil)
JvmLauncher(jvmSettings).launch(cucumberParams)
}

0 comments on commit 046c5b1

Please sign in to comment.