On Thu, 18 Sep 2025 17:38:15 GMT, Andy Goryachev <ango...@openjdk.org> 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:
> 
>   static

Last batch of comments. Initial testing looks good.

modules/javafx.base/src/test/java/test/com/sun/javafx/binding/SelectBindingTest.java
 line 110:

> 108: 
> 109:     @BeforeAll
> 110:     public static void setUpClass() throws Exception {

Minor: this method previously didn't have `throws Exception` and probably 
doesn't need it.

modules/javafx.base/src/test/java/test/javafx/util/OutputRedirect.java line 161:

> 159:             map((s) -> findException(s)).
> 160:             forEach((c) -> {
> 161:                 if (c != null) {

Minor suggestion: filter for non-null Strings before the `forEach` rather than 
checking for non-null in the `forEach` ?

modules/javafx.base/src/test/java/test/javafx/util/OutputRedirect.java line 181:

> 179:     /// `java.lang.NullPointerException: ...`
> 180:     private static final Pattern EXCEPTION_PATTERN = Pattern.compile(
> 181:         "(?:" +

Looks reasonable to me. :)

-------------

PR Review: https://git.openjdk.org/jfx/pull/1897#pullrequestreview-3241127480
PR Review Comment: https://git.openjdk.org/jfx/pull/1897#discussion_r2360492978
PR Review Comment: https://git.openjdk.org/jfx/pull/1897#discussion_r2360506569
PR Review Comment: https://git.openjdk.org/jfx/pull/1897#discussion_r2360514331

Reply via email to