From 2946025d750c378d7f742603142843c16754eded Mon Sep 17 00:00:00 2001 From: Anil Kumar Myla Date: Fri, 13 Sep 2019 19:56:39 -0700 Subject: [PATCH 1/2] Capture double dashes in process args --- src/universal/bin/sbt | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 9b160f3d4..dbfcaec53 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -516,28 +516,28 @@ map_args () { process_args () { while [[ $# -gt 0 ]]; do case "$1" in - -h|-help) usage; exit 1 ;; - -v|-verbose) sbt_verbose=1 && shift ;; - -V|-version) print_sbt_version=1 && shift ;; - -d|-debug) sbt_debug=1 && addSbt "-debug" && shift ;; + -h|-help|--help) usage; exit 1 ;; + -v|-verbose|--verbose) sbt_verbose=1 && shift ;; + -V|-version|--version) print_sbt_version=1 && shift ;; + -d|-debug|--debug) sbt_debug=1 && addSbt "-debug" && shift ;; - -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; - -mem) require_arg integer "$1" "$2" && addMemory "$2" && shift 2 ;; - -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; - -batch) exec Date: Fri, 13 Sep 2019 22:36:30 -0700 Subject: [PATCH 2/2] Add integration tests --- integration-test/src/test/scala/RunnerTest.scala | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 30cca6b5e..c5c1d4c80 100644 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -9,10 +9,7 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { lazy val sbtScript = if (isWindows) new File("target/universal/stage/bin/sbt.bat") else new File("target/universal/stage/bin/sbt") - def sbtProcess(arg: String) = - sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest"), - "JAVA_OPTS" -> "", - "SBT_OPTS" -> "") + def sbtProcess(arg: String) = sbtProcessWithOpts(arg, "", "") def sbtProcessWithOpts(arg: String, javaOpts: String, sbtOpts: String) = sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest"), "JAVA_OPTS" -> javaOpts, @@ -55,6 +52,12 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } + test("sbt --sbt-version") { + val out = sbtProcess("--sbt-version 1.3.0 compile -v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.version=1.3.0")) + () + } + test("sbt -mem 503") { val out = sbtProcess("compile -mem 503 -v").!!.linesIterator.toList assert(out.contains[String]("-Xmx503m"))