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

enable DottyJS, drop Scala.js 0.6.x #248

Merged
merged 3 commits into from
Nov 9, 2020
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
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ jobs:
js:
strategy:
fail-fast: false
matrix:
scalajs: ["1.3.0", "0.6.32"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v7
- run: sbt +testsJS/test
env:
SCALAJS_VERSION: ${{ matrix.scalajs }}
GOOGLE_APPLICATION_CREDENTIALS:
${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GOOGLE_APPLICATION_CREDENTIALS_JSON:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
- name: Publish ${{ github.ref }}
run: |
sbt ci-release
SCALAJS_VERSION=0.6.32 sbt clean sonatypeBundleClean ci-release
sbt docs/docusaurusPublishGhpages
env:
GIT_USER: munit@scalameta.org
Expand Down
24 changes: 9 additions & 15 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import com.typesafe.tools.mima.core.MissingTypesProblem
import sbtcrossproject.CrossPlugin.autoImport.crossProject
import sbtcrossproject.CrossPlugin.autoImport.CrossType
import scala.collection.mutable
val customScalaJSVersion = Option(System.getenv("SCALAJS_VERSION"))
val scalaJSVersion = customScalaJSVersion.getOrElse("1.3.0")
val scalaJSVersion = "1.3.0"
val scalaNativeVersion = "0.4.0-M2"
def previousVersion = "0.7.0"
def scala213 = "2.13.2"
Expand Down Expand Up @@ -110,7 +109,7 @@ val sharedJVMSettings: List[Def.Setting[_]] = List(
) ++ mimaEnable
val sharedJSSettings: List[Def.Setting[_]] = List(
skipIdeaSettings,
crossScalaVersions := scala2Versions,
crossScalaVersions := allScalaVersions.filterNot(_.startsWith("0.")),
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule))
)
val sharedJSConfigure: Project => Project =
Expand Down Expand Up @@ -151,7 +150,6 @@ lazy val junit = project
mimaEnable,
moduleName := "junit-interface",
description := "A Java implementation of sbt's test interface for JUnit 4",
skip in publish := customScalaJSVersion.isDefined,
autoScalaLibrary := false,
crossPaths := false,
sbtPlugin := false,
Expand Down Expand Up @@ -202,7 +200,6 @@ lazy val munit = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.nativeConfigure(sharedNativeConfigure)
.nativeSettings(
sharedNativeSettings,
skip in publish := customScalaJSVersion.isDefined,
libraryDependencies ++= List(
"org.scala-native" %%% "test-interface" % scalaNativeVersion
)
Expand All @@ -211,13 +208,14 @@ lazy val munit = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.jsSettings(
sharedJSSettings,
libraryDependencies ++= List(
"org.scala-js" %% "scalajs-test-interface" % scalaJSVersion,
"org.scala-js" %% "scalajs-junit-test-runtime" % scalaJSVersion
("org.scala-js" %% "scalajs-test-interface" % scalaJSVersion)
.withDottyCompat(scalaVersion.value),
("org.scala-js" %% "scalajs-junit-test-runtime" % scalaJSVersion)
.withDottyCompat(scalaVersion.value)
)
)
.jvmSettings(
sharedJVMSettings,
skip in publish := customScalaJSVersion.isDefined,
libraryDependencies ++= List(
"junit" % "junit" % "4.13.1"
)
Expand All @@ -234,7 +232,6 @@ lazy val plugin = project
sharedSettings,
moduleName := "sbt-munit",
sbtPlugin := true,
skip in publish := customScalaJSVersion.isDefined,
scalaVersion := scala212,
crossScalaVersions := List(scala212),
buildInfoPackage := "munit.sbtmunit",
Expand All @@ -254,16 +251,14 @@ lazy val munitScalacheck = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.settings(
moduleName := "munit-scalacheck",
sharedSettings,
libraryDependencies += "org.scalacheck" %%% "scalacheck" % "1.15.0"
libraryDependencies += "org.scalacheck" %%% "scalacheck" % "1.15.1"
)
.jvmSettings(
sharedJVMSettings,
skip in publish := customScalaJSVersion.isDefined
sharedJVMSettings
)
.nativeConfigure(sharedNativeConfigure)
.nativeSettings(
sharedNativeSettings,
skip in publish := customScalaJSVersion.isDefined
sharedNativeSettings
)
.jsConfigure(sharedJSConfigure)
.jsSettings(sharedJSSettings)
Expand Down Expand Up @@ -305,7 +300,6 @@ lazy val docs = project
.settings(
sharedSettings,
moduleName := "munit-docs",
skip in publish := customScalaJSVersion.isDefined,
crossScalaVersions := List(scala213, scala212),
unmanagedSources.in(Compile) += sourceDirectory
.in(plugin, Compile)
Expand Down
14 changes: 7 additions & 7 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ libraryDependencies += "org.scalameta" %% "munit" % "@VERSION@" % Test
testFrameworks += new TestFramework("munit.Framework")
```

| Scala Version | JVM | Scala.js (0.6.x, 1.x) | Native (0.4.x) |
| ------------------------- | :-: | :-------------------: | :------------: |
| 2.11.x | ✅ | | ✅ |
| 2.12.x | ✅ | | n/a |
| 2.13.x | ✅ | | n/a |
| @SCALA3_PREVIOUS_VERSION@ | ✅ | n/a | n/a |
| @SCALA3_STABLE_VERSION@ | ✅ | n/a | n/a |
| Scala Version | JVM | Scala.js (0.6.x) | Scala.js (1.x) | Native (0.4.x) |
| ------------------------- | :-: | :--------------: | :------------: | :------------: |
| 2.11.x | ✅ | ✅ until 0.7.16 | | ✅ |
| 2.12.x | ✅ | ✅ until 0.7.16 | | n/a |
| 2.13.x | ✅ | ✅ until 0.7.16 | | n/a |
| @SCALA3_PREVIOUS_VERSION@ | ✅ | n/a | ✅ | n/a |
| @SCALA3_STABLE_VERSION@ | ✅ | n/a | ✅ | n/a |

Next, write a test suite.

Expand Down
3 changes: 2 additions & 1 deletion munit/js/src/main/scala/munit/internal/JSIO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ object JSPath extends js.Any {
object JSIO {
private[internal] val process: JSProcess =
js.Dynamic.global.process.asInstanceOf[JSProcess]
def isNode: Boolean = !js.isUndefined(process) && !js.isUndefined(process.cwd)
def isNode: Boolean =
!js.isUndefined(process) && !js.isUndefined(process.cwd())

def inNode[T](f: => T): T =
if (JSIO.isNode) f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class TagsFilter(
var isExcluded = false
description.getAnnotations.foreach {
case t: Tag =>
isIncluded ||= include.contains(t.value())
isExcluded ||= exclude.contains(t.value())
isIncluded ||= include.contains(t.value)
isExcluded ||= exclude.contains(t.value)
case _ =>
}
isIncluded && !isExcluded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ abstract class JUnitFramework extends Framework {
var logAssert = false
var notLogExceptionClass = false
var useSbtLoggers = false
var trimStackTraces = defaults.trimStackTraces()
var trimStackTraces = defaults.trimStackTraces
var includeTags = Set.empty[String]
var excludeTags = Set.empty[String]
for (str <- args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package munit.internal.junitinterface

trait Settings {
def trimStackTraces(): Boolean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the parentheses back here? These interfaces are meant to be mirrors of their equivalent Java interfaces https://github.com/scalameta/munit/blob/7ea3075ae51ca73c7fa84373aa9dd82cf9a6ccd7/junit-interface/src/main/java/munit/internal/junitinterface/Tag.java

I prefer to keep the two synchronized as much as possible, these are internal APIs so it shouldn't matter much whichever we use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add them back, but that makes stuff in some other places more complicated. There are some classes that attempt to use val to override those defs (which doesn't work anymore in Dotty, so they have to be renamed). Those constructors are subsequently called with named parameters, so their call sites have to be renamed too.

I'm happy to go ahead either way, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. That makes sense, I'm glad Scala 3 is more strict about the differences between method() and method without parentheses. It's still quite a large breaking change, I always thought it was elegant that val could override parameterless defs.

Anyways, I'm fine dropping the parentheses in this case 👍

def trimStackTraces: Boolean
}

object Settings {
def defaults(): Settings = new Settings {
def trimStackTraces(): Boolean = true
def trimStackTraces: Boolean = true
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package munit.internal.junitinterface

trait Tag {
def value(): String
def value: String
}
8 changes: 4 additions & 4 deletions munit/shared/src/main/scala/munit/MUnitRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class MUnitRunner(val cls: Class[_ <: Suite], newInstance: () => Suite)
)
}

override def getDescription: Description = {
override def getDescription(): Description = {
val description = Description.createSuiteDescription(cls)

try {
Expand All @@ -104,7 +104,7 @@ class MUnitRunner(val cls: Class[_ <: Suite], newInstance: () => Suite)
Await.result(runAsync(notifier), Duration.Inf)
}
def runAsync(notifier: RunNotifier): Future[Unit] = {
val description = getDescription
val description = getDescription()
notifier.fireTestSuiteStarted(description)
try {
runAll(notifier)
Expand Down Expand Up @@ -139,7 +139,7 @@ class MUnitRunner(val cls: Class[_ <: Suite], newInstance: () => Suite)

private def runAll(notifier: RunNotifier): Future[Unit] = {
if (PlatformCompat.isIgnoreSuite(cls)) {
val description = getDescription
val description = getDescription()
notifier.fireTestIgnored(description)
return Future.successful(())
}
Expand Down Expand Up @@ -356,7 +356,7 @@ class MUnitRunner(val cls: Class[_ <: Suite], newInstance: () => Suite)
notifier.fireTestFinished(description)
}
private def trimStackTrace(ex: Throwable): Unit = {
if (settings.trimStackTraces()) {
if (settings.trimStackTraces) {
StackTraces.trimStackTrace(ex)
}
}
Expand Down
5 changes: 1 addition & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
val scalaJSVersion =
Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.3.0")

addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.11")
Expand All @@ -10,7 +7,7 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.23")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.0.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0-M2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1")

libraryDependencies += "com.google.cloud" % "google-cloud-storage" % "1.113.2"
Expand Down