RFR: 8336332: Rework tests to avoid unrelated stderr output [v5]
Andy Goryachev
angorya at openjdk.org
Wed Sep 17 23:07:13 UTC 2025
> This PR removes unrelated `stderr` output in the headless 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` and the test fails.
>
> ## How To
>
> To redirect stderr and later check the exceptions, surround your code with
>
> `OutputRedirect.suppressStderr()` and either `OutputRedirect.checkStderr()` or `OutputRedirect.checkAndRestoreStderr()` (ideally, in the `finally` block).
>
> To simply undo redirection, without checking, call `OutputRedirect.restoreStderr()`.
>
> To add the check to all the tests in the file, one can call the above mentioned methods inside `@BeforeEach` and `@AfterEach`.
>
> ## Changes
>
> - added `OutputRedirect` facility
> - fixed ErrorLoggingUtiltity name
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 21 additional commits since the last revision:
- snapshot 1 test
- Merge remote-tracking branch 'origin/master' into 8367567.expected
- expected
- single exit common
- message
- whitespace
- launcher test
- revert add exports
- decouple logging
- test.javafx.util
- ... and 11 more: https://git.openjdk.org/jfx/compare/c381e291...98f60999
-------------
Changes:
- all: https://git.openjdk.org/jfx/pull/1897/files
- new: https://git.openjdk.org/jfx/pull/1897/files/12e0f6a7..98f60999
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jfx&pr=1897&range=04
- incr: https://webrevs.openjdk.org/?repo=jfx&pr=1897&range=03-04
Stats: 23516 lines in 205 files changed: 16622 ins; 2845 del; 4049 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