-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix ExpressionTest#verifyImports test compile error introduced in #14263 #14358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First 2 remarks about the code in ExpressionTest.scala
:
- On line 30, the '
s
' prefix is not need in front of the triple quoted string. - On line 39, the variable
cmd
is unused.
Then 2 questions about the usage of bashCommand
in ExpressionTest.scala
:
- In file
BashScriptTests.scala
bashCommand
makes use ofScriptTestEnv.scalaPath
; why not use the same mechanism here ?
E.g.,val (_, _, stdout, stderr) = bashCommand(s"""$scalaPath -e '$expression'""")
. - In variable
expressionLines
(line 28) I readPaths.get("\""."\"")
; for me the code only works if I writePaths.get("\"."\")
(see console output below). Did you check the console output starting withbashCmd
?
Finally, adding assert(success)
(line 36) is good !
PS. Here is the output I get with my local copy of file ExpressionTest.scala
(Win11 Pro, Scala 3.1.0):
Y:\dotty>"%SCALA3_HOME%\bin\scalac" -cp "%REPO_DIR%\junit\junit\4.13.2\junit-4.13.2.jar;compiler\target\scala-3.1.2-RC1\test-classes" compiler\test\dotty\tools\scripting\ExpressionTest.scala -d c:\temp\
Y:\dotty>"%SCALA3_HOME%\bin\scala" -cp "%REPO_DIR%\junit\junit\4.13.2\junit-4.13.2.jar;c:\temp;compiler\target\scala-3.1.2-RC1\classes;compiler\target\scala-3.1.2-RC1\test-classes" dotty.tools.scripting.ExpressionTest
working directory is [Y:/dotty]
=== verifyCommandLineExpression ===
===> verify -e <expression> is properly handled by `dist/bin/scala`
bashCmd: C:/windows/system32/bash.exe -c "/mnt/c/Users/michelou/workspace-perso/dotty-examples/dotty/dist/target/pack/bin/scala -e 'println(3*3)'"
scalacPath: Y:/dotty/dist/target/pack/bin/scalac
JAVA_HOME : C:\opt\jdk-temurin-1.8.0u322-b06
SCALA_HOME : Y:/dotty/dist/target/pack
PATH : dist/target/pack/bin;C:/opt/jdk-temurin-1.8.0u322-b06/bin;[...]
SHELLOPTS : igncr:braceexpand:hashall:ignoreeof:monitor:vi
stdout: 9
stderr:
=== verifyImports ===
bashCmd: C:/windows/system32/bash.exe -c "/mnt/c/Users/michelou/workspace-perso/dotty-examples/dotty/dist/target/pack/bin/scala -e 'import java.nio.file.Paths;println(Paths.get("\"."\").toFile.listFiles.toList.filter(_.isDirectory).size)'"
stdout: 19
stderr:
Note: I appended the following code to file ExpressionTest.scala
to get the above output :
object ExpressionTest:
def main(args: Array[String]): Unit =
val tests = new ExpressionTest
println("\n=== verifyCommandLineExpression ===")
tests.verifyCommandLineExpression
println("\n=== verifyImports ===")
tests.verifyImports
@philwalk 3 more suggestions for file
Otherwise, LGTM. |
@michelou - thanks for the detailed feedback, that helps! It turns out that changing the bash command to I just noticed the code still has a residual unused ' |
I'll do another push with all suggested changes after the workflow dies down a bit later this evening. |
👍 |
@michelou - object ExpressionTest:
def main(args: Array[String]): Unit =
val tests = new ExpressionTest
println("\n=== verifyCommandLineExpression ===")
tests.verifyCommandLineExpression
println("\n=== verifyImports ===")
tests.verifyImports |
It's a small (local) addition I also have in |
The -e (eval) expression in dotty.tools.scripting.ExpressionTest#verifyImports fails to compile, but the test passes anyway because of a missing assertion.
This PR corrects the expression so that it compiles, and it asserts that the expression must print an integer to
STDOUT
, so that the test will fail if the-e <expression>
implementation fails.The compile error is mentioned in #14332