From 82647b600f7e59aa3f5df60b21cdcc49b5de817f Mon Sep 17 00:00:00 2001 From: Tim Sheppard Date: Thu, 31 Jan 2013 15:37:38 +0000 Subject: [PATCH] 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. --- .../templemore/sbt/cucumber/Integration.scala | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/scala/templemore/sbt/cucumber/Integration.scala b/plugin/src/main/scala/templemore/sbt/cucumber/Integration.scala index 9bfc059..1d97905 100644 --- a/plugin/src/main/scala/templemore/sbt/cucumber/Integration.scala +++ b/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)