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

Use portable-scala-reflect instead of the deprecated TestUtils. #178

Merged
merged 1 commit into from
Sep 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ lazy val utest = crossProject(JSPlatform, JVMPlatform, NativePlatform)

)
.jsSettings(
libraryDependencies += "org.scala-js" %% "scalajs-test-interface" % scalaJSVersion
libraryDependencies ++= Seq(
"org.scala-js" %% "scalajs-test-interface" % scalaJSVersion,
"org.portable-scala" %%% "portable-scala-reflect" % "0.1.0"
)
)
.jvmSettings(
libraryDependencies ++= Seq(
"org.scala-sbt" % "test-interface" % "1.0",
"org.scala-js" %% "scalajs-stubs" % scalaJSVersion % "provided"
"org.portable-scala" %%% "portable-scala-reflect" % "0.1.0"
),
resolvers += Resolver.sonatypeRepo("snapshots")
)
Expand Down
11 changes: 11 additions & 0 deletions utest/js/src/main/scala/utest/PlatformShims.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package utest

import scala.concurrent.Future
import org.portablescala.reflect.Reflect

/**
* Platform specific stuff that differs between JVM and JS
Expand All @@ -14,4 +15,14 @@ object PlatformShims {
)
}
}

type EnableReflectiveInstantiation =
org.portablescala.reflect.annotation.EnableReflectiveInstantiation

def loadModule(name: String, loader: ClassLoader): Any = {
Reflect
.lookupLoadableModuleClass(name + "$", loader)
.getOrElse(throw new ClassNotFoundException(name))
.loadModule()
}
}
13 changes: 11 additions & 2 deletions utest/jvm/src/main/scala/utest/PlatformShims.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package utest

import scala.concurrent.{Await, Future}
import scala.util.{Failure, Success}
import concurrent.duration._
import java.io.{PrintWriter, StringWriter}
import org.portablescala.reflect.Reflect

/**
* Platform specific stuff that differs between JVM and JS
*/
object PlatformShims {
def await[T](f: Future[T]): T = Await.result(f, 10.hours)

type EnableReflectiveInstantiation =
org.portablescala.reflect.annotation.EnableReflectiveInstantiation

def loadModule(name: String, loader: ClassLoader): Any = {
Reflect
.lookupLoadableModuleClass(name + "$", loader)
.getOrElse(throw new ClassNotFoundException(name))
.loadModule()
}
}
7 changes: 7 additions & 0 deletions utest/native/src/main/scala/utest/PlatformShims.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package utest
// Taken from the implementation for JS

import scala.concurrent.Future
import org.scalajs.testinterface.TestUtils

/**
* Platform specific stuff that differs between JVM and Native
Expand All @@ -16,4 +17,10 @@ object PlatformShims {
)
}
}

type EnableReflectiveInstantiation =
scala.scalajs.reflect.annotation.EnableReflectiveInstantiation

def loadModule(name: String, loader: ClassLoader): Any =
TestUtils.loadModule(name, loader)
}
3 changes: 2 additions & 1 deletion utest/shared/src/main/scala/utest/TestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import utest.framework.Formatter
import scala.concurrent.{ExecutionContext, Future}
import scala.reflect.macros.Context
import scala.language.experimental.macros
import scala.scalajs.reflect.annotation.EnableReflectiveInstantiation

import PlatformShims.EnableReflectiveInstantiation

/**
* Marker class used to mark an `object` as something containing tests. Used
Expand Down
3 changes: 1 addition & 2 deletions utest/shared/src/main/scala/utest/runner/BaseRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package runner
import sbt.testing._

import scala.util.Failure
import org.scalajs.testinterface.TestUtils
import utest.framework.{StackMarker, Tree}
object BaseRunner{
/**
Expand Down Expand Up @@ -106,7 +105,7 @@ abstract class BaseRunner(val args: Array[String],
try {
Right(
StackMarker.dropOutside(
TestUtils.loadModule(suiteName, testClassLoader).asInstanceOf[TestSuite]
PlatformShims.loadModule(suiteName, testClassLoader).asInstanceOf[TestSuite]
)
)
} catch{case e: Throwable => Left(e)}
Expand Down