Skip to content

Commit 82647b6

Browse files
author
Tim Sheppard
committed
Changed implementation of option checking to use a fixed whitelist of supported options rather than pattern match.
This makes it much more robust and will not pass parameters that are not supported or handled by the plugin in a different way.
1 parent 046c5b1 commit 82647b6

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

Diff for: plugin/src/main/scala/templemore/sbt/cucumber/Integration.scala

+20-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ trait Integration {
3333
}
3434
}
3535

36+
/*
37+
* The options that are supported by the plugin.
38+
* This excludes options that are set in other places such as formatting
39+
* and dotcucumber etc.
40+
*
41+
* This is essentially a list of the parameter-less options supported by the
42+
* `cucumber-jvm` `cucumber.runtime.RuntimeOptions` class
43+
*
44+
* The `--no-xxx` version of the options are not included as they are not enabled
45+
* by default and are therefore not really necessary.
46+
*/
47+
private val supportedOptions = Seq("-d",
48+
"--dry-run",
49+
"-s",
50+
"--strict",
51+
"-m",
52+
"--monochrome")
53+
54+
3655
private def runCucumber(args: Seq[String],
3756
jvmSettings: JvmSettings,
3857
options: Options,
@@ -42,9 +61,7 @@ trait Integration {
4261
def optsFromArgs = args.filter(isAnOption).toList
4362
def namesFromArgs = args.filter(isAName).toList
4463

45-
val optionPattern = """-[a-z]""".r.pattern
46-
47-
def isAnOption(arg: String) = (arg.startsWith("--") || optionPattern.matcher(arg).matches())
64+
def isAnOption(arg: String) = supportedOptions.contains(arg)
4865
def isATag(arg: String) = arg.startsWith("@") || arg.startsWith("~@")
4966
def isAName(arg:String) = !isATag(arg) && !isAnOption(arg)
5067

0 commit comments

Comments
 (0)