From e2d5bd71f932de5e912c6e7a4b5de5921bba80b7 Mon Sep 17 00:00:00 2001 From: Nepomuk Seiler Date: Mon, 23 Feb 2015 10:33:09 +0100 Subject: [PATCH 1/3] FIX #502 Removing JAVA_OPTS --- appveyor.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 4adb9603a..6b4d8503f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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 From 161f8794cd1f41e6bde1bcb8301d1d071a79d1e5 Mon Sep 17 00:00:00 2001 From: Nepomuk Seiler Date: Tue, 24 Feb 2015 15:31:32 +0100 Subject: [PATCH 2/3] Removing error code. See git miss explanation in #502 --- .../resources/com/typesafe/sbt/packager/archetypes/bat-template | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/resources/com/typesafe/sbt/packager/archetypes/bat-template b/src/main/resources/com/typesafe/sbt/packager/archetypes/bat-template index c71ebf68c..0d90debf5 100644 --- a/src/main/resources/com/typesafe/sbt/packager/archetypes/bat-template +++ b/src/main/resources/com/typesafe/sbt/packager/archetypes/bat-template @@ -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 From 0bd8d8ae1f04e241202d3809a2229f3f41ae6123 Mon Sep 17 00:00:00 2001 From: nazoking Date: Wed, 25 Feb 2015 15:07:28 +0900 Subject: [PATCH 3/3] fix test for jdk1.7.0_25, jdk1.8.0_20 --- .../windows/test-bat-template/build.sbt | 78 +++++++++++++------ 1 file changed, 53 insertions(+), 25 deletions(-) diff --git a/src/sbt-test/windows/test-bat-template/build.sbt b/src/sbt-test/windows/test-bat-template/build.sbt index 70808e645..0366d516a 100644 --- a/src/sbt-test/windows/test-bat-template/build.sbt +++ b/src/sbt-test/windows/test-bat-template/build.sbt @@ -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") @@ -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) }