Skip to content

Commit 5f378a2

Browse files
committed
remove unused code; eliminate quotes in eval expression
1 parent 8756d2c commit 5f378a2

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

compiler/test/dotty/tools/scripting/ExpressionTest.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ class ExpressionTest:
2525
assert(result.contains(expected), s"expression [$expression] did not send [$expected] to stdout")
2626

2727
@Test def verifyImports: Unit =
28+
2829
val expressionLines = List(
2930
"import java.nio.file.Paths",
30-
s"""println(Paths.get("\""."\"").toFile.listFiles.toList.filter(_.isDirectory).size)""",
31+
"import dotty.tools.dotc.config.Properties.userDir",
32+
s"""println(Paths.get(userDir).toFile.listFiles.toList.filter(_.isDirectory).size)""",
3133
)
3234
val expression = expressionLines.mkString(";")
3335
val success = testExpression(expression){ result =>
@@ -36,8 +38,7 @@ class ExpressionTest:
3638
assert(success)
3739

3840
def getResult(expression: String): String =
39-
val cmd = s"bin/scala -e $expression"
40-
val (_, _, stdout, stderr) = bashCommand(s"""bin/scala -e '$expression'""")
41+
val (_, _, stdout, stderr) = bashCommand(s"$scalaPath -e '$expression'")
4142
printf("stdout: %s\n", stdout.mkString("|"))
4243
printf("stderr: %s\n", stderr.mkString("\n","\n",""))
4344
stdout.filter(_.nonEmpty).mkString("")

compiler/test/dotty/tools/scripting/ScriptTestEnv.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ object ScriptTestEnv {
2121
def psep: String = sys.props("path.separator")
2222
def userDir: String = sys.props("user.dir").norm
2323
def testCwd = envOrElse("TEST_CWD", "").norm // optional working directory TEST_CWD
24+
def verbose = envOrElse("VERBOSE", "").nonEmpty
2425

2526
def whichJava: String = whichExe("java")
2627
def whichBash: String = whichExe("bash")
2728

2829
lazy val workingDirectory: String = {
2930
val dirstr = if testCwd.nonEmpty then
30-
printf("TEST_CWD set to [%s]\n", testCwd)
31+
if verbose then printf("TEST_CWD set to [%s]\n", testCwd)
3132
testCwd
3233
else
3334
userDir // userDir, if TEST_CWD not set
@@ -37,7 +38,7 @@ object ScriptTestEnv {
3738
if !test.isDirectory then
3839
printf("warning: not found below working directory: %s\n", test.norm)
3940

40-
printf("working directory is [%s]\n", dirstr)
41+
if verbose then printf("working directory is [%s]\n", dirstr)
4142
dirstr
4243
}
4344

@@ -106,7 +107,7 @@ object ScriptTestEnv {
106107
// a misconfigured environment (e.g., script is not executable) can prevent script execution
107108
val validTest = !stderr.exists(_.contains("Permission denied"))
108109
if ! validTest then
109-
printf("\nunable to execute script, return value is %d\n", exitVal)
110+
System.err.printf("\nunable to execute script, return value is %d\n", exitVal)
110111
stderr.foreach { System.err.printf("stderr [%s]\n", _) }
111112

112113
(validTest, exitVal, stdout.reverse, stderr.reverse)
@@ -275,8 +276,7 @@ object ScriptTestEnv {
275276
("MSYS", msyshome),
276277
("SHELLOPTS", shellopts),
277278
).filter { case (name, valu) => valu.nonEmpty }
278-
for (k, v) <- pairs do
279-
printf("%s : %s\n", k ,v)
279+
if verbose then for (k, v) <- pairs do printf("%s : %s\n", k ,v)
280280
pairs
281281
}
282282

0 commit comments

Comments
 (0)