Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski committed Dec 16, 2021
1 parent 991a21f commit f0d19e7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions modules/cli/src/main/scala/scala/cli/commands/Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,8 @@ object Test extends ScalaCommand[TestOptions] {
case Platform.JVM =>
val classPath = build.fullClassPath

val testFrameworkOpt0 = testFrameworkOpt match {
case Some(fw) => Some(fw)
case None => findTestFramework(classPath, logger)
val testFrameworkOpt0 = testFrameworkOpt.orElse {
findTestFramework(classPath, logger)
}

val extraArgs =
Expand All @@ -191,19 +190,22 @@ object Test extends ScalaCommand[TestOptions] {
}

def findTestFramework(classPath: Seq[Path], logger: Logger): Option[String] = {
val parentInspector = new AsmTestRunner.ParentInspector(classPath)
val classPath0 = classPath.map(_.toString)
val classPath0 = classPath.map(_.toString)

// https://github.com/VirtusLab/scala-cli/issues/426
if (classPath0.exists(_.contains("zio-test")) && !classPath0.exists(_.contains("zio-test-sbt")))
if (
classPath0.exists(_.contains("zio-test")) && !classPath0.exists(_.contains("zio-test-sbt"))
) {
val parentInspector = new AsmTestRunner.ParentInspector(classPath)
Runner.frameworkName(classPath, parentInspector) match {
case Right(f) => Some(f)
case Left(_) =>
logger.message(
"ScalaCLI detects that you use zio-test, please import zio-test-sbt to run zio tests using scala-cli."
"zio-test found in the class path, zio-test-sbt should be added to run zio tests with Scala CLI."
)
None
}
}
else
None
}
Expand Down

0 comments on commit f0d19e7

Please sign in to comment.