Report a readable diagnostic on empty -J argument in CLI

This commit is contained in:
scaventz
2021-02-22 11:16:03 +08:00
committed by Alexander Udalov
parent 81a495b494
commit 9a7ef11043
3 changed files with 22 additions and 2 deletions
+4
View File
@@ -52,6 +52,10 @@ while [ $# -gt 0 ]; do
;;
-J*)
java_args=("${java_args[@]}" "${1:2}")
if [ "x${1:2}" = "x" ]; then
echo "error: empty -J argument"
exit 1
fi
shift
;;
*)
+8 -2
View File
@@ -28,6 +28,10 @@ set _arg=%~1
if "%_arg%" == "" goto loopend
if "%_arg:~0,2%"=="-J" (
if "%_arg:~2%"=="" (
echo error: empty -J argument
goto error
)
set JAVA_OPTS=%JAVA_OPTS% "%_arg:~2%"
) else (
if "%_arg:~0,2%"=="-D" (
@@ -67,7 +71,6 @@ if "!_KOTLIN_RUNNER!"=="1" (
%_KOTLIN_COMPILER% %KOTLIN_OPTS%
)
exit /b %ERRORLEVEL%
goto end
rem ##########################################################################
@@ -103,5 +106,8 @@ rem Needs to be executed in the EnableDelayedExpansion mode.
)
goto :eof
:error
set ERRORLEVEL=1
:end
endlocal
exit /b %ERRORLEVEL%
@@ -349,4 +349,14 @@ fun f() : Result<Int> = Result.success(42)
expectedStdout = "[OK]\n", environment = jdk15,
)
}
fun testEmptyJArgument() {
runProcess(
"kotlinc",
"$testDataDirectory/helloWorld.kt",
"-d", tmpdir.path,
"-J", expectedStdout = "error: empty -J argument\n",
expectedExitCode = 1
)
}
}