Skip to content
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 #21242: Add REPL flag to quit after evaluating init script #22636

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

noti0na1
Copy link
Member

Fix the remaining part of #21242

Evaluate the init script and skip the interactive mode in REPL.

Test with flag at REPL startup:

> ./bin/scalaQ --repl-init-script 'println("Hello from init script!"); val i = 2 * 2' --repl-eval
[warning] MainGenericRunner class is deprecated since Scala 3.5.0, and Scala CLI features will not work.
[warning] Please be sure to update to the Scala CLI launcher to use the new features.
[warning] Check the Scala 3.5.0 release notes to troubleshoot your installation.
Hello from init script!
val i: Int = 4
>

@Gedochao
Copy link
Contributor

Can we have a test case for this?
Just to verify the output, and that a sub-terminal doesn't get created.
Preferably with dotty.tools.repl.Main, rather than the legacy runner.

@noti0na1
Copy link
Member Author

Can we have a test case for this?

You can test it locally, the process terminates immediately, but I don't know how to create a test to verify that.

@Gedochao
Copy link
Contributor

You can test it locally, the process terminates immediately, but I don't know how to create a test to verify that.

I can see that it works the way it is now, but an automated anti-regression test would go a long way.
I believe it'd be sufficient to call the REPL main method with the --repl-init-script and --repl-eval args, and then verify the output on stdout.

@noti0na1
Copy link
Member Author

Oh, I find this test we may be able to reuse: compiler/test/dotty/tools/scripting/BashExitCodeTests.scala

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants