On Thu, 18 Sep 2025 18:50:04 GMT, Andy Goryachev <[email protected]> wrote:
>> 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 >> >> ## Miscellaneous >> >> `ErrorLoggingUtiltity` name will be fixed in a followup >> https://bugs.openjdk.org/browse/JDK-8367995 > > Andy Goryachev has updated the pull request incrementally with one additional > commit since the last revision: > > run and wait Shapshot1Test still fails for me. This time the exceptions are being captured in the print stream, but the parsing of the output reports 2 exceptions instead of the expected 1: Mismatch in thrown exceptions: expected={java.lang.ClassCastException=1} observed={java.lang.ClassCastException=1, Exception=1} tests/system/src/test/java/test/javafx/scene/Snapshot1Test.java line 253: > 251: > 252: assertEquals(0, latch.getCount()); > 253: } finally { Since the ClassCast exception happens after the latch countdown, I recommend a sleep (of, say, 100 msec) after checking that the latch count is 0. tests/system/src/test/java/test/javafx/scene/Snapshot1Test.java line 382: > 380: > 381: assertEquals(0, latch.getCount()); > 382: } finally { Same here: a short sleep after the assertEquals. ------------- PR Review: https://git.openjdk.org/jfx/pull/1897#pullrequestreview-3241971053 PR Review Comment: https://git.openjdk.org/jfx/pull/1897#discussion_r2361081138 PR Review Comment: https://git.openjdk.org/jfx/pull/1897#discussion_r2361083383
