RFR: 8336332: Rework tests to avoid unrelated stderr output [v2]
Andy Goryachev
angorya at openjdk.org
Mon Sep 15 18:16:13 UTC 2025
> This PR removes unrelated `stderr` output in the headful test logs by redirecting it to an in-memory buffer. Exceptions found in the buffer can be checked against the expected list.
>
> In the case when any mismatch is detected, whether the type or the number of exceptions of particular type, the accumulated buffer gets dumped to `stderr` (without failing the test).
>
> ## How To
>
> To redirect stderr and later check the exceptions, surround your code with
>
> `ErrorLoggingUtility.suppressStderr()` and either `ErrorLoggingUtility.checkStderr()` or `ErrorLoggingUtility.checkAndRestoreStderr()`.
>
> To simply undo redirection, without checking, call `ErrorLoggingUtility.restoreStderr()`.
>
> To add the check to all the tests in the file, one can call the above mentioned methods inside `@BeforeEach` and `@AfterEach`.
>
> ## Miscellaneous
>
> For reviewers' convenience, the first commit contains the main change, the second fixes the misspelt name of the utility class, the rest are trivial.
>
> ## Questions
>
> - should we fail the current test with `Assertions.fail()` in case of a mismatch?
Andy Goryachev has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
- Merge remote-tracking branch 'origin/master' into 8336332.failed
- whitespace
- revert intentionally failing test
- 2025
- fixed utility class name
- suppress stderr
-------------
Changes:
- all: https://git.openjdk.org/jfx/pull/1897/files
- new: https://git.openjdk.org/jfx/pull/1897/files/dd43ce99..7b228d42
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jfx&pr=1897&range=01
- incr: https://webrevs.openjdk.org/?repo=jfx&pr=1897&range=00-01
Stats: 121318 lines in 711 files changed: 60981 ins; 23896 del; 36441 mod
Patch: https://git.openjdk.org/jfx/pull/1897.diff
Fetch: git fetch https://git.openjdk.org/jfx.git pull/1897/head:pull/1897
PR: https://git.openjdk.org/jfx/pull/1897
More information about the openjfx-dev
mailing list