-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix scala runner exit codes #15604
Fix scala runner exit codes #15604
Conversation
…p file creation for expression for better error messages
…ompile by other scripting tests
I'll delete this additional file after fixes in code review to not rerun tests again. touchedFile.out |
…rom ScriptingTests
@@ -146,6 +146,8 @@ class ScriptingTests: | |||
if touchedFile.exists then | |||
printf("success: executable jar created file %s\n", touchedFile) | |||
assert( touchedFile.exists, s"expected to find file ${touchedFile}" ) | |||
touchedFile.delete | |||
assert( !touchedFile.exists, s"unable to delete ${touchedFile}" ) |
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.
I found that touchedFile.out was a leftover from this test. Now it should be deleted properly.
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.
minor point but it would be nice if for ExecuteMode.Expression
the StringDriver.compileAndRun
was escaped for the StringDriverException
to just print the message, like what happens for ScriptingException
.
Currently we get a stack trace for compilation errors in the -e
mode:
~/workspace/scripts » ../dotty/dist/target/pack/bin/scala -e 'prinln(2)' || echo "fail"
-- [E006] Not Found Error: expression:2:2 --------------------------------------
2 | prinln(2)
| ^^^^^^
| Not found: prinln
|
| longer explanation available when compiling with `-explain`
dotty.tools.scripting.StringDriverException: Errors encountered during compilation
at dotty.tools.scripting.StringDriverException$.apply(StringDriver.scala:52)
at dotty.tools.scripting.StringDriver.compileAndRun(StringDriver.scala:31)
at dotty.tools.MainGenericRunner$.run$1(MainGenericRunner.scala:261)
at dotty.tools.MainGenericRunner$.process(MainGenericRunner.scala:271)
at dotty.tools.MainGenericRunner$.main(MainGenericRunner.scala:281)
at dotty.tools.MainGenericRunner.main(MainGenericRunner.scala)
fail
Ideally it would just be
~/workspace/scripts » ../dotty/dist/target/pack/bin/scala -e 'prinln(2)' || echo "fail"
-- [E006] Not Found Error: expression:2:2 --------------------------------------
2 | prinln(2)
| ^^^^^^
| Not found: prinln
|
| longer explanation available when compiling with `-explain`
Errors encountered during compilation
fail
Yeah, my mistake, and while we're at expression flag. In scala 2 |
I would say no: - I don't think its a big deal because its internal details, but could also cause confusion with other modes, such as |
Adoption of scala2 exit code implementation. Fixes #15022
Now main runner returns proper status code when it fails during runtime.
Also tried to cleanup this class a bit.
I added tests for all combinations of MainGenericCompiler / Runner that I could think of and found that
-print-tasty
flag was returning wrong exit codes despite errors. I didn't know it that's the best place to put them but i think they count asscripting
tests.The last change that I've made is improving error messages for scala expressions (
-e
). Before it created virtual files fromcompileFromStrings
even though we explicitly passed one source. It lead to very high horizontal length of stack trace making it less clear as those files hadUUID
in their name. It now creates single file to make it shorter.