Skip to content

Commit aa85388

Browse files
committed
Merge pull request #503 from sbt/fix/windows-test-appveyor
FIX #502 Removing JAVA_OPTS
2 parents cfdff4c + 4467d31 commit aa85388

File tree

3 files changed

+54
-29
lines changed

3 files changed

+54
-29
lines changed

appveyor.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ install:
1212
}
1313
- cmd: SET PATH=C:\sbt\sbt\bin;%JAVA_HOME%\bin;%PATH%
1414
- cmd: SET SBT_OPTS=-XX:MaxPermSize=2g -Xmx4g
15-
- cmd: SET JAVA_OPTS=-XX:MaxPermSize=2g -Xmx4g
1615
build_script:
1716
- sbt clean compile
1817
test_script:
1918
- sbt "test-only * -- -n windows"
20-
- sbt "scripted universal/dist universal/stage windows/java-app-archetype windows/test-custom-main"
19+
- sbt "scripted universal/dist universal/stage windows/*"
2120
cache:
2221
- C:\sbt\
2322
- C:\Users\appveyor\.m2

src/main/resources/com/typesafe/sbt/packager/archetypes/bat-template

-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ if defined CUSTOM_MAIN_CLASS (
137137

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

143141
@endlocal
144142

src/sbt-test/windows/test-bat-template/build.sbt

+53-25
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,23 @@ TaskKey[Unit]("check-script") <<= (stagingDirectory in Universal, name, streams)
4141
val detailScript:File = {
4242
val d = dir / "bin" / "detail.bat"
4343
val out = new java.io.PrintWriter( d , "UTF-8")
44-
out.print( scala.io.Source.fromFile(script).mkString.replaceAll("@echo off","@echo on & prompt \\$g ") )
44+
out.print( scala.io.Source.fromFile(script).mkString.replaceAll("@echo off","echo on & prompt \\$g ") )
4545
out.close
4646
d
4747
}
4848
def crlf2cr(txt:String) = txt.trim.replaceAll("\\\r\\\n", "\n")
49-
def checkOutputEnv(env:Map[String,String], expectedRC: Int, expected:String, args:String*) = {
49+
def checkOutput(testName:String, args:String, expected:String, env:Map[String,String]=Map.empty, expectedRC: Int=0) = {
5050
val pr = new StringBuilder()
5151
val logger = ProcessLogger((o: String) => pr.append(o+"\n"),(e: String) => pr.append("error < " + e+"\n"))
52-
val cmd = Seq("cmd", "/c", script.getAbsolutePath) ++ args
52+
val cmd = Seq("cmd", "/c", script.getAbsolutePath+" "+args)
5353
val result = Process(cmd, None, env.toSeq:_*) ! logger
5454
if ( result != expectedRC ) {
5555
pr.append("error code: " + result+"\n")
5656
}
5757
val output = crlf2cr(pr.toString)
5858
if(result != expectedRC || output != expected.trim){
59+
fails.append("\n---------------------------------\n")
60+
fails.append(testName)
5961
fails.append("\n---------------------------------\n")
6062
fails.append("Failed to correctly run the main script!.\n")
6163
fails.append("\""+cmd.mkString("\" \"")+"\"\n")
@@ -70,34 +72,60 @@ TaskKey[Unit]("check-script") <<= (stagingDirectory in Universal, name, streams)
7072
fails.append(crlf2cr(pr.toString)+"\n")
7173
fails.append("\n--detail-------------------------------\n")
7274
pr.clear
73-
Process(Seq("cmd", "/c", detailScript.getAbsolutePath) ++ args, None, env.toSeq:_*) ! logger
75+
Process(Seq("cmd", "/c", detailScript.getAbsolutePath+" "+args), None, env.toSeq:_*) ! logger
7476
fails.append(crlf2cr(pr.toString)+"\n")
7577
}
7678
if(debugOutFile.exists){
7779
debugOutFile.delete()
7880
}
7981
}
80-
def checkOutput(expectedRC: Int, expected:String, args:String*) = checkOutputEnv(Map.empty, expectedRC, expected, args:_*)
81-
checkOutput(0, "arg #0 is [OK]\nSUCCESS!", "OK")
82-
checkOutput(0, "arg #0 is [OK]\nproperty(test.hoge) is [huga]\nSUCCESS!", "-Dtest.hoge=\"huga\"", "OK")
83-
checkOutputEnv(Map("show-vmargs"->"true"), 0, "arg #0 is [OK]\nvmarg #0 is [-Xms6m]\nSUCCESS!","-J-Xms6m", "OK")
84-
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!",
85-
"first", "-Dtest.hoge=\"huga\"", "-J-Xms6m", "-XX", "last")
86-
// include space
87-
checkOutput(0, "arg #0 is [C:\\Program Files\\Java]\nproperty(test.hoge) is [C:\\Program Files\\Java]\nSUCCESS!",
88-
"-Dtest.hoge=C:\\Program Files\\Java", "C:\\Program Files\\Java")
89-
// split "include symbols"
90-
checkOutput(0, "property(test.hoge) is [\\[]!< >%]\nSUCCESS!", "\"-Dtest.hoge=\\[]!< >%\"")
91-
checkOutput(0, "arg #0 is [\\[]!< >%]\nSUCCESS!", "\\[]!< >%")
92-
checkOutput(0, "property(test.huga) is [\\[]!<>%]\nSUCCESS!", "-Dtest.huga=\"\\[]!<>%\"")
93-
// include symbols
94-
checkOutput(0, "arg #0 is [\\[]!< >%]\nproperty(test.hoge) is [\\[]!< >%]\nproperty(test.huga) is [\\[]!<>%]\nSUCCESS!",
95-
"\"-Dtest.hoge=\\[]!< >%\"", "\\[]!< >%", "-Dtest.huga=\"\\[]!<>%\"")
96-
// include space and double-quote is failed...
82+
checkOutput("normal argmument",
83+
"OK",
84+
"arg #0 is [OK]\nSUCCESS!")
85+
checkOutput("with -D",
86+
"-Dtest.hoge=\"huga\" OK",
87+
"arg #0 is [OK]\nproperty(test.hoge) is [huga]\nSUCCESS!")
88+
checkOutput("with -J java-opt",
89+
"-J-Xms6m OK",
90+
"arg #0 is [OK]\nvmarg #0 is [-Xms6m]\nSUCCESS!",
91+
Map("show-vmargs"->"true"))
92+
checkOutput("complex",
93+
"first -Dtest.hoge=\"huga\" -J-Xms6m -XX last",
94+
"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!",
95+
Map("show-vmargs"->"true"))
96+
checkOutput("include space",
97+
"""-Dtest.hoge="C:\Program Files\Java" "C:\Program Files\Java" """,
98+
"arg #0 is [C:\\Program Files\\Java]\nproperty(test.hoge) is [C:\\Program Files\\Java]\nSUCCESS!")
99+
checkOutput("include symbols on -D",
100+
"\"-Dtest.hoge=\\[]!< >%\"",
101+
"property(test.hoge) is [\\[]!< >%]\nSUCCESS!")
102+
checkOutput("include symbols on normal args",
103+
""" "\[]!< >%" """,
104+
"arg #0 is [\\[]!< >%]\nSUCCESS!")
105+
checkOutput("include symbols with double quote",
106+
"-Dtest.huga=\"[]!<>%\"",
107+
"property(test.huga) is [[]!<>%]\nSUCCESS!")
108+
checkOutput("include symbols with double quote2",
109+
""" "-Dtest.hoge=\[]!< >%" "\[]!< >%" -Dtest.huga="\[]!<>%" """,
110+
"arg #0 is [\\[]!< >%]\nproperty(test.hoge) is [\\[]!< >%]\nproperty(test.huga) is [\\[]!<>%]\nSUCCESS!")
97111
// 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 ...
98-
//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")
99-
checkOutputEnv(Map("return-code"->"1"), 1, "arg #0 is [RC1]\nFAILURE!", "RC1")
100-
checkOutputEnv(Map("return-code"->"2"), 2, "arg #0 is [RC2]\nFAILURE!", "RC2")
101-
checkOutputEnv(Map("return-code"->"-1"), -1, "arg #0 is [RC-1]\nFAILURE!", "RC-1")
112+
//checkOutput("include space and double-quote",
113+
// "-Dtest.hoge=aa\"bb xx\"yy",
114+
// "arg #0 is [xx\"yy]\nproperty(test.hoge) is [aa\"bb]\nvmarg #0 is [-Dtest.hoge=aa\"bb]\nSUCCESS!")
115+
checkOutput("return-cord not 0",
116+
"RC1",
117+
"arg #0 is [RC1]\nFAILURE!",
118+
Map("return-code"->"1"),
119+
1)
120+
checkOutput("return-cord not 0 and 1",
121+
"RC2",
122+
"arg #0 is [RC2]\nFAILURE!",
123+
Map("return-code"->"2"),
124+
2)
125+
checkOutput("return-code negative",
126+
"RC-1",
127+
"arg #0 is [RC-1]\nFAILURE!",
128+
Map("return-code"->"-1"),
129+
-1)
102130
assert(fails.toString == "", fails.toString)
103131
}

0 commit comments

Comments
 (0)