Merge pull request #317 from eed3si9n/wip/star

Fixes quoted argument with whitespace
This commit is contained in:
eugene yokota 2020-01-04 15:31:11 -05:00 committed by GitHub
commit 269533c160
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 20 deletions

View File

@ -48,21 +48,14 @@ matrix:
- sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test
- cd citest && ./test.sh
- name: "build using JDK 8 test using JDK 8"
script:
- sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test
- cd citest && ./test.sh
- name: "build using JDK 8, test using OpenJDK 11"
script:
- sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test
- $JABBA_HOME/bin/jabba install $TRAVIS_JDK11 && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK11" && export PATH="$JAVA_HOME/bin:$PATH"
- java -Xmx32m -version
- cd citest && ./test.sh
- name: "Linux package testing"
- name: "build using JDK 8 test using JDK 8 and JDK 11"
script:
- sbt -Dsbt.build.version=$SBT_VER rpm:packageBin debian:packageBin
- sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test
- cd citest && ./test.sh
- $JABBA_HOME/bin/jabba install $TRAVIS_JDK11 && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK11" && export PATH="$JAVA_HOME/bin:$PATH"
- java -Xmx32m -version
- ./test.sh
addons:
apt:
packages:

View File

@ -11,3 +11,18 @@ $ sbt -Dsbt.build.version=1.0.3 -Dsbt.build.offline=true
> rpm:releaseAllStaged
```
## Notes on batch
### Testing if a variable is blank
```
if not defined _JAVACMD set _JAVACMD=java
```
### Testing if an argument %0 is blank
```
if "%~0" == "" goto echolist_end
```
The above would work in case `%0` contains either double quote (`"`) or whitespace.

View File

@ -5,6 +5,8 @@ lazy val root = (project in file("."))
.settings(
scalaVersion := "2.12.4",
name := "Hello",
libraryDependencies += "com.eed3si9n.verify" %% "verify" % "0.2.0" % Test,
testFrameworks += new TestFramework("verify.runner.Framework"),
check := {
val xs = IO.readLines(file("output.txt")).toVector

View File

@ -0,0 +1,7 @@
import verify._
object HelloTest extends BasicTestSuite {
test("addition") {
assert(2 == 1 + 1)
}
}

View File

@ -174,4 +174,10 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions {
)
()
}
test("sbt \"testOnly *\"") {
val out = sbtProcess("testOnly *", "--no-colors", "-v").!!.linesIterator.toList
assert(out.contains[String]("[info] HelloTest"))
()
}
}

View File

@ -118,7 +118,7 @@ if not defined _SBT_OPTS if defined default_sbt_opts set _SBT_OPTS=!default_sbt_
:args_loop
shift
if [%0] EQU [] goto args_end
if "%~0" == "" goto args_end
set g=%~0
rem make sure the sbt_args_debug gets set first incase any argument parsing uses :dlog
@ -369,7 +369,7 @@ if "%~0" == "--jvm-debug" set _jvm_debug_arg=true
if defined _jvm_debug_arg (
set _jvm_debug_arg=
if [%1] NEQ [] (
if not "%~1" == "" (
set /a JVM_DEBUG_PORT=%~1 2>nul >nul
if !JVM_DEBUG_PORT! EQU 0 (
rem next argument wasn't a port, set a default and process next arg
@ -384,7 +384,7 @@ if "%~0" == "--java-home" set _java_home_arg=true
if defined _java_home_arg (
set _java_home_arg=
if [%1] NEQ [] (
if not "%~1" == "" (
if exist "%~1\bin\java.exe" (
set "_JAVACMD=%~1\bin\java.exe"
set "JAVA_HOME=%~1"
@ -596,7 +596,7 @@ if defined sbt_args_verbose (
echo -cp
echo "!sbt_jar!"
echo xsbt.boot.Boot
if not [%~1] == [] ( call :echolist %* )
if not "%~1" == "" ( call :echolist %* )
echo.
)
@ -610,8 +610,8 @@ rem fixes dealing with quotes after = args: -Dscala.ext.dirs="C:\Users\First Las
rem call method is in first call of %0
shift
if [%0] EQU [] goto echolist_end
set "p=%0"
if "%~0" == "" goto echolist_end
set "p=%~0"
if "%p:~0,2%" == "-D" (
rem special handling for -D since '=' gets parsed away
@ -791,7 +791,7 @@ if /I !JAVA_VERSION! GEQ 9 (
exit /B 0
:sync_preloaded
if [!init_sbt_version] == [] (
if not defined init_sbt_version (
rem FIXME: better !init_sbt_version! detection
FOR /F "tokens=* usebackq" %%F IN (`dir /b "!SBT_HOME!\lib\local-preloaded\org\scala-sbt\sbt" /B`) DO (
SET init_sbt_version=%%F