-
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
Runner sets residual args instead of append #14543
Conversation
Here is an example of how to call the |
Would you mind opening a backport of this fix to the release-3.1.2 branch too? |
c92d0d6
to
b9ec198
Compare
The test doesn't help, and Meanwhile, I'll learn how to backport to the release branch. |
You can add shell script unit tests to https://github.com/lampepfl/dotty/blob/main/project/scripts/cmdTests |
Oh but cmdTests uses sbt scalac, I don't know what's the best place to test the output of the actual scalac shell script /cc @BarkingBad |
If I got you correctly, you are looking for these tests https://github.com/lampepfl/dotty/tree/main/compiler/test/dotty/tools/scripting |
Adding the following test in project/scripts/cmdTests does the appropriate test. Not sure if that is the place to use echo "testing bin/scala call to main"
clear_out "$OUT"
bin/scalac tests/run-with-compiler/i14541.scala
bin/scala echo hello world > "$tmp"
# cat "$tmp" # for debugging
grep -e "^hello world$" "$tmp" |
b9ec198
to
2cc3070
Compare
Before
After
|
12 years ago
The scala 2 script uses env var to set the default for the
At the command line, I'd expect to get a useful class path for free. But I haven't looked to see what assumptions or expectations are built into |
import dotty.tools.runner.RichClassLoader._ | ||
val newClassLoader = ScalaClassLoader.fromURLsParallelCapable(newClasspath) | ||
import dotty.tools.runner.RichClassLoader.{getClass as _, *} | ||
val newClassLoader = ScalaClassLoader.fromURLsParallelCapable(newClasspath, getClass.getClassLoader) |
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.
This change does not seem to be needed to make tests/run-with-compiler/i14541.scala
pass. Why was this added? How could I test this?
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.
This is the 2nd commit about whether to do -usejavacp
behavior from Scala 2, i.e., use the class loader you were given. I'm doubtful both ways.
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.
Oh, it's necessary for the 2nd test where it doesn't supply a class path arg to MainGenericRunner.
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.
If that is the case, I would remove this change and the second test. The third test already covers the fix. We could have a look at this cp change in a separate PR as we don't know or have time to test unintended consequences of this change. I would prefer to only fix the regression in this PR as this fill be back ported. We also want the backport quickly to be able to release 3.1.2 as soon as possible.
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.
@nicolasstucki
PR #14559 is another backport candidate for release-3.1.2
. Can you vote for it please (no one did react till now) ?!
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.
@som-snytt we also have a -usejavacp flag checked in some of our she'll scripts I believe, shouldn't we check it here too?
tests/run-with-compiler/i14541.scala
Outdated
val classpath = dotty.tools.dotc.util.ClasspathFromClassloader(getClass.getClassLoader) | ||
def main(args: Array[String]): Unit = | ||
getClass.getClassLoader.run("echo", List("hello", "raw", "world")) | ||
getClass.getClassLoader.run("dotty.tools.MainGenericRunner", List("echo", "hello", "rawr", "world")) |
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.
This call works after using "parent class loader" in Runner. Folks with an opinion about how the command line runner should behave might have an opinion.
Dropped the speculative commit and squashed. (Can return to usejavacp usage later, or let scala-cli explore that space.) Thanks, for future contributions I'll be more disciplined about minimized and easy-to-review deltas. |
Fixes #14541
Quick tweak requires proper test.
Backported #14552