Skip to content

Commit 046c5b1

Browse files
author
Tim Sheppard
committed
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.
1 parent 08980a7 commit 046c5b1

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

plugin/src/main/scala/templemore/sbt/cucumber/Integration.scala

+12-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import templemore.sbt.util._
99
* cucumber as both a forked JVM and within the current JVM process.
1010
*
1111
* @author Chris Turner
12+
* @author RandomCoder
1213
*/
1314
trait Integration {
1415

@@ -38,14 +39,18 @@ trait Integration {
3839
output: Output,
3940
log: Logger) = {
4041
def tagsFromArgs = args.filter(isATag).toList
41-
def namesFromArgs = args.filter(isNotATag).toList
42+
def optsFromArgs = args.filter(isAnOption).toList
43+
def namesFromArgs = args.filter(isAName).toList
4244

43-
def isATag(arg: String) = arg.startsWith("@") || arg.startsWith("~")
44-
def isNotATag(arg: String) = !isATag(arg)
45+
val optionPattern = """-[a-z]""".r.pattern
46+
47+
def isAnOption(arg: String) = (arg.startsWith("--") || optionPattern.matcher(arg).matches())
48+
def isATag(arg: String) = arg.startsWith("@") || arg.startsWith("~@")
49+
def isAName(arg:String) = !isATag(arg) && !isAnOption(arg)
4550

4651
log.info("Running cucumber...")
4752
options.beforeFunc()
48-
val result = launchCucumberInSeparateJvm(jvmSettings, options, output, tagsFromArgs, namesFromArgs)
53+
val result = launchCucumberInSeparateJvm(jvmSettings, options, output, tagsFromArgs, namesFromArgs, optsFromArgs)
4954
options.afterFunc()
5055
result
5156
}
@@ -54,14 +59,16 @@ trait Integration {
5459
options: Options,
5560
output: Output,
5661
tags: List[String],
57-
names: List[String]): Int = {
62+
names: List[String],
63+
cucumberOptions: List[String]): Int = {
5864
def makeOptionsList(options: List[String], flag: String) = options flatMap(List(flag, _))
5965

6066
val cucumberParams = ("--glue" :: options.basePackage :: Nil) ++
6167
options.extraOptions ++
6268
output.options ++
6369
makeOptionsList(tags, "--tags") ++
6470
makeOptionsList(names, "--name") ++
71+
cucumberOptions ++
6572
(options.featuresLocation :: Nil)
6673
JvmLauncher(jvmSettings).launch(cucumberParams)
6774
}

0 commit comments

Comments
 (0)