Skip to content

Commit

Permalink
Fix CI failures
Browse files Browse the repository at this point in the history
* don't run StackTraceFrameworkSuite on Scala.js
* run Scalafix + Scalafmt
  • Loading branch information
Olafur Pall Geirsson committed May 10, 2020
1 parent 5605177 commit a2a694e
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 36 deletions.

This file was deleted.

5 changes: 4 additions & 1 deletion munit/shared/src/main/scala/munit/FunFixtures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ trait FunFixtures { self: FunSuite =>
}

object FunFixture {
def apply[T](setup: TestOptions => T, teardown: T => Unit) = {
def apply[T](
setup: TestOptions => T,
teardown: T => Unit
): FunFixture[T] = {
implicit val ec = munitExecutionContext
async[T](
options => Future { setup(options) },
Expand Down
8 changes: 4 additions & 4 deletions tests/jvm/src/test/scala/munit/AsyncFixtureOrderSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import scala.concurrent.Future
import scala.concurrent.Promise

class AsyncFixtureOrderSuite extends FunSuite {
val latch = Promise[Unit]
var completedFromTest = Option.empty[Boolean]
var completedFromTeardown = Option.empty[Boolean]
val latch: Promise[Unit] = Promise[Unit]
var completedFromTest: Option[Boolean] = None
var completedFromTeardown: Option[Boolean] = None

val latchOnTeardown = FunFixture.async[String](
val latchOnTeardown: FunFixture[String] = FunFixture.async[String](
setup = { test => Future.successful(test.name) },
teardown = { name =>
implicit val ec = munitExecutionContext
Expand Down
38 changes: 19 additions & 19 deletions tests/shared/src/main/scala/munit/AssertionsFrameworkSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ class AssertionsFrameworkSuite extends FunSuite {
object AssertionsFrameworkSuite
extends FrameworkTest(
classOf[AssertionsFrameworkSuite],
"""|==> failure munit.AssertionsFrameworkSuite.equal-tostring - /scala/munit/AssertionsFrameworkSuite.scala:11 values are not equal even if they have the same `toString()`: C
|10: }
|11: assertEquals[Any, Any](new A(), new B())
|12: }
|==> failure munit.AssertionsFrameworkSuite.case-class-productPrefix - /scala/munit/AssertionsFrameworkSuite.scala:21 values are not equal even if they have the same `toString()`: A()
|20: }
|21: assertEquals[Any, Any](a.A(), b.A())
|22: }
|==> failure munit.AssertionsFrameworkSuite.different-toString - /scala/munit/AssertionsFrameworkSuite.scala:35
|34: }
|35: assertEquals[Any, Any](a.A(), b.A())
|36: }
|values are not the same
|=> Obtained
|a.A()
|=> Diff (- obtained, + expected)
|-a.A()
|+b.B()
|""".stripMargin
"""|==> failure munit.AssertionsFrameworkSuite.equal-tostring - /scala/munit/AssertionsFrameworkSuite.scala:11 values are not equal even if they have the same `toString()`: C
|10: }
|11: assertEquals[Any, Any](new A(), new B())
|12: }
|==> failure munit.AssertionsFrameworkSuite.case-class-productPrefix - /scala/munit/AssertionsFrameworkSuite.scala:21 values are not equal even if they have the same `toString()`: A()
|20: }
|21: assertEquals[Any, Any](a.A(), b.A())
|22: }
|==> failure munit.AssertionsFrameworkSuite.different-toString - /scala/munit/AssertionsFrameworkSuite.scala:35
|34: }
|35: assertEquals[Any, Any](a.A(), b.A())
|36: }
|values are not the same
|=> Obtained
|a.A()
|=> Diff (- obtained, + expected)
|-a.A()
|+b.B()
|""".stripMargin
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ package munit
import scala.concurrent.Future

class AsyncFixtureFrameworkSuite extends FunSuite {
val failingSetup = FunFixture.async[Unit](
val failingSetup: FunFixture[Unit] = FunFixture.async[Unit](
_ => Future.failed(new Error("failure in setup")),
_ => Future.successful(())
)

val failingTeardown = FunFixture.async[Unit](
val failingTeardown: FunFixture[Unit] = FunFixture.async[Unit](
_ => Future.successful(()),
_ => Future.failed(new Error("failure in teardown"))
)

val unitFixture = FunFixture.async[Unit](
val unitFixture: FunFixture[Unit] = FunFixture.async[Unit](
_ => Future.successful(()),
_ => Future.successful(())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import scala.concurrent.Future
class AsyncFixtureTeardownFrameworkSuite extends FunSuite {
@volatile var cleanedUp: Boolean = _

val cleanupInTeardown = FunFixture.async[Unit](
val cleanupInTeardown: FunFixture[Unit] = FunFixture.async[Unit](
_ => { cleanedUp = false; Future.successful(()) },
_ => { cleanedUp = true; Future.successful(()) }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class BaseStackTraceFrameworkSuite(arguments: Array[String], expected: String)
classOf[StackTraceFrameworkSuite],
expected,
arguments = arguments,
tags = Set(OnlyJVM),
onEvent = { event =>
if (event.throwable().isDefined()) {
val s = event.throwable().get().getStackTrace()
Expand Down
4 changes: 2 additions & 2 deletions tests/shared/src/test/scala/munit/BaseFrameworkSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import munit.internal.console.AnsiColors
import munit.internal.PlatformCompat
import scala.concurrent.Future

abstract class BaseFrameworkSuite extends FunSuite {
abstract class BaseFrameworkSuite extends BaseSuite {
val systemOut = System.out
override def munitIgnore: Boolean = !BuildInfo.scalaVersion.startsWith("2.13")
def exceptionMessage(ex: Throwable): String = {
Expand All @@ -29,7 +29,7 @@ abstract class BaseFrameworkSuite extends FunSuite {
}

def check(t: FrameworkTest): Unit = {
test(t.cls.getSimpleName()) {
test(t.cls.getSimpleName().withTags(t.tags)) {
val baos = new ByteArrayOutputStream()
val out = new PrintStream(baos)
val logger = new Logger {
Expand Down
2 changes: 1 addition & 1 deletion tests/shared/src/test/scala/munit/FunFixtureSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package munit

class FunFixtureSuite extends FunSuite {
var tearDownName = ""
val files = FunFixture[String](
val files: FunFixture[String] = FunFixture[String](
setup = { test => test.name + "-setup" },
teardown = { name => tearDownName = name }
)
Expand Down

0 comments on commit a2a694e

Please sign in to comment.