@@ -18,7 +18,7 @@ class ClasspathTests:
18
18
str.reverse.dropWhile(_ != '.' ).drop(1 ).reverse
19
19
20
20
extension(f : File ) def absPath =
21
- f.getAbsolutePath.replace('\\ ' ,'/' )
21
+ f.getAbsolutePath.replace('\\ ' , '/' )
22
22
23
23
// only interested in classpath test scripts
24
24
def testFiles = scripts(" /scripting" ).filter { _.getName.matches(" classpath.*[.]sc" ) }
@@ -36,21 +36,21 @@ class ClasspathTests:
36
36
*/
37
37
@ Test def scalacEchoTest =
38
38
val relpath = testScript.toPath.relpath.norm
39
- printf(" ===> scalacEchoTest for script [%s]\n " ,relpath)
40
- printf(" bash is [%s]\n " ,bashExe)
39
+ printf(" ===> scalacEchoTest for script [%s]\n " , relpath)
40
+ printf(" bash is [%s]\n " , bashExe)
41
41
42
42
if packBinScalaExists then
43
43
val echoTest = " SCALAC_ECHO_TEST=1"
44
44
val bashCmdline = s " SCALA_OPTS= $echoTest dist/target/pack/bin/scala -classpath ' $wildcardEntry' $relpath"
45
45
46
46
// ask [dist/bin/scalac] to echo generated command line so we can verify some things
47
- val cmd = Array (bashExe," -c" ,bashCmdline)
47
+ val cmd = Array (bashExe, " -c" , bashCmdline)
48
48
49
- // cmd.foreach { printf("[%s]\n",_) }
49
+ // cmd.foreach { printf("[%s]\n", _) }
50
50
51
51
val javaCommandLine = exec(cmd:_* ).mkString(" " ).split(" " ).filter { _.trim.nonEmpty }
52
- printf(" \n ==================== isWin[%s], cygwin[%s], mingw[%s], msys[%s]\n " ,isWin,cygwin,mingw,msys)
53
- javaCommandLine.foreach { printf(" java-command[%s]\n " ,_) }
52
+ printf(" \n ==================== isWin[%s], cygwin[%s], mingw[%s], msys[%s]\n " , isWin, cygwin, mingw, msys)
53
+ javaCommandLine.foreach { printf(" java-command[%s]\n " , _) }
54
54
55
55
val output = scala.collection.mutable.Queue (javaCommandLine:_* )
56
56
output.dequeueWhile( _ != " dotty.tools.scripting.Main" )
@@ -63,54 +63,54 @@ class ClasspathTests:
63
63
64
64
// display command line starting with "dotty.tools.scripting.Main"
65
65
output.foreach { line =>
66
- printf(" %s\n " ,line)
66
+ printf(" %s\n " , line)
67
67
}
68
68
69
69
// expecting -classpath next
70
- assert(consumeNext.replaceAll(" '" ," " ) == " -classpath" )
70
+ assert(consumeNext.replaceAll(" '" , " " ) == " -classpath" )
71
71
72
72
// 2nd arg to scripting.Main is 'lib/*', with semicolon added if Windows jdk
73
73
74
74
// PR #10761: verify that [dist/bin/scala] -classpath processing adds $psep to wildcard if Windows
75
75
val classpathValue = consumeNext
76
- printf(" classpath value [%s]\n " ,classpathValue)
76
+ printf(" classpath value [%s]\n " , classpathValue)
77
77
assert( ! winshell || classpathValue.contains(psep) )
78
78
79
79
// expecting -script next
80
- assert(consumeNext.replaceAll(" '" ," " ) == " -script" )
80
+ assert(consumeNext.replaceAll(" '" , " " ) == " -script" )
81
81
82
82
// PR #10761: verify that Windows jdk did not expand single wildcard classpath to multiple file paths
83
83
if javaCommandLine.last != relpath then
84
- printf(" last: %s\n relp: %s\n " ,javaCommandLine.last,relpath)
85
- assert(javaCommandLine.last == relpath,s " unexpected output passed to scripting.Main " )
84
+ printf(" last: %s\n relp: %s\n " , javaCommandLine.last, relpath)
85
+ assert(javaCommandLine.last == relpath, s " unexpected output passed to scripting.Main " )
86
86
87
87
/*
88
88
* verify classpath reported by called script.
89
89
*/
90
90
@ Test def hashbangClasspathVerifyTest =
91
91
val relpath = testScript.toPath.relpath.norm
92
- printf(" ===> hashbangClasspathVerifyTest for script [%s]\n " ,relpath)
93
- printf(" bash is [%s]\n " ,bashExe)
92
+ printf(" ===> hashbangClasspathVerifyTest for script [%s]\n " , relpath)
93
+ printf(" bash is [%s]\n " , bashExe)
94
94
95
95
if false && packBinScalaExists then
96
96
val bashCmdline = s " SCALA_OPTS= $relpath"
97
- val cmd = Array (bashExe," -c" ,bashCmdline)
97
+ val cmd = Array (bashExe, " -c" , bashCmdline)
98
98
99
- cmd.foreach { printf(" [%s]\n " ,_) }
99
+ cmd.foreach { printf(" [%s]\n " , _) }
100
100
101
101
// test script reports the classpath it sees
102
102
val scriptOutput = exec(cmd:_* )
103
- val scriptCwd = findTaggedLine(" cwd" ,scriptOutput)
104
- printf(" script ran in directory [%s]\n " ,scriptCwd)
105
- val scriptCp = findTaggedLine(" classpath" ,scriptOutput)
103
+ val scriptCwd = findTaggedLine(" cwd" , scriptOutput)
104
+ printf(" script ran in directory [%s]\n " , scriptCwd)
105
+ val scriptCp = findTaggedLine(" classpath" , scriptOutput)
106
106
107
107
val hashbangClasspathJars = scriptCp.split(psep).map { _.getName }.sorted.distinct
108
108
val packlibJars = listJars(s " $scriptCwd/dist/target/pack/lib " ).sorted.distinct
109
109
110
110
// verify that the classpath set in the hashbang line is effective
111
111
if hashbangClasspathJars.size != packlibJars.size then
112
- printf(" %d test script jars in classpath\n " ,hashbangClasspathJars.size)
113
- printf(" %d jar files in dist/target/pack/lib\n " ,packlibJars.size)
112
+ printf(" %d test script jars in classpath\n " , hashbangClasspathJars.size)
113
+ printf(" %d jar files in dist/target/pack/lib\n " , packlibJars.size)
114
114
115
115
assert(hashbangClasspathJars.size == packlibJars.size)
116
116
@@ -127,7 +127,7 @@ def listJars(dir: String) =
127
127
Nil
128
128
129
129
import scala .jdk .CollectionConverters ._
130
- lazy val env : Map [String ,String ] = System .getenv.asScala.toMap
130
+ lazy val env : Map [String , String ] = System .getenv.asScala.toMap
131
131
132
132
// script output expected as "<tag>: <value>"
133
133
def findTaggedLine (tag : String , lines : Seq [String ]): String =
@@ -161,7 +161,7 @@ def which(str:String) =
161
161
162
162
def bashExe = which(" bash" )
163
163
def unameExe = which(" uname" )
164
- def path = envOrElse(" PATH" ," " ).split(psep).toList
164
+ def path = envOrElse(" PATH" , " " ).split(psep).toList
165
165
def psep = sys.props(" path.separator" )
166
166
167
167
def cygwin = ostype == " cygwin"
@@ -174,10 +174,10 @@ def ostype = ostypeFull.toLowerCase.takeWhile{ cc => cc >= 'a' && cc <='z' || cc
174
174
175
175
extension(p: Path )
176
176
def relpath : Path = cwd.relativize(p)
177
- def norm : String = p.toString.replace('\\ ' ,'/' )
177
+ def norm : String = p.toString.replace('\\ ' , '/' )
178
178
179
179
extension(path : String )
180
- def getName : String = norm.replaceAll(" .*/" ," " )
180
+ def getName : String = norm.replaceAll(" .*/" , " " )
181
181
182
182
// Normalize path separator, convert relative path to absolute
183
183
def norm : String =
@@ -187,12 +187,12 @@ extension(path: String)
187
187
case s => s
188
188
}
189
189
190
- def parent : String = norm.replaceAll(" /[^/]*$" ," " )
190
+ def parent : String = norm.replaceAll(" /[^/]*$" , " " )
191
191
192
192
// convert to absolute path relative to cwd.
193
193
def absPath : String = norm match
194
194
case str if str.isAbsolute => norm
195
- case _ => Paths .get(userDir,norm).toString.norm
195
+ case _ => Paths .get(userDir, norm).toString.norm
196
196
197
197
def isDir : Boolean = Files .isDirectory(Paths .get(path))
198
198
0 commit comments