On Sat, 8 Jun 2024 06:53:21 GMT, Chris Plummer <cjplum...@openjdk.org> wrote:

>> test/lib/jdk/test/lib/process/OutputAnalyzer.java line 187:
>> 
>>> 185:      *             If stderr was not empty
>>> 186:      */
>>> 187:     public OutputAnalyzer 
>>> stderrShouldBeEmptyIgnoreDeprecatedWarnings() {
>> 
>> Maybe this should be renamed to reflect that it is about VM option warnings.
>
> Possibly. It means updating 15 tests. Also need to come up with a new name. 
> Any suggestions?

Hello Chris, given these similary named methods in this class, perhaps we 
should instead just have one single `stderrShouldBeEmptyIgnoring(...)` method 
which takes the messages that should be ignored. Something like:


public static final String VM_WARNING_MSG = ".* VM warning:.*";

public static final String VM_WARNING_DEPRECATED_MSG = ".* VM warning:.* 
deprecated.*";
...

public OutputAnalyzer stderrShouldBeEmptyIgnoring(String ignoreMsg, String... 
additionalIgnoreMsgs) {
    String stdErrContent = getStderr().replaceAll(ignoreMsg + "\\R", "");
    if (additionalIgnoreMsgs != null) {
        for (String additionalIgnore : additionalIgnoreMsgs) {
                stdErrContent = getStderr().replaceAll(additionalIgnore + 
"\\R", "");
        }
    }
    if (!stdErrContent.isEmpty()) {
        reportDiagnosticSummary();
        throw new RuntimeException("stderr was not empty");
    }
    return this;
}


We make those private fields in OutputAnalyzer public and have the caller pass 
them:


oa.stderrShouldBeEmptyIgnoring(OutputAnalyzer.VM_WARNING_DEPRECATED_MSG)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19606#discussion_r1631923540

Reply via email to