@@ -18,19 +18,19 @@ class ClasspathTests:
18
18
val packBinDir = " dist/target/pack/bin"
19
19
val packLibDir = " dist/target/pack/lib"
20
20
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
-
27
21
def exists (scriptPath : Path ): Boolean = Files .exists(scriptPath)
28
22
def packBinScalaExists : Boolean = exists(Paths .get(s " $packBinDir/scala " ))
29
23
30
24
/*
31
25
* verify classpath reported by called script.
32
26
*/
33
27
@ 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
+
34
34
val relpath = testScript.toPath.relpath.norm
35
35
printf(" ===> hashbangClasspathVerifyTest for script [%s]\n " , relpath)
36
36
printf(" bash is [%s]\n " , bashExe)
@@ -50,13 +50,41 @@ class ClasspathTests:
50
50
val hashbangClasspathJars = scriptCp.split(psep).map { _.getName }.sorted.distinct
51
51
val packlibJars = listJars(s " $scriptCwd/ $packLibDir" ).sorted.distinct
52
52
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
+
53
56
// verify that the classpath set in the hashbang line is effective
54
57
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 " , " " ))
57
59
58
60
assert(hashbangClasspathJars.size == packlibJars.size)
59
61
}
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
+ }
60
88
61
89
62
90
// ////////////// end of tests ////////////////
0 commit comments