From 825c032e36df38f3f5bba2fb7cdc651e342731b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Zu=CC=88hlke?= Date: Thu, 18 Apr 2024 09:02:17 +0200 Subject: [PATCH 1/2] create test to document current status --- .../src/main/scala/munit/BaseSuite.scala | 2 + .../scala/munit/SkippedFrameworkSuite.scala | 62 ++++++++++++++++- tests/shared/src/main/scala/munit/Tags.scala | 1 + .../src/test/scala/munit/FrameworkSuite.scala | 68 ++++++++++--------- 4 files changed, 100 insertions(+), 33 deletions(-) diff --git a/tests/shared/src/main/scala/munit/BaseSuite.scala b/tests/shared/src/main/scala/munit/BaseSuite.scala index ea2289a5..dddc0336 100644 --- a/tests/shared/src/main/scala/munit/BaseSuite.scala +++ b/tests/shared/src/main/scala/munit/BaseSuite.scala @@ -20,6 +20,8 @@ class BaseSuite extends FunSuite { test.tag(Ignore) } else if (test.tags(OnlyJVM) && !PlatformCompat.isJVM) { test.tag(Ignore) + } else if (test.tags(NoJVM) && PlatformCompat.isJVM) { + test.tag(Ignore) } else if (test.tags(NoNative) && PlatformCompat.isNative) { test.tag(Ignore) } else { diff --git a/tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala b/tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala index fb632b09..6e9781b7 100644 --- a/tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala +++ b/tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala @@ -23,5 +23,65 @@ object SkippedFrameworkSuite |==> ignored munit.SkippedFrameworkSuite.ignore |==> success munit.SkippedFrameworkSuite.assume(true) |==> skipped munit.SkippedFrameworkSuite.assume(false) - assume it fails - |""".stripMargin + |""".stripMargin, + format = SbtFormat + ) + +object SkippedFrameworkStdoutOtherSuite + extends FrameworkTest( + classOf[SkippedFrameworkSuite], + """|munit.SkippedFrameworkSuite: + | + pass + | + assume(true) + |""".stripMargin, + format = StdoutFormat, + tags = Set(NoJVM) + ) + +object SkippedFrameworkStdoutOtherVerboseSuite + extends FrameworkTest( + classOf[SkippedFrameworkSuite], + """|munit.SkippedFrameworkSuite: + |pass started + | + pass + |==> i ignore ignored + |assume(true) started + | + assume(true) + |assume(false) started + |==> s assume(false) skipped + |""".stripMargin, + format = StdoutFormat, + tags = Set(NoJVM), + arguments = Array("-v") + ) + +object SkippedFrameworkStdoutJVMSuite + extends FrameworkTest( + classOf[SkippedFrameworkSuite], + """|munit.SkippedFrameworkSuite: + | + pass + |==> i munit.SkippedFrameworkSuite.ignore ignored + | + assume(true) + |""".stripMargin, + format = StdoutFormat, + tags = Set(OnlyJVM) + ) + +object SkippedFrameworkStdoutJVMVerboseSuite + extends FrameworkTest( + classOf[SkippedFrameworkSuite], + """|munit.SkippedFrameworkSuite started + |munit.SkippedFrameworkSuite: + |munit.SkippedFrameworkSuite.pass started + | + pass + |==> i munit.SkippedFrameworkSuite.ignore ignored + |munit.SkippedFrameworkSuite.assume(true) started + | + assume(true) + |munit.SkippedFrameworkSuite.assume(false) started + |==> i assume(false) + |Test run munit.SkippedFrameworkSuite finished: 0 failed, 1 ignored, 3 total, + |""".stripMargin, + format = StdoutFormat, + tags = Set(OnlyJVM), + arguments = Array("-v") ) diff --git a/tests/shared/src/main/scala/munit/Tags.scala b/tests/shared/src/main/scala/munit/Tags.scala index b81797be..3e878299 100644 --- a/tests/shared/src/main/scala/munit/Tags.scala +++ b/tests/shared/src/main/scala/munit/Tags.scala @@ -1,6 +1,7 @@ package munit object OnlyJVM extends Tag("OnlyJVM") {} +object NoJVM extends Tag("NoJVM") {} object NoDotty extends Tag("NoDotty") {} object Only213 extends Tag("Only213") {} object NoNative extends Tag("NoNative") {} diff --git a/tests/shared/src/test/scala/munit/FrameworkSuite.scala b/tests/shared/src/test/scala/munit/FrameworkSuite.scala index e0f1c44f..6aea344f 100644 --- a/tests/shared/src/test/scala/munit/FrameworkSuite.scala +++ b/tests/shared/src/test/scala/munit/FrameworkSuite.scala @@ -2,38 +2,42 @@ package munit class FrameworkSuite extends BaseFrameworkSuite { val tests: List[FrameworkTest] = List[FrameworkTest]( - SwallowedExceptionSuite, - InterceptFrameworkSuite, - CiOnlyFrameworkSuite, - DiffProductFrameworkSuite, - FailFrameworkSuite, - FailSuiteFrameworkSuite, - TestNameFrameworkSuite, - ScalaVersionFrameworkSuite, - FixtureOrderFrameworkSuite, - TagsIncludeFramweworkSuite, - TagsIncludeExcludeFramweworkSuite, - TagsExcludeFramweworkSuite, - SuiteTransformCrashFrameworkSuite, - SuiteTransformFrameworkSuite, - TestTransformCrashFrameworkSuite, - TestTransformFrameworkSuite, - ValueTransformCrashFrameworkSuite, - ValueTransformFrameworkSuite, - ScalaCheckFrameworkSuite, - AsyncFunFixtureFrameworkSuite, - AsyncFixtureTeardownFrameworkSuite, - DuplicateNameFrameworkSuite, - FullStackTraceFrameworkSuite, - SmallStackTraceFrameworkSuite, - AssertionsFrameworkSuite, - Issue179FrameworkSuite, - Issue285FrameworkSuite, - Issue497FrameworkSuite, - Issue583FrameworkSuite, - ScalaCheckExceptionFrameworkSuite, - BoxedFrameworkSuite, - SkippedFrameworkSuite +// SwallowedExceptionSuite, +// InterceptFrameworkSuite, +// CiOnlyFrameworkSuite, +// DiffProductFrameworkSuite, +// FailFrameworkSuite, +// FailSuiteFrameworkSuite, +// TestNameFrameworkSuite, +// ScalaVersionFrameworkSuite, +// FixtureOrderFrameworkSuite, +// TagsIncludeFramweworkSuite, +// TagsIncludeExcludeFramweworkSuite, +// TagsExcludeFramweworkSuite, +// SuiteTransformCrashFrameworkSuite, +// SuiteTransformFrameworkSuite, +// TestTransformCrashFrameworkSuite, +// TestTransformFrameworkSuite, +// ValueTransformCrashFrameworkSuite, +// ValueTransformFrameworkSuite, +// ScalaCheckFrameworkSuite, +// AsyncFunFixtureFrameworkSuite, +// AsyncFixtureTeardownFrameworkSuite, +// DuplicateNameFrameworkSuite, +// FullStackTraceFrameworkSuite, +// SmallStackTraceFrameworkSuite, +// AssertionsFrameworkSuite, +// Issue179FrameworkSuite, +// Issue285FrameworkSuite, +// Issue497FrameworkSuite, +// Issue583FrameworkSuite, +// ScalaCheckExceptionFrameworkSuite, +// BoxedFrameworkSuite, + SkippedFrameworkSuite, + SkippedFrameworkStdoutOtherSuite, + SkippedFrameworkStdoutJVMSuite, + SkippedFrameworkStdoutOtherVerboseSuite, + SkippedFrameworkStdoutJVMVerboseSuite ) tests.foreach { t => check(t) } } From cfca6bd3ebfb6269f5107fb246fe5559e46e70da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Zu=CC=88hlke?= Date: Thu, 18 Apr 2024 17:39:29 +0200 Subject: [PATCH 2/2] align output for ignored and skipped tests between all 3 platforms --- .../junitinterface/EventDispatcher.java | 12 ++-- .../junitinterface/JUnitReporter.scala | 8 +-- .../scala/munit/SkippedFrameworkSuite.scala | 39 ++++++----- .../src/test/scala/munit/FrameworkSuite.scala | 66 +++++++++---------- 4 files changed, 63 insertions(+), 62 deletions(-) diff --git a/junit-interface/src/main/java/munit/internal/junitinterface/EventDispatcher.java b/junit-interface/src/main/java/munit/internal/junitinterface/EventDispatcher.java index d49a4eaa..70e7014d 100644 --- a/junit-interface/src/main/java/munit/internal/junitinterface/EventDispatcher.java +++ b/junit-interface/src/main/java/munit/internal/junitinterface/EventDispatcher.java @@ -75,9 +75,11 @@ public void testAssumptionFailure(final Failure failure) { failure.getDescription(), new ErrorEvent(failure, Status.Skipped) { void logTo(RichLogger logger) { - if (settings.verbose) { - logger.info(Ansi.c("==> i " + failure.getDescription().getMethodName(), WARNMSG)); - } + logger.warn( + settings.buildTestResult(Status.Skipped) + + ansiName + + Ansi.c(" skipped", SKIPPED) + + durationSuffix()); } }); } @@ -134,7 +136,7 @@ void logTo(RichLogger logger) { logger.warn( settings.buildTestResult(Status.Ignored) + ansiName - + " ignored" + + Ansi.c(" ignored", SKIPPED) + durationSuffix()); } }); @@ -163,7 +165,7 @@ private void recordStartTime(Description description) { private Long elapsedTime(Description description) { Long startTime = startTimes.get(description.getMethodName()); if (startTime == null) { - return 0l; + return 0L; } else { return System.currentTimeMillis() - startTime; } diff --git a/munit/js-native/src/main/scala/munit/internal/junitinterface/JUnitReporter.scala b/munit/js-native/src/main/scala/munit/internal/junitinterface/JUnitReporter.scala index a65fdefc..03d03f64 100644 --- a/munit/js-native/src/main/scala/munit/internal/junitinterface/JUnitReporter.scala +++ b/munit/js-native/src/main/scala/munit/internal/junitinterface/JUnitReporter.scala @@ -30,9 +30,7 @@ final class JUnitReporter( } def reportTestIgnored(method: String): Unit = { - if (settings.verbose) { - log(Info, AnsiColors.c(s"==> i $method ignored", AnsiColors.YELLOW)) - } + log(Info, AnsiColors.c(s"==> i $method ignored", AnsiColors.YELLOW)) emitEvent(method, Status.Ignored) } def reportAssumptionViolation( @@ -40,9 +38,7 @@ final class JUnitReporter( timeInSeconds: Double, e: Throwable ): Unit = { - if (settings.verbose) { - log(Info, AnsiColors.c(s"==> s $method skipped", AnsiColors.YELLOW)) - } + log(Info, AnsiColors.c(s"==> s $method skipped", AnsiColors.YELLOW)) emitEvent(method, Status.Skipped, new OptionalThrowable(e)) } def reportTestPassed(method: String, elapsedMillis: Double): Unit = { diff --git a/tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala b/tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala index 6e9781b7..53e60ea2 100644 --- a/tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala +++ b/tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala @@ -27,33 +27,35 @@ object SkippedFrameworkSuite format = SbtFormat ) -object SkippedFrameworkStdoutOtherSuite +object SkippedFrameworkStdoutJsNativeSuite extends FrameworkTest( classOf[SkippedFrameworkSuite], """|munit.SkippedFrameworkSuite: | + pass + |==> i ignore ignored | + assume(true) + |==> s assume(false) skipped |""".stripMargin, format = StdoutFormat, tags = Set(NoJVM) ) -object SkippedFrameworkStdoutOtherVerboseSuite - extends FrameworkTest( - classOf[SkippedFrameworkSuite], - """|munit.SkippedFrameworkSuite: - |pass started - | + pass - |==> i ignore ignored - |assume(true) started - | + assume(true) - |assume(false) started - |==> s assume(false) skipped - |""".stripMargin, - format = StdoutFormat, - tags = Set(NoJVM), - arguments = Array("-v") - ) +object SkippedFrameworkStdoutJsNativeVerboseSuite + extends FrameworkTest( + classOf[SkippedFrameworkSuite], + """|munit.SkippedFrameworkSuite: + |pass started + | + pass + |==> i ignore ignored + |assume(true) started + | + assume(true) + |assume(false) started + |==> s assume(false) skipped + |""".stripMargin, + format = StdoutFormat, + tags = Set(NoJVM), + arguments = Array("-v") + ) object SkippedFrameworkStdoutJVMSuite extends FrameworkTest( @@ -62,6 +64,7 @@ object SkippedFrameworkStdoutJVMSuite | + pass |==> i munit.SkippedFrameworkSuite.ignore ignored | + assume(true) + |==> s munit.SkippedFrameworkSuite.assume(false) skipped |""".stripMargin, format = StdoutFormat, tags = Set(OnlyJVM) @@ -78,7 +81,7 @@ object SkippedFrameworkStdoutJVMVerboseSuite |munit.SkippedFrameworkSuite.assume(true) started | + assume(true) |munit.SkippedFrameworkSuite.assume(false) started - |==> i assume(false) + |==> s munit.SkippedFrameworkSuite.assume(false) skipped |Test run munit.SkippedFrameworkSuite finished: 0 failed, 1 ignored, 3 total, |""".stripMargin, format = StdoutFormat, diff --git a/tests/shared/src/test/scala/munit/FrameworkSuite.scala b/tests/shared/src/test/scala/munit/FrameworkSuite.scala index 6aea344f..26009fe6 100644 --- a/tests/shared/src/test/scala/munit/FrameworkSuite.scala +++ b/tests/shared/src/test/scala/munit/FrameworkSuite.scala @@ -2,41 +2,41 @@ package munit class FrameworkSuite extends BaseFrameworkSuite { val tests: List[FrameworkTest] = List[FrameworkTest]( -// SwallowedExceptionSuite, -// InterceptFrameworkSuite, -// CiOnlyFrameworkSuite, -// DiffProductFrameworkSuite, -// FailFrameworkSuite, -// FailSuiteFrameworkSuite, -// TestNameFrameworkSuite, -// ScalaVersionFrameworkSuite, -// FixtureOrderFrameworkSuite, -// TagsIncludeFramweworkSuite, -// TagsIncludeExcludeFramweworkSuite, -// TagsExcludeFramweworkSuite, -// SuiteTransformCrashFrameworkSuite, -// SuiteTransformFrameworkSuite, -// TestTransformCrashFrameworkSuite, -// TestTransformFrameworkSuite, -// ValueTransformCrashFrameworkSuite, -// ValueTransformFrameworkSuite, -// ScalaCheckFrameworkSuite, -// AsyncFunFixtureFrameworkSuite, -// AsyncFixtureTeardownFrameworkSuite, -// DuplicateNameFrameworkSuite, -// FullStackTraceFrameworkSuite, -// SmallStackTraceFrameworkSuite, -// AssertionsFrameworkSuite, -// Issue179FrameworkSuite, -// Issue285FrameworkSuite, -// Issue497FrameworkSuite, -// Issue583FrameworkSuite, -// ScalaCheckExceptionFrameworkSuite, -// BoxedFrameworkSuite, + SwallowedExceptionSuite, + InterceptFrameworkSuite, + CiOnlyFrameworkSuite, + DiffProductFrameworkSuite, + FailFrameworkSuite, + FailSuiteFrameworkSuite, + TestNameFrameworkSuite, + ScalaVersionFrameworkSuite, + FixtureOrderFrameworkSuite, + TagsIncludeFramweworkSuite, + TagsIncludeExcludeFramweworkSuite, + TagsExcludeFramweworkSuite, + SuiteTransformCrashFrameworkSuite, + SuiteTransformFrameworkSuite, + TestTransformCrashFrameworkSuite, + TestTransformFrameworkSuite, + ValueTransformCrashFrameworkSuite, + ValueTransformFrameworkSuite, + ScalaCheckFrameworkSuite, + AsyncFunFixtureFrameworkSuite, + AsyncFixtureTeardownFrameworkSuite, + DuplicateNameFrameworkSuite, + FullStackTraceFrameworkSuite, + SmallStackTraceFrameworkSuite, + AssertionsFrameworkSuite, + Issue179FrameworkSuite, + Issue285FrameworkSuite, + Issue497FrameworkSuite, + Issue583FrameworkSuite, + ScalaCheckExceptionFrameworkSuite, + BoxedFrameworkSuite, SkippedFrameworkSuite, - SkippedFrameworkStdoutOtherSuite, + SkippedFrameworkStdoutJsNativeSuite, SkippedFrameworkStdoutJVMSuite, - SkippedFrameworkStdoutOtherVerboseSuite, + SkippedFrameworkStdoutJsNativeVerboseSuite, SkippedFrameworkStdoutJVMVerboseSuite ) tests.foreach { t => check(t) }