@@ -11,7 +11,10 @@ import org.junit.Test
1111import vulpix .TestConfiguration
1212
1313
14- /** Runs all tests contained in `compiler/test-resources/scripting/` */
14+ /** Verifies correct handling of command line arguments by `dist/bin/scala` and `dist/bin/scalac`.
15+ * +. arguments following a script path must be treated as script arguments
16+ * +. preserve script command line arguments.
17+ */
1518class BashScriptsTests :
1619 // classpath tests managed by scripting.ClasspathTests.scala
1720 def testFiles = scripts(" /scripting" ).filter { ! _.getName.startsWith(" classpath" ) }
@@ -45,9 +48,7 @@ class BashScriptsTests:
4548 val commandline = (Seq (scalacPath, " -script" , showArgsScript) ++ testScriptArgs).mkString(" " )
4649 if bashPath.toFile.exists then
4750 var cmd = Array (bashExe, " -c" , commandline)
48- val output = for {
49- line <- Process (cmd).lazyLines_!
50- } yield line
51+ val output = Process (cmd).lazyLines_!
5152 var fail = false
5253 printf(" \n " )
5354 for (line, expect) <- output zip expectedOutput do
@@ -77,6 +78,20 @@ class BashScriptsTests:
7778 if fail then
7879 assert(output == expectedOutput)
7980
81+ /*
82+ * verify that scriptPath.sc sees a valid script.path property.
83+ */
84+ @ Test def verifyScriptPathProperty =
85+ val scriptFile = testFiles.find(_.getName == " scriptPath.sc" ).get
86+ val expected = s " / ${scriptFile.getName}"
87+ printf(" ===> verify valid system property script.path is reported by script [%s]\n " , scriptFile.getName)
88+ var cmd = Array (bashExe, " -c" , scriptFile.absPath)
89+ val output = Process (cmd).lazyLines_!
90+ output.foreach { printf(" [%s]\n " ,_) }
91+ val valid = output.exists { _.endsWith(expected) }
92+ if valid then printf(" # valid script.path reported by [%s]\n " ,scriptFile.getName)
93+ assert(valid, s " script ${scriptFile.absPath} did not report valid script.path value " )
94+
8095 extension (str : String ) def dropExtension =
8196 str.reverse.dropWhile(_ != '.' ).drop(1 ).reverse
8297
0 commit comments