From 4872ddf3efe4b84b780544d7877473ac94da6902 Mon Sep 17 00:00:00 2001 From: Henri Cook Date: Mon, 25 May 2020 19:31:20 +0100 Subject: [PATCH] Add tests for supporting -debug flag in SBT_OPTSs --- integration-test/src/test/scala/RunnerTest.scala | 14 ++++++++++++++ src/universal/bin/sbt | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 29a0be9bb..7f0ec31d7 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -137,6 +137,20 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } + test("sbt with -debug in SBT_OPTS appears in sbt commands") { + val out: List[String] = sbtProcessWithOpts("compile", "-v")("", "-debug").!!.linesIterator.toList + // Debug argument must appear in the 'commands' section after sbt-launch.jar to work + val locationOfSbtLaunchJarArg = out.zipWithIndex.collectFirst { + case (arg, index) if arg.endsWith("sbt-launch.jar") => index + } + + assert(locationOfSbtLaunchJarArg.nonEmpty) + + val argsAfterSbtLaunch = out.drop(locationOfSbtLaunchJarArg.get) + assert(argsAfterSbtLaunch.contains("-debug")) + () + } + test("sbt -V|-version|--version should print sbtVersion") { val out = sbtProcess("-version").!!.trim val expectedVersion = diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 17ae8f426..2408265b7 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -353,11 +353,11 @@ run() { java_args=($JAVA_OPTS) sbt_options0=(${SBT_OPTS:-$default_sbt_opts}) - # Split SBT_OPTs into options/commands + # Split SBT_OPTS into options/commands miniscript=$(map_args "${sbt_options0[@]}") && eval "${miniscript/options/sbt_options}" && \ eval "${miniscript/commands/sbt_additional_commands}" - # Combine command line options/commands and commands from SBT_OPTs + # Combine command line options/commands and commands from SBT_OPTS miniscript=$(map_args "$@") && eval "${miniscript/options/cli_options}" && eval "${miniscript/commands/cli_commands}" args1=( "${cli_options[@]}" "${cli_commands[@]}" "${sbt_additional_commands[@]}" )