@@ -7,6 +7,7 @@ import java.nio.file.{Path, Paths, Files}
77import scala .sys .process ._
88
99import org .junit .Test
10+ import org .junit .Assert .assertEquals
1011
1112import vulpix .TestConfiguration
1213
@@ -28,13 +29,13 @@ class BashScriptsTests:
2829 printf(" scalac path: [%s]\n " , scalacPath)
2930
3031 lazy val expectedOutput = List (
31- " arg 0:[a]" ,
32- " arg 1:[b]" ,
33- " arg 2:[c]" ,
34- " arg 3:[-repl]" ,
35- " arg 4:[-run]" ,
36- " arg 5:[-script]" ,
37- " arg 6:[-debug]" ,
32+ " arg 0:[a]" ,
33+ " arg 1:[b]" ,
34+ " arg 2:[c]" ,
35+ " arg 3:[-repl]" ,
36+ " arg 4:[-run]" ,
37+ " arg 5:[-script]" ,
38+ " arg 6:[-debug]" ,
3839 )
3940 lazy val testScriptArgs = Seq (
4041 " a" , " b" , " c" , " -repl" , " -run" , " -script" , " -debug"
@@ -56,6 +57,38 @@ class BashScriptsTests:
5657 if fail then
5758 assert(stdout == expectedOutput)
5859
60+ /* verify `dist/bin/scala` with -J setting */
61+ @ Test def verifyScJProperty =
62+ val commandline = Seq (scalaPath, " -J-Dkey=World" , testFiles.find(_.getName == " envtest.sc" ).get.absPath).mkString(" " )
63+ val (validTest, exitCode, stdout, stderr) = bashCommand(commandline)
64+ assertEquals(stdout.mkString(" /n" ), " Hello World" )
65+
66+ /* verify `dist/bin/scala` with -J setting */
67+ @ Test def verifyScalaJProperty =
68+ val commandline = Seq (scalaPath, " -J-Dkey=World3" , testFiles.find(_.getName == " envtest.scala" ).get.absPath).mkString(" " )
69+ val (validTest, exitCode, stdout, stderr) = bashCommand(commandline)
70+ assertEquals(stdout.mkString(" /n" ), " Hello World3" )
71+
72+ /* verify `dist/bin/scala` with -D setting */
73+ @ Test def verifyScDProperty =
74+ val commandline = Seq (scalaPath, " -Dkey=World3" , testFiles.find(_.getName == " envtest.sc" ).get.absPath).mkString(" " )
75+ val (validTest, exitCode, stdout, stderr) = bashCommand(commandline)
76+ assertEquals(stdout.mkString(" /n" ), " Hello World3" )
77+
78+ /* verify `dist/bin/scala` with -D setting */
79+ @ Test def verifyScalaDProperty =
80+ val commandline = Seq (scalaPath, " -Dkey=World4" , testFiles.find(_.getName == " envtest.scala" ).get.absPath).mkString(" " )
81+ val (validTest, exitCode, stdout, stderr) = bashCommand(commandline)
82+ assertEquals(stdout.mkString(" /n" ), " Hello World4" )
83+
84+ /* verify `dist/bin/scala` with -D setting */
85+ @ Test def saveAndRunWithDProperty =
86+ val commandline = Seq (scalaPath, " -save" , testFiles.find(_.getName == " envtest.scala" ).get.absPath).mkString(" " )
87+ val (_, _, _, _) = bashCommand(commandline)
88+ val commandline2 = Seq (scalaPath, " -Dkey=World5" , testFiles.find(_.getName == " envtest.jar" ).get.absPath).mkString(" " )
89+ val (validTest, exitCode, stdout, stderr) = bashCommand(commandline2)
90+ assertEquals(stdout.mkString(" /n" ), " Hello World5" )
91+
5992 /* verify `dist/bin/scala` non-interference with command line args following script name */
6093 @ Test def verifyScalaArgs =
6194 val commandline = (Seq (" SCALA_OPTS= " , scalaPath, showArgsScript) ++ testScriptArgs).mkString(" " )
@@ -73,7 +106,7 @@ class BashScriptsTests:
73106 assert(stdout == expectedOutput)
74107
75108 /*
76- * verify that scriptPath.sc sees a valid script.path property,
109+ * verify that scriptPath.sc sees a valid script.path property,
77110 * and that it's value is the path to "scriptPath.sc".
78111 */
79112 @ Test def verifyScriptPathProperty =
@@ -192,7 +225,7 @@ class BashScriptsTests:
192225 val envPairs = testEnvPairs ++ additionalEnvPairs
193226 val proc = Process (cmd, None , envPairs * )
194227 val exitVal = proc ! ProcessLogger (
195- (out : String ) => stdout ::= out,
228+ (out : String ) => stdout ::= out,
196229 (err : String ) => stderr ::= err
197230 )
198231 val validTest = exitVal == 0 && ! stderr.exists(_.contains(" Permission denied" ))
0 commit comments