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

Support “Pending” test case Tag #839 #840

Merged
merged 3 commits into from
Oct 10, 2024
Merged

Conversation

jnd-au
Copy link
Contributor

@jnd-au jnd-au commented Oct 3, 2024

  • Also show elapsed time for JS/Native Ignored tests (may be non-zero), to be consistent with JVM

- Also show elapsed time for JS/Native Ignored tests (may be non-zero), to be consistent with JVM
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

Sounds reasonable to add it. Sorry for taking so long to review!

if (annotation instanceof Tag) {
Tag tag = (Tag) annotation;
String kind = tag.getClass().getName();
if (kind.equals("munit.Tag") && tag.value().equals("Pending")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (kind.equals("munit.Tag") && tag.value().equals("Pending")) {
if (tag.value().equals("Pending")) {

is this needed? We already check if it's a Tag class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your review! The reason for lines 143-146 was for simplicity, to avoid adding lots of Java and JS interfaces in the munit.internal.junitinterface package. However, based on your feedback, I’ll push some changes to that interface.

@@ -1,7 +1,10 @@
package object munit {
case class PendingComment(override val value: String) extends Tag(value)
Copy link
Contributor

Choose a reason for hiding this comment

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

What about having a single class instead?

Suggested change
case class PendingComment(override val value: String) extends Tag(value)
case class Pending(override val value: String = Pending) extends Tag(value)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, we need to differentiate the special sentinel-value flag from the arbitrary user-comment instances, so I felt that the cleanest way is with types, not string values. If we use a special string value like you suggested, then tags would be coalesced together and then we need to separate them out again, with separate implementations for Java and ScalaJS. Here’s is what the implementations might look like:

              boolean isPending = false;
              ...
                if (tag instanceof PendingTag) {
                  if (tag.value().equals("Pending")) {
                    isPending = true;
                  }
                  else {
                    builder.append(" ");
                    builder.append(tag.value());
                  }
                }
                ...
            if (isPending) {
              builder.insert(0, " PENDING");
            }
      val (isPending, pendingComments) = annotations.collect {
        case pending: PendingTag => pending
      }.partition(_.equals(munit.Pending))
      isPending.distinct.map(_.value.toUpperCase) ++ pendingComments.map(_.value)

This is okay, but somehow these implementations, and their equivalency, seem more unclear to me. So I didn’t push a commit for this.

@@ -325,7 +325,7 @@ class MUnitRunner(val cls: Class[_ <: Suite], newInstance: () => Suite)
catch onError
result.map { _ =>
notifier.fireTestFinished(description)
true
!test.tags(Pending)
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't we ignoring PendingComment here and below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, PendingComment uses Pending (because def pending(comment: String): TestOptions = pending.tag(PendingComment(comment))), so we only need to check for Pending.

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@tgodzik tgodzik merged commit 9099c11 into scalameta:main Oct 10, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants