Skip to content

Commit

Permalink
bat script: fix parsing of -J-XX: jvm args
Browse files Browse the repository at this point in the history
  • Loading branch information
dwickern committed Jan 4, 2024
1 parent 672ed32 commit ccced7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@ rem Processes incoming arguments and places them in appropriate global variables

if "!_TEST_PARAM:~0,2!"=="-J" (
rem strip -J prefix
set _JAVA_PARAMS=!_JAVA_PARAMS! !_TEST_PARAM:~2!
call set _TEST_PARAM=!_TEST_PARAM:~2!
if not "!_TEST_PARAM:~0,5!" == "-XX:+" if not "!_TEST_PARAM:~0,5!" == "-XX:-" if "!_TEST_PARAM:~0,3!" == "-XX" (
rem special handling for -J-XX since '=' gets parsed away
for /F "delims== tokens=1,*" %%G in ("!_TEST_PARAM!") DO (
call set _TEST_PARAM=!_TEST_PARAM!=%%1
shift
)
)
set _JAVA_PARAMS=!_JAVA_PARAMS! !_TEST_PARAM!
goto param_loop
)

Expand Down
6 changes: 6 additions & 0 deletions src/sbt-test/windows/test-bat-template/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ TaskKey[Unit]("checkScript") := {
"arg #0 is [first]\narg #1 is [-XX]\narg #2 is [last]\nproperty(test.hoge) is [huga]\nvmarg #0 is [-Dtest.hoge=huga]\nvmarg #1 is [-Xms6m]\nSUCCESS!",
Map("show-vmargs" -> "true")
)
checkOutput(
"with -J-XX java-opts",
Seq("-J-XX:+UseG1GC", "-J-XX:-UnlockExperimentalVMOptions", "-J-XX:MaxGCPauseMillis=500"),
"vmarg #0 is [-XX:+UseG1GC]\nvmarg #1 is [-XX:-UnlockExperimentalVMOptions]\nvmarg #2 is [-XX:MaxGCPauseMillis=500]\nSUCCESS!",
Map("show-vmargs" -> "true")
)
checkOutput(
"include space",
Seq("""-Dtest.hoge=C:\Program Files\Java""", """"C:\Program Files\Java""""),
Expand Down

0 comments on commit ccced7a

Please sign in to comment.