bazelbuild / rules_scala

Scala rules for Bazel
Apache License 2.0
363 stars 275 forks source link

Unreadable test result #1581

Open evis opened 4 months ago

evis commented 4 months ago

Test result from scalatest in buildbuddy is quite unreadable sometimes.

Screenshots

Screenshot 2024-04-26 at 15 14 50

Test log: build_logs.txt

test.xml from buildbuddy: test.xml.zip

If some more info is needed, tell me please.

Here is a hint on how to fix it: https://github.com/buildbuddy-io/buildbuddy/issues/6453#issuecomment-2112632388

The problematic part from the snippet that Son showed is this part:

<failure 
      message="Unexpected not mocked invocation getLatestResult(car_info {&amp;#010;  mark: &quot;

note that the message is quite verbose and contains entities like &amp;#010; etc.

I don't have a ton of experience with these XML files and hoping other folks can chime in if they have more experience with this, but from reading the XML schema documentation here I think that in normal usage, the message attribute (assert message) is intended for a short summary of the error (a few words), while the text content inside the <failure> tag should contain more details such as the stack trace. It appears that in the XML doc you provided, the same full error message is included in both the message attribute and the text of the tag.

A quick fix that I could think of is to patch rules_scala so that the message attribute will only include the first line of failure.message. That will give you a much more readable error with Junit XML and Bazel (and BuildBuddy).

I think it's from rules_scala with https://github.com/bazelbuild/rules_scala/blob/e2fe29c3b51647ecd07a562917c2c09fb48f9c0a/scala/support/JUnitXmlReporter.scala#L412-L437

could you please open an issue on rules_scala to report this? I think rules_scala maintainers would have more context on how scalatest runner created these events, as well as best practices from other Scala build tools to replicate over.

evis commented 3 months ago

@liucijus could you take a look?

liucijus commented 3 months ago

@evis would you be willing to contribute and test such change?