Permalink
Browse files

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.
  • Loading branch information...
1 parent 046c5b1 commit 82647b600f7e59aa3f5df60b21cdcc49b5de817f Tim Sheppard committed Jan 31, 2013
Showing with 20 additions and 3 deletions.
  1. +20 −3 plugin/src/main/scala/templemore/sbt/cucumber/Integration.scala
@@ -33,6 +33,25 @@ trait Integration {
}
}
+ /*
+ * The options that are supported by the plugin.
+ * This excludes options that are set in other places such as formatting
+ * and dotcucumber etc.
+ *
+ * This is essentially a list of the parameter-less options supported by the
+ * `cucumber-jvm` `cucumber.runtime.RuntimeOptions` class
+ *
+ * The `--no-xxx` version of the options are not included as they are not enabled
+ * by default and are therefore not really necessary.
+ */
+ private val supportedOptions = Seq("-d",
+ "--dry-run",
+ "-s",
+ "--strict",
+ "-m",
+ "--monochrome")
+
+
private def runCucumber(args: Seq[String],
jvmSettings: JvmSettings,
options: Options,
@@ -42,9 +61,7 @@ trait Integration {
def optsFromArgs = args.filter(isAnOption).toList
def namesFromArgs = args.filter(isAName).toList
- val optionPattern = """-[a-z]""".r.pattern
-
- def isAnOption(arg: String) = (arg.startsWith("--") || optionPattern.matcher(arg).matches())
+ def isAnOption(arg: String) = supportedOptions.contains(arg)
def isATag(arg: String) = arg.startsWith("@") || arg.startsWith("~@")
def isAName(arg:String) = !isATag(arg) && !isAnOption(arg)

0 comments on commit 82647b6

Please sign in to comment.