bloop
bloop copied to clipboard
Passing arguments from CLI to Scalatest runner does not work
CLI runner arguments are not passed to Scalatest. Previously reported (and not fixed) in #1288.
$ bloop test root --only MySpec -- -Dkey=value
MySpec:
configMap=Map()
It works perfectly fine with sbt:
$ sbt "root/testOnly MySpec -- -Dkey=value"
[info] compiling ...
MySpec:
configMap=Map(key -> value)
Tried and not worked:
- The
--argsflag and/or variations of quotations - bloop "1.4.8" and "v1.4.8-19-4d9f966b"
- JDK 8 and 11
bloop test xyz -- -J-Dkey=value
Thanks for reporting! I will try to take a look at it at some point unless anyone else is able to take a look :s
Faced the same problem today.
I confirmed the issue is still in bloop 1.4.12
What did you try? Just checked it and it seems to work with:
bloop test root-test -o CubeCalculatorTest -- -J-Dhello=1
in the scalatest example project.
I confirmed the -- -J-Dkey=value does not work. See https://github.com/davidmlw/bloop-test/runs/5168231480
I create a basic scala project and sbt passes but bloop not.
That's actually weird, the process does have it set /usr/lib/jvm/temurin-11-jdk-amd64/bin/java -Dkey=Hello -Duser.dir=/home/runner/work/bloop-test/bloop-test
Does it work if you do sys.env.get("key") ?
It did work for me in that case, though I am not familiar with ConfigMap and I am not sure when it should be populated.
See this run https://github.com/davidmlw/bloop-test/runs/5183749554
Bloop test passes the property -J-Dkey=Hello to java process, but not to scala test configMap. Sbt test passes the -Dkey=Hello to scala test configMap but not to java process. In the bloop test, the key value is found in System.getProperty("key"). In the sbt test, the 'key' is not found, nor the user.key, but 'user.dir' is found.
bloop test foo -o FooTester -- -Dkey=Hello -J-Duser.key=helllllo
sbt 'testOnly FooTester -- -Dkey=hello -Duser.key=helllllo'
println(s"java version: ${System.getProperty("java.version")}")
println(s"runtime version: ${System.getProperty("java.runtime.version")}")
println(s"user.dir: ${System.getProperty("user.dir")}")
println(s"user.key: ${System.getProperty("user.key")}")
println(s"key: ${System.getProperty("key")}")
println(s"env user.dir: ${sys.env.get("user.dir")}")
println(s"env key: ${sys.env.get("key")}")
This run was passed with -Dkey=Hello -J-Dkey=Hello, one for test framework, one for JVM.
https://github.com/davidmlw/bloop-test/runs/5186157948#step:6:138
[D] Running test suites with arguments: List()
The log shows the test framework didn't receive the -Dkey=Hello.
https://github.com/scalacenter/bloop/blob/81973d639aac92360c3a98043d335d4a39fc834f/frontend/src/main/scala/bloop/engine/tasks/TestTask.scala#L89-L91
it seems that frameworkArgs were not properly passed
This line has not been exectuted https://github.com/scalacenter/bloop/blob/81973d639aac92360c3a98043d335d4a39fc834f/frontend/src/main/scala/bloop/engine/tasks/TestTask.scala#L228 The options is not Nil and we found just one framework, the line should be printed, but it was not.
We might need to forward the jvm parameters to the test framework one then. Thanks for investigating!
I confirmed the issue is still in bloop 1.5.0, as shown here https://github.com/davidmlw/bloop-test/runs/6372828263
I have the same issue for bloop 1.5.11. If anybody knows a workaround please let me know 😇