Skip to content

Commit

Permalink
bump Scala versions, compile for Scala.js 1.0, update ScalaTest depen…
Browse files Browse the repository at this point in the history
…dency
  • Loading branch information
Rogach committed Apr 24, 2020
1 parent 8d03638 commit b9c98b9
Show file tree
Hide file tree
Showing 32 changed files with 109 additions and 75 deletions.
12 changes: 7 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ lazy val commonSettings = Seq(
scala.io.Source.fromFile("README.md").getLines.filter(_.contains("libraryDependencies")).mkString
versionRegexp.findFirstIn(libraryDependenciesString).get
},
scalaVersion := "2.13.0",
crossScalaVersions := Seq("2.10.7", "2.11.12", "2.12.8", "2.13.0"),
scalaVersion := "2.13.2",
crossScalaVersions := Seq("2.10.7", "2.11.12", "2.12.11", "2.13.2"),
scalacOptions ++= Seq(
"-deprecation",
"-unchecked",
Expand Down Expand Up @@ -87,12 +87,12 @@ lazy val scallop =
.configure(_.enablePlugins(spray.boilerplate.BoilerplatePlugin))
.jvmSettings(
libraryDependencies ++= Seq(
"org.scalatest" %%% "scalatest" % "3.0.8" % Test
"org.scalatest" %%% "scalatest" % "3.1.1" % Test
),
// fix for paths to source files in scaladoc
doc in Compile := {
import sys.process._
Seq("bash","-c",""" for x in $(find jvm/target/scala-2.12/api/ -type f); do sed -i "s_`pwd`/__" $x; done """).!
Seq("bash","-c",""" for x in $(find jvm/target/scala-2.13/api/ -type f); do sed -i "s_`pwd`/__" $x; done """).!
(doc in Compile).value
},
scalacOptions in Test -= "-Xlint"
Expand All @@ -102,5 +102,7 @@ lazy val scallop =
crossScalaVersions := Seq("2.11.12")
)
.jsSettings(
scalaJSUseMainModuleInitializer in Test := true
libraryDependencies ++= Seq(
"org.scalatest" %%% "scalatest" % "3.1.1" % Test
)
)
10 changes: 10 additions & 0 deletions js/src/main/scala/org.rogach.scallop/Compat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.rogach.scallop

object Compat {

def exit(code: Int): Nothing = {
scalajs.js.Dynamic.global.process.exit(code)
throw new Throwable()
}

}
2 changes: 1 addition & 1 deletion js/src/main/scala/org.rogach.scallop/ScallopConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class ScallopConf(

errorMessageHandler = { message =>
Console.err.println(Util.format("[%s] Error: %s", printedName, message))
sys.exit(1)
Compat.exit(1)
}

}
18 changes: 10 additions & 8 deletions js/src/test/scala/JSTests.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package org.rogach.scallop

object Main {
def main(args: Array[String]): Unit = {
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers

class JSTests extends AnyFunSuite with Matchers {

test("small example") {
val conf = new ScallopConf(List("-a","3")) {
val apples = opt[Int]("apples")
verify()
}
assert(conf.apples() == 3)
assert(
conf.builder.help ==
""" -a, --apples <arg>
| -h, --help Show help message""".stripMargin
)
conf.apples() shouldBe 3
conf.builder.help shouldBe """ -a, --apples <arg>
| -h, --help Show help message""".stripMargin
}

}
9 changes: 9 additions & 0 deletions jvm/src/main/scala/org.rogach.scallop/Compat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.rogach.scallop

object Compat {

def exit(code: Int): Nothing = {
sys.exit(code)
}

}
2 changes: 1 addition & 1 deletion jvm/src/main/scala/org.rogach.scallop/ScallopConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ abstract class ScallopConf(
// no colors on output
Console.err.println("[%s] Error: %s" format (printedName, message))
}
sys.exit(1)
Compat.exit(1)
}

}
6 changes: 3 additions & 3 deletions jvm/src/test/scala/ChoiceOptionsTest.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.Matchers
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import org.rogach.scallop._
import org.rogach.scallop.exceptions._

class ChoiceOptionsTest extends FunSuite with Matchers with UsefulMatchers {
class ChoiceOptionsTest extends AnyFunSuite with Matchers with UsefulMatchers {
throwError.value = true

test ("choice option") {
Expand Down
6 changes: 3 additions & 3 deletions jvm/src/test/scala/ConfTest.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.Matchers
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import org.rogach.scallop._
import org.rogach.scallop.exceptions._

class ConfTest extends FunSuite with Matchers with UsefulMatchers with CapturingTest {
class ConfTest extends AnyFunSuite with Matchers with UsefulMatchers with CapturingTest {
throwError.value = true

test ("full example") {
Expand Down
4 changes: 2 additions & 2 deletions jvm/src/test/scala/CustomErrorMessageHandlerTest.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import org.rogach.scallop._
import org.rogach.scallop.exceptions._

class CustomErrorMessageHandlerTest extends FunSuite with UsefulMatchers {
class CustomErrorMessageHandlerTest extends AnyFunSuite with UsefulMatchers {
throwError.value = false

case object Err extends Exception
Expand Down
6 changes: 3 additions & 3 deletions jvm/src/test/scala/DefaultConverterTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package org.rogach.scallop

import org.rogach.scallop.exceptions._

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

import scala.concurrent.duration._

class DurationConverterTest extends FunSuite with UsefulMatchers {
class DurationConverterTest extends AnyFunSuite with UsefulMatchers {
throwError.value = true

test("convert to Duration") {
Expand All @@ -25,7 +25,7 @@ class DurationConverterTest extends FunSuite with UsefulMatchers {
}
}

class FiniteDurationConverterTest extends FunSuite with UsefulMatchers {
class FiniteDurationConverterTest extends AnyFunSuite with UsefulMatchers {
throwError.value = true

test("convert to Duration") {
Expand Down
4 changes: 2 additions & 2 deletions jvm/src/test/scala/DefaultNames.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.Matchers
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import org.rogach.scallop._
import org.rogach.scallop.exceptions._

Expand Down
6 changes: 3 additions & 3 deletions jvm/src/test/scala/ErrorsTest.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.Matchers
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import org.rogach.scallop._
import org.rogach.scallop.exceptions._

class ErrorsTest extends FunSuite with Matchers with UsefulMatchers {
class ErrorsTest extends AnyFunSuite with Matchers with UsefulMatchers {
throwError.value = true

test ("options parse failure") {
Expand Down
5 changes: 3 additions & 2 deletions jvm/src/test/scala/FormatterTest.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.rogach.scallop

import org.scalatest.{ FunSuite, Matchers }
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers

class FormatterTest extends FunSuite with Matchers {
class FormatterTest extends AnyFunSuite with Matchers {
test ("exact wrapping") {
// Two lines' worth of dots, two dots to start (one dot should be at the very end of the line).
val dots = ".." +: Seq.fill(79)(".")
Expand Down
4 changes: 2 additions & 2 deletions jvm/src/test/scala/Isolated.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.Matchers
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import org.rogach.scallop._
import org.rogach.scallop.exceptions._

Expand Down
6 changes: 3 additions & 3 deletions jvm/src/test/scala/LegacyScallopTest.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.Matchers
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import org.rogach.scallop._
import org.rogach.scallop.exceptions._
import reflect.runtime.universe._

class LegacyScallopTest extends FunSuite with Matchers with CapturingTest {
class LegacyScallopTest extends AnyFunSuite with Matchers with CapturingTest {

test ("readme example") {
import org.rogach.scallop._
Expand Down
6 changes: 3 additions & 3 deletions jvm/src/test/scala/LoadTest.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.Matchers
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import org.rogach.scallop._
import org.rogach.scallop.exceptions._

class LoadTest extends FunSuite with Matchers {
class LoadTest extends AnyFunSuite with Matchers {

ignore ("trail options") {
val start = System.currentTimeMillis
Expand Down
4 changes: 2 additions & 2 deletions jvm/src/test/scala/MapCodependenceTest.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import org.rogach.scallop._
import org.rogach.scallop.exceptions._

class MapCodependenceTest extends FunSuite with UsefulMatchers {
class MapCodependenceTest extends AnyFunSuite with UsefulMatchers {
throwError.value = true

class TestConf(args: Seq[String]) extends ScallopConf(args) {
Expand Down
6 changes: 3 additions & 3 deletions jvm/src/test/scala/NumberOptionTest.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.Matchers
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import org.rogach.scallop._
import org.rogach.scallop.exceptions._

class NumberOptionTest extends FunSuite with Matchers with CapturingTest with UsefulMatchers {
class NumberOptionTest extends AnyFunSuite with Matchers with CapturingTest with UsefulMatchers {
throwError.value = true

test ("number option") {
Expand Down
4 changes: 2 additions & 2 deletions jvm/src/test/scala/OptionDependenciesTest.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import org.rogach.scallop._
import org.rogach.scallop.exceptions._

class OptionDependenciesTest extends FunSuite with UsefulMatchers {
class OptionDependenciesTest extends AnyFunSuite with UsefulMatchers {
throwError.value = true

test("dependsOnAny - success, option is not provided") {
Expand Down
6 changes: 3 additions & 3 deletions jvm/src/test/scala/SerializationTest.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.Matchers
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import java.io.{Serializable, ByteArrayOutputStream, ByteArrayInputStream, ObjectOutputStream, ObjectInputStream}

class TestConf(args: List[String]) extends ScallopConf(args) with Serialization {
val apples = opt[Int]("apples")
verify()
}

class SerializationTest extends FunSuite with Matchers with UsefulMatchers {
class SerializationTest extends AnyFunSuite with Matchers with UsefulMatchers {
throwError.value = true

test("simple ScallopConf serialization") {
Expand Down
2 changes: 1 addition & 1 deletion jvm/src/test/scala/SubcommandsTest.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import org.rogach.scallop._
import org.rogach.scallop.exceptions._

Expand Down
5 changes: 3 additions & 2 deletions jvm/src/test/scala/ToggleOptionTest.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.rogach.scallop

import org.scalatest.{FunSuite, Matchers}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import org.rogach.scallop._
import org.rogach.scallop.exceptions._


class ToggleOptionTest extends FunSuite with Matchers {
class ToggleOptionTest extends AnyFunSuite with Matchers {
throwError.value = true

test ("short name") {
Expand Down
6 changes: 3 additions & 3 deletions jvm/src/test/scala/TrailingArgumentsParseTest.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.Matchers
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import org.rogach.scallop._
import org.rogach.scallop.exceptions._

class TrailingArgumentsParseTest extends FunSuite with Matchers with UsefulMatchers {
class TrailingArgumentsParseTest extends AnyFunSuite with Matchers with UsefulMatchers {
throwError.value = true

test ("non-required trailing option after flag") {
Expand Down
6 changes: 3 additions & 3 deletions jvm/src/test/scala/UsefulMatchers.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.Matchers
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers

trait UsefulMatchers extends FunSuite with Matchers {
trait UsefulMatchers extends AnyFunSuite with Matchers {

implicit def toGoodEquals[A](a: A) = new {
def ====[B](b: B) = a should equal (b)
Expand Down
6 changes: 3 additions & 3 deletions jvm/src/test/scala/UtilTest.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.Matchers
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers

class UtilTest extends FunSuite with Matchers with UsefulMatchers {
class UtilTest extends AnyFunSuite with Matchers with UsefulMatchers {
test ("format") {
Util.format("%s", "test") ==== "test"
Util.format(" %s ", "test") ==== " test "
Expand Down
4 changes: 2 additions & 2 deletions jvm/src/test/scala/ValueConverterTest.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.rogach.scallop

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

class ValueConverterTest extends FunSuite with UsefulMatchers {
class ValueConverterTest extends AnyFunSuite with UsefulMatchers {
throwError.value = true

test ("optional value - flatMap way") {
Expand Down
9 changes: 9 additions & 0 deletions native/src/main/scala/org.rogach.scallop/Compat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.rogach.scallop

object Compat {

def exit(code: Int): Nothing = {
sys.exit(code)
}

}
2 changes: 1 addition & 1 deletion native/src/main/scala/org.rogach.scallop/ScallopConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class ScallopConf(

errorMessageHandler = { message =>
Console.err.println(Util.format("[%s] Error: %s", printedName, message))
sys.exit(1)
Compat.exit(1)
}

}
Loading

0 comments on commit b9c98b9

Please sign in to comment.