Skip to content

Commit

Permalink
Merge pull request #194 from typelevel/js-warnings
Browse files Browse the repository at this point in the history
Silence JS warnings for CE 2
  • Loading branch information
danicheg authored Mar 5, 2022
2 parents 3fe3e15 + dc5da65 commit 0b75458
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ lazy val ce2 = crossProject(JSPlatform, JVMPlatform)
Test / unmanagedSourceDirectories += baseDirectory.value / "../../common/jvm/src/test/scala"
)
.jsSettings(
libraryDependencies += "org.scala-js" %%% "scala-js-macrotask-executor" % "1.0.0",
Compile / unmanagedSourceDirectories += baseDirectory.value / "../../common/js/src/main/scala",
Test / unmanagedSourceDirectories += baseDirectory.value / "../../common/js/src/test/scala",
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule))
Expand Down
5 changes: 5 additions & 0 deletions ce2/js/src/main/scala/munit/CatsEffectSuitePlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
package munit

import cats.effect.IO
import org.scalajs.macrotaskexecutor.MacrotaskExecutor

import scala.concurrent.ExecutionContext

private[munit] trait CatsEffectSuitePlatform { self: CatsEffectSuite =>

private[munit] def unsafeRunSyncOrForget[A](ioa: IO[A]): Unit = ioa.unsafeRunAsyncAndForget()

private[munit] def suiteExecutionContext: ExecutionContext = MacrotaskExecutor

}
4 changes: 4 additions & 0 deletions ce2/jvm/src/main/scala/munit/CatsEffectSuitePlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ package munit

import cats.effect.IO

import scala.concurrent.ExecutionContext

private[munit] trait CatsEffectSuitePlatform { self: CatsEffectSuite =>

private[munit] def unsafeRunSyncOrForget[A](ioa: IO[A]): Unit = {
ioa.unsafeRunSync()
()
}

private[munit] def suiteExecutionContext: ExecutionContext = ExecutionContext.global

}
6 changes: 4 additions & 2 deletions ce2/shared/src/main/scala/munit/CatsEffectSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ abstract class CatsEffectSuite
with CatsEffectFixtures
with CatsEffectFunFixtures {

private val ec: ExecutionContext = suiteExecutionContext

implicit def munitContextShift: ContextShift[IO] =
IO.contextShift(ExecutionContext.global)
IO.contextShift(ec)

implicit def munitTimer: Timer[IO] =
IO.timer(ExecutionContext.global)
IO.timer(ec)

override def munitValueTransforms: List[ValueTransform] =
super.munitValueTransforms ++ List(munitIOTransform, munitSyncIOTransform)
Expand Down

0 comments on commit 0b75458

Please sign in to comment.