Skip to content

Commit

Permalink
Merge pull request #503 from sbt/fix/windows-test-appveyor
Browse files Browse the repository at this point in the history
FIX #502 Removing JAVA_OPTS
  • Loading branch information
muuki88 committed Feb 25, 2015
2 parents cfdff4c + 4467d31 commit aa85388
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 29 deletions.
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)
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)
}

0 comments on commit aa85388

Please sign in to comment.