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

Replace testFrameworksJvmClasspath and testClasspathJvm with just runClasspath #627

Merged
merged 1 commit into from
Jun 8, 2019
Merged
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
25 changes: 3 additions & 22 deletions scalanativelib/src/ScalaNativeModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ trait TestScalaNativeModule extends ScalaNativeModule with TestModule { testOute
// The test frameworks run under the JVM and communicate with the native binary over a socket
// therefore the test framework is loaded from a JVM classloader
val testClassloader =
new URLClassLoader(testClasspathJvm().map(_.path.toIO.toURI.toURL).toArray,
new URLClassLoader(runClasspath().map(_.path.toIO.toURI.toURL).toArray,
this.getClass.getClassLoader)
val frameworkInstances = TestRunner.frameworks(testFrameworks())(testClassloader)
val testBinary = testRunnerNative.nativeLink().toIO
Expand All @@ -186,33 +186,14 @@ trait TestScalaNativeModule extends ScalaNativeModule with TestModule { testOute

val (doneMsg, results) = TestRunner.runTests(
nativeFrameworks,
testClasspathJvm().map(_.path),
runClasspath().map(_.path),
Agg(compile().classes.path),
args
)

TestModule.handleResults(doneMsg, results)
}

private val supportedTestFrameworks = Set("utest", "scalatest")

// get the JVM classpath entries for supported test frameworks
def testFrameworksJvmClasspath = T{
Lib.resolveDependencies(
repositories,
Lib.depToDependency(_, scalaVersion(), ""),
transitiveIvyDeps().filter(d => d.cross.isBinary && supportedTestFrameworks(d.dep.module.name.value)),
ctx = Some(implicitly[mill.util.Ctx.Log])
)
}

def testClasspathJvm = T{
localClasspath() ++
transitiveLocalClasspath() ++
unmanagedClasspath() ++
testFrameworksJvmClasspath()
}

// creates a specific binary used for running tests - has a different (generated) main class
// which knows the names of all the tests and references to invoke them
object testRunnerNative extends ScalaNativeModule {
Expand Down Expand Up @@ -243,7 +224,7 @@ trait TestScalaNativeModule extends ScalaNativeModule with TestModule { testOute
val frameworkInstances = TestRunner.frameworks(testFrameworks()) _

val testClasses =
Jvm.inprocess(testClasspathJvm().map(_.path), classLoaderOverrideSbtTesting = true, isolated = true, closeContextClassLoaderWhenDone = true,
Jvm.inprocess(runClasspath().map(_.path), classLoaderOverrideSbtTesting = true, isolated = true, closeContextClassLoaderWhenDone = true,
cl => {
frameworkInstances(cl).flatMap { framework =>
val df = Lib.discoverTests(cl, framework, Agg(compile().classes.path))
Expand Down