-
Notifications
You must be signed in to change notification settings - Fork 336
Report logs only on failures in JUnit and ScalaTest #13721
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
base: develop
Are you sure you want to change the base?
Conversation
This change simplifies the existing `MemoryAppender` in order to accomodate for setting up Loggers in both, JUnit and ScalaTest. A `ReportLogsOnFailure` has already been used in LS but not in `runtime-integration-tests`. It also didn't work for logs in engine. Junit implements "logs on failure" via rules.
More tests use the "report logs on failure only" feature.
`trace` level seems more useful now that logs are printed only when necessary.
c636b81 to
25a1f80
Compare
So far we have not experienced ordering issues.
| "-Dtck.inlineVerifierInstrument=false", | ||
| "-Dpolyglot.engine.AllowExperimentalOptions=true" | ||
| ), | ||
| Test / javacOptions += "-implicit:none", |
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.
Not related to this PR but reduces warnings noise.
engine/runtime-integration-tests/src/test/java/org/enso/compiler/test/ExecCompilerTest.java
Show resolved
Hide resolved
engine/runtime-integration-tests/src/test/java/org/enso/compiler/test/StaticAnalysisTest.java
Outdated
Show resolved
Hide resolved
lib/java/test-utils/src/main/java/org/enso/test/utils/ContextUtils.java
Outdated
Show resolved
Hide resolved
lib/java/test-utils/src/main/java/org/enso/test/utils/ContextUtils.java
Outdated
Show resolved
Hide resolved
Akirathan
left a comment
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.
Having another @Rule definition seems like a duplicate on many tests that already have @Rule ContextUtils. Can't the new logging behavior be the default for ContextUtils?
...e/runtime-integration-tests/src/test/java/org/enso/compiler/test/ExecStrictCompilerTest.java
Show resolved
Hide resolved
lib/java/test-utils/src/main/java/org/enso/test/utils/ContextUtils.java
Outdated
Show resolved
Hide resolved
|
I will have another run at all those changed tests and see if I can somehow eliminate the few exceptions that needed manual settings. |
Reduced redundant `logHandler` setup in various places.
Akirathan
left a comment
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.
LGTM in general. Ideally, this behavior should somehow be enforced for all the tests. In a few months, when we all start forgetting to put @Rule ReportLogsOnFailure in our tests, we will be in the same situation and with the same polluted outputs on the CI. Were you able to investigate if it is possible to somehow hook into jUnit or ScalaTest runner?
Quite the contrary. If this rule is not present, no logs would be printed.
Hook into? To do what exactly? |
Can you elaborate? runtime-integration-tests/src/test/resources/application-test.conf specifies that the default appender is MemoryAppender which forwards to console. So if I implement a new test in runtime-integration-tests without any rules, the logs will still be forwarded to the console even if the test is successful, no? And what about tests in other projects? Like project-manager, language-server, etc?
To do the same thing that you have implemented in the new rule - capture all output and only print it if a test failed. |
In non-strict mode errors are being reported as warnings. Should :fingers-crossed: help with CI failures.
No. The forwarding is manually requested. If you want to always see the logs you can change the default appender to console.
Let's take it offline as I'm still missing the point. |
Reading it again, I feel that what you are asking makes sense. I remember that the reason why I didn't do it was because of some logs that could be reported prior to execution of any test cases, in setup. |
Pull Request Description
This change simplifies the existing
MemoryAppenderin order to accommodate for setting up Loggers in both, JUnit and ScalaTest. This change adds support for reporting logs on failures via JUnit'sRules.Made sure that (in most cases) we use
JulHandleras engine's log handler so that logs are appropriately forwarded to slf4j for processing.The functionality stays as before. The only difference is that we now have logs being reported when a test fails.
Closes #13308.
Important Notes
A
ReportLogsOnFailurehas already been used in LS but not inruntime-integration-tests. It also didn't work well with logs in engine.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.