@@ -18,19 +18,19 @@ class ClasspathTests:
1818 val packBinDir = " dist/target/pack/bin"
1919 val packLibDir = " dist/target/pack/lib"
2020
21- // only interested in classpath test scripts
22- val testScriptName = " classpathReport.sc"
23- val testScript = scripts(" /scripting" ).find { _.getName.matches(testScriptName) } match
24- case None => sys.error(s " test script not found: ${testScriptName}" )
25- case Some (file) => file
26-
2721 def exists (scriptPath : Path ): Boolean = Files .exists(scriptPath)
2822 def packBinScalaExists : Boolean = exists(Paths .get(s " $packBinDir/scala " ))
2923
3024 /*
3125 * verify classpath reported by called script.
3226 */
3327 @ Test def hashbangClasspathVerifyTest = {
28+ // only interested in classpath test scripts
29+ val testScriptName = " classpathReport.sc"
30+ val testScript = scripts(" /scripting" ).find { _.getName.matches(testScriptName) } match
31+ case None => sys.error(s " test script not found: ${testScriptName}" )
32+ case Some (file) => file
33+
3434 val relpath = testScript.toPath.relpath.norm
3535 printf(" ===> hashbangClasspathVerifyTest for script [%s]\n " , relpath)
3636 printf(" bash is [%s]\n " , bashExe)
@@ -50,13 +50,41 @@ class ClasspathTests:
5050 val hashbangClasspathJars = scriptCp.split(psep).map { _.getName }.sorted.distinct
5151 val packlibJars = listJars(s " $scriptCwd/ $packLibDir" ).sorted.distinct
5252
53+ printf(" %d jar files in dist/target/pack/lib\n " , packlibJars.size)
54+ printf(" %d test script jars in classpath\n " , hashbangClasspathJars.size)
55+
5356 // verify that the classpath set in the hashbang line is effective
5457 if hashbangClasspathJars.size != packlibJars.size then
55- printf(" %d test script jars in classpath\n " , hashbangClasspathJars.size)
56- printf(" %d jar files in dist/target/pack/lib\n " , packlibJars.size)
58+ printf(" hashbangClasspathJars: %s\n " , hashbangClasspathJars.mkString(" \n " , " \n " , " " ))
5759
5860 assert(hashbangClasspathJars.size == packlibJars.size)
5961 }
62+ /*
63+ * verify classpath is unglobbed by MainGenericRunner.
64+ */
65+ @ Test def unglobClasspathVerifyTest = {
66+ val testScriptName = " unglobClasspath.sc"
67+ val testScript = scripts(" /scripting" ).find { _.getName.matches(testScriptName) } match
68+ case None => sys.error(s " test script not found: ${testScriptName}" )
69+ case Some (file) => file
70+
71+ val relpath = testScript.toPath.relpath.norm
72+ printf(" ===> unglobClasspathVerifyTest for script [%s]\n " , relpath)
73+ printf(" bash is [%s]\n " , bashExe)
74+
75+ if packBinScalaExists then
76+ val bashCmdline = s " SCALA_OPTS= $relpath"
77+ val cmd = Array (bashExe, " -c" , bashCmdline)
78+
79+ cmd.foreach { printf(" [%s]\n " , _) }
80+
81+ // test script reports the classpath it sees
82+ val scriptOutput = exec(cmd:_* )
83+ val scriptCp = findTaggedLine(" unglobbed classpath" , scriptOutput)
84+ val classpathJars = scriptCp.split(psep).map { _.getName }.sorted.distinct
85+ // classpathJars.foreach { printf("%s\n", _) }
86+ assert(classpathJars.size > 1 )
87+ }
6088
6189
6290// ////////////// end of tests ////////////////
0 commit comments