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

Align output for ignored and skipped tests between all 3 platforms #766

Merged
merged 2 commits into from
Apr 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
});
}
Expand Down Expand Up @@ -134,7 +136,7 @@ void logTo(RichLogger logger) {
logger.warn(
settings.buildTestResult(Status.Ignored)
+ ansiName
+ " ignored"
+ Ansi.c(" ignored", SKIPPED)
+ durationSuffix());
}
});
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,15 @@ 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(
method: String,
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 = {
Expand Down
2 changes: 2 additions & 0 deletions tests/shared/src/main/scala/munit/BaseSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
65 changes: 64 additions & 1 deletion tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,68 @@ object SkippedFrameworkSuite
|==> ignored munit.SkippedFrameworkSuite.ignore
|==> success munit.SkippedFrameworkSuite.assume(true)
|==> skipped munit.SkippedFrameworkSuite.assume(false) - assume it fails
|""".stripMargin
|""".stripMargin,
format = SbtFormat
)

object SkippedFrameworkStdoutJsNativeSuite
extends FrameworkTest(
classOf[SkippedFrameworkSuite],
"""|munit.SkippedFrameworkSuite:
| + pass <elapsed time>
|==> i ignore ignored
| + assume(true) <elapsed time>
|==> s assume(false) skipped
|""".stripMargin,
format = StdoutFormat,
tags = Set(NoJVM)
)

object SkippedFrameworkStdoutJsNativeVerboseSuite
extends FrameworkTest(
classOf[SkippedFrameworkSuite],
"""|munit.SkippedFrameworkSuite:
|pass started
| + pass <elapsed time>
|==> i ignore ignored
|assume(true) started
| + assume(true) <elapsed time>
|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 <elapsed time>
|==> i munit.SkippedFrameworkSuite.ignore ignored <elapsed time>
| + assume(true) <elapsed time>
|==> s munit.SkippedFrameworkSuite.assume(false) skipped <elapsed time>
|""".stripMargin,
format = StdoutFormat,
tags = Set(OnlyJVM)
)

object SkippedFrameworkStdoutJVMVerboseSuite
extends FrameworkTest(
classOf[SkippedFrameworkSuite],
"""|munit.SkippedFrameworkSuite started
|munit.SkippedFrameworkSuite:
|munit.SkippedFrameworkSuite.pass started
| + pass <elapsed time>
|==> i munit.SkippedFrameworkSuite.ignore ignored <elapsed time>
|munit.SkippedFrameworkSuite.assume(true) started
| + assume(true) <elapsed time>
|munit.SkippedFrameworkSuite.assume(false) started
|==> s munit.SkippedFrameworkSuite.assume(false) skipped <elapsed time>
|Test run munit.SkippedFrameworkSuite finished: 0 failed, 1 ignored, 3 total, <elapsed time>
|""".stripMargin,
format = StdoutFormat,
tags = Set(OnlyJVM),
arguments = Array("-v")
)
1 change: 1 addition & 0 deletions tests/shared/src/main/scala/munit/Tags.scala
Original file line number Diff line number Diff line change
@@ -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") {}
6 changes: 5 additions & 1 deletion tests/shared/src/test/scala/munit/FrameworkSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ class FrameworkSuite extends BaseFrameworkSuite {
Issue583FrameworkSuite,
ScalaCheckExceptionFrameworkSuite,
BoxedFrameworkSuite,
SkippedFrameworkSuite
SkippedFrameworkSuite,
SkippedFrameworkStdoutJsNativeSuite,
SkippedFrameworkStdoutJVMSuite,
SkippedFrameworkStdoutJsNativeVerboseSuite,
SkippedFrameworkStdoutJVMVerboseSuite
)
tests.foreach { t => check(t) }
}