Skip to content

Fix for #20 - Add Support for CLI options #21

Closed
wants to merge 3 commits into from
View
34 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 {
@@ -32,20 +33,41 @@ 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,
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)
+ def isAnOption(arg: String) = supportedOptions.contains(arg)
+ 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 +76,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)
}
View
20 project/Build.scala
@@ -1,9 +1,11 @@
import sbt._
import Keys._
+import Versions._
+
object Settings {
val buildOrganization = "templemore"
- val buildScalaVersion = "2.9.2"
+ val buildScalaVersion = scala2_9
val buildVersion = "0.7.2"
val buildSettings = Defaults.defaultSettings ++
@@ -16,9 +18,6 @@ object Settings {
object Dependencies {
- private val CucumberVersionForScala2_9 = "1.0.9"
- private val CucumberVersionForScala2_10 = "1.1.1"
-
def cucumberScala(scalaVersion: String) = {
def cucumberVersion = if ( scalaVersion.startsWith("2.10") ) CucumberVersionForScala2_10 else CucumberVersionForScala2_9
"info.cukes" % "cucumber-scala" % cucumberVersion % "compile"
@@ -32,18 +31,27 @@ object Build extends Build {
import Dependencies._
import Settings._
+ private val crossVersions = Seq(scala2_9, scala2_10)
+
lazy val parentProject = Project("sbt-cucumber-parent", file ("."),
settings = buildSettings ++
- Seq(crossScalaVersions := Seq("2.9.2", "2.10.0-RC2"))) aggregate (pluginProject, integrationProject)
+ Seq(crossScalaVersions := crossVersions)) aggregate (pluginProject, integrationProject)
lazy val pluginProject = Project("sbt-cucumber-plugin", file ("plugin"),
settings = buildSettings ++
Seq(sbtPlugin := true))
lazy val integrationProject = Project ("sbt-cucumber-integration", file ("integration"),
settings = buildSettings ++
- Seq(crossScalaVersions := Seq("2.9.2", "2.10.0-RC2"),
+ Seq(crossScalaVersions := crossVersions,
libraryDependencies <+= scalaVersion { sv => cucumberScala(sv) },
libraryDependencies += testInterface))
}
+
+object Versions {
+ val scala2_9 = "2.9.2"
+ val scala2_10 = "2.10.0"
+ val CucumberVersionForScala2_9 = "1.0.9"
+ val CucumberVersionForScala2_10 = "1.1.1"
+}
Something went wrong with that request. Please try again.