-
Notifications
You must be signed in to change notification settings - Fork 317
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
Suppress logs for test cases unless a failure is reported #8694
Conversation
@@ -1557,9 +1558,6 @@ lazy val runtime = (project in file("engine/runtime")) | |||
}, | |||
Test / parallelExecution := false, | |||
Test / logBuffered := false, | |||
Test / testOptions += Tests.Argument( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has stopped working ever since we provided a global test option for ScalaTest
{ | ||
name = "console" | ||
pattern = "[%level] [%d{yyyy-MM-ddTHH:mm:ssXXX}] [%logger] %msg%n%nopex" | ||
pattern = "[%level] [%d{yyyy-MM-ddTHH:mm:ssXXX}] [%logger] %msg%n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change ensures that we print stacktraces. Since now we only do that on failure this is much more useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the logging works as described in description, then it is a huge step forward.
@@ -19,7 +20,8 @@ class GitSpec | |||
extends AnyWordSpecLike | |||
with Matchers | |||
with Effects | |||
with FlakySpec { | |||
with FlakySpec | |||
with ReportLogsOnFailure { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using mixin is nice solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can still see some unnecessary error logs in the job output:
- https://github.com/enso-org/enso/actions/runs/7424042897/job/20202796504?pr=8694#step:10:4081 In https://github.com/enso-org/enso/blob/48f0c6f5e84a339491d664a705ff605a0c964e10/engine/language-server/src/test/scala/org/enso/languageserver/monitoring/HealthCheckEndpointSpec.scala
- https://github.com/enso-org/enso/actions/runs/7424042897/job/20202796504?pr=8694#step:10:1806 In https://github.com/enso-org/enso/blob/fce6d5dce613e72adde086d59b62bd05a834a838/lib/scala/project-manager/src/test/scala/org/enso/projectmanager/protocol/ProjectManagementApiSpec.scala
- Multiple of those
Would it be possible to also get rid of those, please? Other than that, the job output got much more readable. Thanks for such a quick fix.
Yes, I haven't added the mixin in all the places yet. |
The change adds a convenient trait `ReportLogsOnFailure` that, when merged with the test class, will keep logs in memory and only delegate to the underlying appender on failure. For now we only support forwarding to the console which is sufficient. As a bonus fixed arguments passed to ScalaTest in build.sbt so that we are now, again, showing timings of individual tests.
d62b561
to
5ac856f
Compare
Pull Request Description
The change adds a convenient trait
ReportLogsOnFailure
that, when merged with the test class, will keep logs in memory and only delegate to the underlying appender on failure. For now we only support forwarding to the console which is sufficient.A corresponding entry in
application-test.conf
has to point to the newmemory
appender. The additional complexity in the implementation ensures that if someone forgets to mixinReportLogsOnFailure
logs appear as before i.e. they respect the log level.As a bonus fixed arguments passed to ScalaTest in build.sbt so that we are now, again, showing timings of individual tests.
Closes #8603.
Important Notes
Before:
After:
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.