Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX #502 Removing JAVA_OPTS #503

Merged
merged 4 commits into from
Feb 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ install:
}
- cmd: SET PATH=C:\sbt\sbt\bin;%JAVA_HOME%\bin;%PATH%
- cmd: SET SBT_OPTS=-XX:MaxPermSize=2g -Xmx4g
- cmd: SET JAVA_OPTS=-XX:MaxPermSize=2g -Xmx4g
build_script:
- sbt clean compile
test_script:
- sbt "test-only * -- -n windows"
- sbt "scripted universal/dist universal/stage windows/java-app-archetype windows/test-custom-main"
- sbt "scripted universal/dist universal/stage windows/*"
cache:
- C:\sbt\
- C:\Users\appveyor\.m2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ if defined CUSTOM_MAIN_CLASS (

rem Call the application and pass all arguments unchanged.
"%_JAVACMD%" !_JAVA_OPTS! !@@APP_ENV_NAME@@_OPTS! -cp "%APP_CLASSPATH%" %MAIN_CLASS% !_APP_ARGS!
if ERRORLEVEL 1 goto error
goto end

@endlocal

Expand Down
78 changes: 53 additions & 25 deletions src/sbt-test/windows/test-bat-template/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,23 @@ TaskKey[Unit]("check-script") <<= (stagingDirectory in Universal, name, streams)
val detailScript:File = {
val d = dir / "bin" / "detail.bat"
val out = new java.io.PrintWriter( d , "UTF-8")
out.print( scala.io.Source.fromFile(script).mkString.replaceAll("@echo off","@echo on & prompt \\$g ") )
out.print( scala.io.Source.fromFile(script).mkString.replaceAll("@echo off","echo on & prompt \\$g ") )
out.close
d
}
def crlf2cr(txt:String) = txt.trim.replaceAll("\\\r\\\n", "\n")
def checkOutputEnv(env:Map[String,String], expectedRC: Int, expected:String, args:String*) = {
def checkOutput(testName:String, args:String, expected:String, env:Map[String,String]=Map.empty, expectedRC: Int=0) = {
val pr = new StringBuilder()
val logger = ProcessLogger((o: String) => pr.append(o+"\n"),(e: String) => pr.append("error < " + e+"\n"))
val cmd = Seq("cmd", "/c", script.getAbsolutePath) ++ args
val cmd = Seq("cmd", "/c", script.getAbsolutePath+" "+args)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, java doesn't seem to like the command sequence :(
Thanks for figuring this out

val result = Process(cmd, None, env.toSeq:_*) ! logger
if ( result != expectedRC ) {
pr.append("error code: " + result+"\n")
}
val output = crlf2cr(pr.toString)
if(result != expectedRC || output != expected.trim){
fails.append("\n---------------------------------\n")
fails.append(testName)
fails.append("\n---------------------------------\n")
fails.append("Failed to correctly run the main script!.\n")
fails.append("\""+cmd.mkString("\" \"")+"\"\n")
Expand All @@ -70,34 +72,60 @@ TaskKey[Unit]("check-script") <<= (stagingDirectory in Universal, name, streams)
fails.append(crlf2cr(pr.toString)+"\n")
fails.append("\n--detail-------------------------------\n")
pr.clear
Process(Seq("cmd", "/c", detailScript.getAbsolutePath) ++ args, None, env.toSeq:_*) ! logger
Process(Seq("cmd", "/c", detailScript.getAbsolutePath+" "+args), None, env.toSeq:_*) ! logger
fails.append(crlf2cr(pr.toString)+"\n")
}
if(debugOutFile.exists){
debugOutFile.delete()
}
}
def checkOutput(expectedRC: Int, expected:String, args:String*) = checkOutputEnv(Map.empty, expectedRC, expected, args:_*)
checkOutput(0, "arg #0 is [OK]\nSUCCESS!", "OK")
checkOutput(0, "arg #0 is [OK]\nproperty(test.hoge) is [huga]\nSUCCESS!", "-Dtest.hoge=\"huga\"", "OK")
checkOutputEnv(Map("show-vmargs"->"true"), 0, "arg #0 is [OK]\nvmarg #0 is [-Xms6m]\nSUCCESS!","-J-Xms6m", "OK")
checkOutputEnv(Map("show-vmargs"->"true"), 0, "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!",
"first", "-Dtest.hoge=\"huga\"", "-J-Xms6m", "-XX", "last")
// include space
checkOutput(0, "arg #0 is [C:\\Program Files\\Java]\nproperty(test.hoge) is [C:\\Program Files\\Java]\nSUCCESS!",
"-Dtest.hoge=C:\\Program Files\\Java", "C:\\Program Files\\Java")
// split "include symbols"
checkOutput(0, "property(test.hoge) is [\\[]!< >%]\nSUCCESS!", "\"-Dtest.hoge=\\[]!< >%\"")
checkOutput(0, "arg #0 is [\\[]!< >%]\nSUCCESS!", "\\[]!< >%")
checkOutput(0, "property(test.huga) is [\\[]!<>%]\nSUCCESS!", "-Dtest.huga=\"\\[]!<>%\"")
// include symbols
checkOutput(0, "arg #0 is [\\[]!< >%]\nproperty(test.hoge) is [\\[]!< >%]\nproperty(test.huga) is [\\[]!<>%]\nSUCCESS!",
"\"-Dtest.hoge=\\[]!< >%\"", "\\[]!< >%", "-Dtest.huga=\"\\[]!<>%\"")
// include space and double-quote is failed...
checkOutput("normal argmument",
"OK",
"arg #0 is [OK]\nSUCCESS!")
checkOutput("with -D",
"-Dtest.hoge=\"huga\" OK",
"arg #0 is [OK]\nproperty(test.hoge) is [huga]\nSUCCESS!")
checkOutput("with -J java-opt",
"-J-Xms6m OK",
"arg #0 is [OK]\nvmarg #0 is [-Xms6m]\nSUCCESS!",
Map("show-vmargs"->"true"))
checkOutput("complex",
"first -Dtest.hoge=\"huga\" -J-Xms6m -XX last",
"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("include space",
"""-Dtest.hoge="C:\Program Files\Java" "C:\Program Files\Java" """,
"arg #0 is [C:\\Program Files\\Java]\nproperty(test.hoge) is [C:\\Program Files\\Java]\nSUCCESS!")
checkOutput("include symbols on -D",
"\"-Dtest.hoge=\\[]!< >%\"",
"property(test.hoge) is [\\[]!< >%]\nSUCCESS!")
checkOutput("include symbols on normal args",
""" "\[]!< >%" """,
"arg #0 is [\\[]!< >%]\nSUCCESS!")
checkOutput("include symbols with double quote",
"-Dtest.huga=\"[]!<>%\"",
"property(test.huga) is [[]!<>%]\nSUCCESS!")
checkOutput("include symbols with double quote2",
""" "-Dtest.hoge=\[]!< >%" "\[]!< >%" -Dtest.huga="\[]!<>%" """,
"arg #0 is [\\[]!< >%]\nproperty(test.hoge) is [\\[]!< >%]\nproperty(test.huga) is [\\[]!<>%]\nSUCCESS!")
// can't success include double-quote. arguments pass from Process(Seq("-Da=xx\"yy", "aa\"bb")) is parsed (%1="-Da", %2="xx\"yy aa\"bb") by cmd.exe ...
//checkOutput(0, "arg #0 is [xx\"yy]\nproperty(test.hoge) is [aa\"bb]\nvmarg #0 is [-Dtest.hoge=aa\"bb]\nSUCCESS!", "-Dtest.hoge=aa\"bb", "xx\"yy")
checkOutputEnv(Map("return-code"->"1"), 1, "arg #0 is [RC1]\nFAILURE!", "RC1")
checkOutputEnv(Map("return-code"->"2"), 2, "arg #0 is [RC2]\nFAILURE!", "RC2")
checkOutputEnv(Map("return-code"->"-1"), -1, "arg #0 is [RC-1]\nFAILURE!", "RC-1")
//checkOutput("include space and double-quote",
// "-Dtest.hoge=aa\"bb xx\"yy",
// "arg #0 is [xx\"yy]\nproperty(test.hoge) is [aa\"bb]\nvmarg #0 is [-Dtest.hoge=aa\"bb]\nSUCCESS!")
checkOutput("return-cord not 0",
"RC1",
"arg #0 is [RC1]\nFAILURE!",
Map("return-code"->"1"),
1)
checkOutput("return-cord not 0 and 1",
"RC2",
"arg #0 is [RC2]\nFAILURE!",
Map("return-code"->"2"),
2)
checkOutput("return-code negative",
"RC-1",
"arg #0 is [RC-1]\nFAILURE!",
Map("return-code"->"-1"),
-1)
assert(fails.toString == "", fails.toString)
}