Port asynchronous test adapter code from Scala.js
The current test infrastructure doesn't work with asynchronous code.
Tests frameworks work around this problem by forcing the execution of the scala.scalanative.runtime.loop() before awaiting the futures. This is not needed in Scala.js since all the test infrastructure code is asynchronous.
This PR ports that code to Scala Native as well.
I tested with utest and you can now have asynchronous tests that behave exactly as with Scala.js.
For example, returning a future that doesn't complete hangs as with Scala.js instead of failing instantaneously.
import utest._
import scala.concurrent._
object MyTest extends TestSuite {
val tests = Tests {
test("doesn't complete") {
val p = Promise[Int]()
p.future
}
}
}
Very cool. If you could put the Date and SHA like this that would be super - https://github.com/scala-native/scala-native/blob/main/javalib/src/main/scala/java/util/AbstractMap.scala#L1-L11
@ekrich This wasn't a complete copy-paste but I adapted the code to work with the existing code. Does the Scala.js port commit still apply? By the way, I'm making this PR ready for review even if some comments need to be updated, because I don't know exactly what to write.
@lolgab this is awesome!! So IIUC, we should be able to remove the loop() from the JUnit integration?
https://github.com/scala-native/scala-native/blob/5924b310ae516baf7ca7326d0f2329e4726799be/junit-async/native/src/main/scala/scala/scalanative/junit/async/package.scala#L1-L11
As decided in the review, the PR does not bring any reasonable improvements, since it still require to manually run scalanativ e loop. Closing.