-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #700 from armanbilge/issue/695
Move `scalanative.runtime.loop()` invocation to correct place
- Loading branch information
Showing
7 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
munit/native/src/main/scala/munit/internal/junitinterface/JUnitTask.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Adapted from https://github.com/scala-js/scala-js, see NOTICE.md. | ||
*/ | ||
|
||
package munit.internal.junitinterface | ||
|
||
import munit.internal.PlatformCompat | ||
import org.junit.runner.notification.RunNotifier | ||
import sbt.testing._ | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
|
||
/* Implementation note: In JUnitTask we use Future[Try[Unit]] instead of simply | ||
* Future[Unit]. This is to prevent Scala's Future implementation to box/wrap | ||
* fatal errors (most importantly AssertionError) in ExecutionExceptions. We | ||
* need to prevent the wrapping in order to hide the fact that we use async | ||
* under the hood and stay consistent with JVM JUnit. | ||
*/ | ||
final class JUnitTask( | ||
_taskDef: TaskDef, | ||
runSettings: RunSettings, | ||
classLoader: ClassLoader | ||
) extends Task { | ||
|
||
override def taskDef(): TaskDef = _taskDef | ||
override def tags(): Array[String] = Array.empty | ||
|
||
def execute( | ||
eventHandler: EventHandler, | ||
loggers: Array[Logger] | ||
): Array[Task] = { | ||
PlatformCompat.newRunner(taskDef(), classLoader) match { | ||
case None => | ||
case Some(runner) => | ||
runner.filter(runSettings.tags) | ||
val reporter = | ||
new JUnitReporter(eventHandler, loggers, runSettings, taskDef()) | ||
val notifier: RunNotifier = new MUnitRunNotifier(reporter) | ||
runner.run(notifier) | ||
} | ||
Array() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package munit | ||
|
||
import scala.concurrent._ | ||
|
||
class Issue695Suite extends FunSuite { | ||
override def munitExecutionContext = ExecutionContext.global | ||
|
||
test("await task on global EC") { | ||
val p = Promise[Unit]() | ||
ExecutionContext.global.execute { () => | ||
Thread.sleep(1000) | ||
p.success(()) | ||
} | ||
p.future | ||
} | ||
|
||
} |