Skip to content

Commit

Permalink
Factor launcher option handling in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed Apr 11, 2023
1 parent ed53da5 commit 39d7ea5
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ import coursier.clitests.util.TestAuthProxy
import coursier.dependencyString
import utest._

abstract class BootstrapTests extends TestSuite {
abstract class BootstrapTests extends TestSuite with LauncherOptions {

def launcher: String
def assembly: String
def acceptsDOptions: Boolean = true
def acceptsJOptions: Boolean = true

def overrideProguarded: Option[Boolean] =
None
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package coursier.clitests

trait LauncherOptions {
def acceptsDOptions: Boolean
def acceptsJOptions: Boolean
}
6 changes: 6 additions & 0 deletions modules/cli-tests/src/main/scala/coursier/clitests/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ object Run extends CaseApp[RunOptions] {

val launchTests = new LaunchTests {
val launcher = options.launcher

def acceptsDOptions = true
def acceptsJOptions = true
}
val bootstrapTests = new BootstrapTests {
val launcher = options.launcher
val assembly = options.assembly

def acceptsDOptions = true
def acceptsJOptions = true
}
val fetchTests = new FetchTests {
val launcher = options.launcher
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
package coursier.clitests

import java.util.Locale

import scala.util.Properties

object PackBootstrapTests extends BootstrapTests {
object PackBootstrapTests extends BootstrapTests with PackLauncherOptions {
val launcher = LauncherTestUtil.launcher
val assembly = LauncherTestUtil.assembly
override lazy val acceptsDOptions =
sys.props.get("coursier-test-launcher-accepts-D").map(_.toLowerCase(Locale.ROOT)) match {
case Some("true") => true
case Some("false") => false
case None => true
case Some(other) =>
System.err.println(s"Warning: unrecognized coursier-test-launcher-accepts-D value '$other'")
true
}
override lazy val acceptsJOptions =
sys.props.get("coursier-test-launcher-accepts-J").map(_.toLowerCase(Locale.ROOT)) match {
case Some("true") => true
case Some("false") => false
case None => !Properties.isWin
case Some(other) =>
System.err.println(s"Warning: unrecognized coursier-test-launcher-accepts-J value '$other'")
true
}
override lazy val overrideProguarded: Option[Boolean] =
if (sys.props.get("java.version").exists(!_.startsWith("1.")))
// It seems bootstrap JARs built on Java 11 fail at runtime with some obscure
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package coursier.clitests

import java.util.Locale

import scala.util.Properties

trait PackLauncherOptions extends LauncherOptions {
override lazy val acceptsDOptions =
sys.props.get("coursier-test-launcher-accepts-D").map(_.toLowerCase(Locale.ROOT)) match {
case Some("true") => true
case Some("false") => false
case None => true
case Some(other) =>
System.err.println(s"Warning: unrecognized coursier-test-launcher-accepts-D value '$other'")
true
}
override lazy val acceptsJOptions =
sys.props.get("coursier-test-launcher-accepts-J").map(_.toLowerCase(Locale.ROOT)) match {
case Some("true") => true
case Some("false") => false
case None => !Properties.isWin
case Some(other) =>
System.err.println(s"Warning: unrecognized coursier-test-launcher-accepts-J value '$other'")
true
}
}

0 comments on commit 39d7ea5

Please sign in to comment.