@@ -11,7 +11,10 @@ import org.junit.Test
11
11
import vulpix .TestConfiguration
12
12
13
13
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
+ */
15
18
class BashScriptsTests :
16
19
// classpath tests managed by scripting.ClasspathTests.scala
17
20
def testFiles = scripts(" /scripting" ).filter { ! _.getName.startsWith(" classpath" ) }
@@ -45,9 +48,7 @@ class BashScriptsTests:
45
48
val commandline = (Seq (scalacPath, " -script" , showArgsScript) ++ testScriptArgs).mkString(" " )
46
49
if bashPath.toFile.exists then
47
50
var cmd = Array (bashExe, " -c" , commandline)
48
- val output = for {
49
- line <- Process (cmd).lazyLines_!
50
- } yield line
51
+ val output = Process (cmd).lazyLines_!
51
52
var fail = false
52
53
printf(" \n " )
53
54
for (line, expect) <- output zip expectedOutput do
@@ -77,6 +78,20 @@ class BashScriptsTests:
77
78
if fail then
78
79
assert(output == expectedOutput)
79
80
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
+
80
95
extension (str : String ) def dropExtension =
81
96
str.reverse.dropWhile(_ != '.' ).drop(1 ).reverse
82
97
0 commit comments