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

Add repl command with test artifacts on path, corrensponding sbt command Test/console #2953

Closed
bjornregnell opened this issue Jun 5, 2024 · 11 comments · Fixed by #2971
Closed
Assignees
Labels
enhancement New feature or request missing feature Something should have been implemented, but wasn't. REPL Issues tied with the repl sub-command. test command

Comments

@bjornregnell
Copy link
Contributor

Is your feature request related to a problem? Please describe.
My munit test has a bug.

Describe the solution you'd like
I want to debug my munit test in repl using scala-cli.

Describe alternatives you've considered
Use the sbt command Test/console

Additional context
Found nothing about this when reading scala-cli repl --help-full

@bjornregnell bjornregnell added the enhancement New feature or request label Jun 5, 2024
@bjornregnell bjornregnell changed the title Add repl with test artifacts on path, corrensponding sbt command Test/console Add repl command with test artifacts on path, corrensponding sbt command Test/console Jun 5, 2024
@SethTisue
Copy link
Contributor

SethTisue commented Jun 5, 2024

if this is actually supported somehow, I can't find it either in the doc or via experiment (e.g. scala-cli repl --test . is the syntax I would expect and doesn't work)

(and if it isn't supported, it seems like a pretty big hole to me)

@bjornregnell
Copy link
Contributor Author

bjornregnell commented Jun 5, 2024

seems like a pretty big hole to me

I agree. This seems like a feature that should be assigned the "missing feature" label.

@Gedochao Gedochao added test command REPL Issues tied with the repl sub-command. missing feature Something should have been implemented, but wasn't. labels Jun 6, 2024
@Gedochao
Copy link
Contributor

Gedochao commented Jun 6, 2024

(and if it isn't supported, it seems like a pretty big hole to me)

It seems it isn't supported at the moment, so the feature request is valid.
Shouldn't be too hard to deliver (hopefully).

@bjornregnell
Copy link
Contributor Author

bjornregnell commented Jun 6, 2024

I guess users may try this from two angles: 1) they use the test command but want repl and maybe they try scala-cli test . --repl or 2) they use the repl command but want to include test artifacts and maybe they try scala-cli repl . --test or similar.

Perhaps both ways should be supported? Or of only one, I guess 2) is the most natural as it is the repl that is started...

@SethTisue
Copy link
Contributor

SethTisue commented Jun 6, 2024

I agree 2 is more natural (but repl --test ., not repl . --test). I don't see a need to support 1 (and having multiple ways to do things is a cost).

@Gedochao
Copy link
Contributor

Gedochao commented Jun 7, 2024

We already have compile --test, while we don't have test --compile 😅
repl --test is what I plan to go with, I just need to find time to implement it.

@bjornregnell
Copy link
Contributor Author

bjornregnell commented Jun 7, 2024

Great. But with the dot or not for "current dir"? And where to put the dot?

It seems like scala-cli compile . --test accepts the dot both before and after the --test option so scala-cli compile --test . also seems to work.

@Gedochao
Copy link
Contributor

Gedochao commented Jun 7, 2024

But with the dot or not for "current dir"?

. (the dot) is an input, which stands for the current working directory.
Launching repl --test without any inputs would mean you're launching the repl while including the test scope, but the test scope will be empty, since there are no inputs.

TL;DR yeah, the dot is necessary.

And where to put the dot?

As with any other case, . is treated as regular input, which can be passed anywhere after the subcommand name.
You can even pass inputs interchangeably with options, just take care not to pass it as an option argument by accident.
For example, the following is a valid command:

scala-cli repl -S 3.4.2 . --jvm 22

@bjornregnell
Copy link
Contributor Author

Makes sense! Thanks for clarification. Liberal rules, with some gotchas...

@bjornregnell
Copy link
Contributor Author

So if I write scala-cli repl someDir --test does that mean that tests have to be in someDir/src/test/scala or is scala-cli looking at any sub-dir called test for test code? Can I have my test code in a custom location?

@Gedochao
Copy link
Contributor

So if I write scala-cli repl someDir --test does that mean that tests have to be in someDir/src/test/scala or is scala-cli looking at any sub-dir called test for test code? Can I have my test code in a custom location?

It needs to be identified as a test source, as per this doc:
https://scala-cli.virtuslab.org/docs/commands/test#test-sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request missing feature Something should have been implemented, but wasn't. REPL Issues tied with the repl sub-command. test command
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants