test/jdk/tools/launcher/InfoStreams.java
author anazarov
Thu, 05 Apr 2018 17:04:16 -0700
changeset 49538 707553fcca04
parent 47216 71c04702a3d5
child 51675 b487c1e914d0
permissions -rw-r--r--
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings Reviewed-by: ksrini, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     1
/*
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     4
 *
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     8
 *
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    13
 * accompanied this code).
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    14
 *
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    18
 *
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    21
 * questions.
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    22
 */
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    23
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    24
/**
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    25
 * @test
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    26
 * @library /lib/testlibrary
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    27
 * @build InfoStreams jdk.testlibrary.ProcessTools
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    28
 * @run main InfoStreams
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    29
 * @summary Test that informational options use the correct streams
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    30
 */
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    31
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    32
import jdk.testlibrary.ProcessTools;
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    33
import jdk.testlibrary.OutputAnalyzer;
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    34
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    35
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    36
public class InfoStreams {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    37
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    38
    public static OutputAnalyzer run(String ... opts) throws Exception {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    39
        return ProcessTools.executeTestJava(opts).shouldHaveExitValue(0);
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    40
    }
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    41
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    42
    private static final String
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    43
        java_version = System.getProperty("java.version"),
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    44
        USAGE = "^Usage: java ",
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    45
        VERSION_ERR = "^(java|openjdk) version \"" + java_version + "\"",
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    46
        VERSION_OUT = "^(java|openjdk) " + java_version,
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    47
        FULLVERSION_ERR = "^(java|openjdk) full version \"" + java_version + ".*\"",
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    48
        FULLVERSION_OUT = "^(java|openjdk) " + java_version,
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    49
        NONSTD = ".*These extra options are subject to change";
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    50
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    51
    public static void main(String ... args) throws Exception {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    52
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    53
        String classPath = System.getProperty("java.class.path");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    54
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    55
        run("-help").stderrShouldMatch(USAGE).stdoutShouldNotMatch(USAGE);
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    56
        run("--help").stdoutShouldMatch(USAGE).stderrShouldNotMatch(USAGE);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    57
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    58
        run("-version").stderrShouldMatch(VERSION_ERR)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    59
                       .stdoutShouldNotMatch(VERSION_ERR)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    60
                       .stdoutShouldNotMatch(VERSION_OUT);
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    61
        run("--version").stdoutShouldMatch(VERSION_OUT)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    62
                        .stderrShouldNotMatch(VERSION_OUT)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    63
                        .stderrShouldNotMatch(VERSION_ERR);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    64
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    65
        run("-showversion", "--dry-run", "-cp", classPath, "InfoStreams")
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    66
            .stderrShouldMatch(VERSION_ERR)
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    67
            .stdoutShouldNotMatch(VERSION_ERR)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    68
            .stdoutShouldNotMatch(VERSION_OUT);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    69
        run("--show-version", "--dry-run", "-cp", classPath, "InfoStreams")
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    70
            .stdoutShouldMatch(VERSION_OUT)
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    71
            .stderrShouldNotMatch(VERSION_OUT)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    72
            .stderrShouldNotMatch(VERSION_ERR);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    73
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    74
        run("-fullversion").stderrShouldMatch(FULLVERSION_ERR)
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    75
                           .stdoutShouldNotMatch(FULLVERSION_ERR)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    76
                           .stdoutShouldNotMatch(FULLVERSION_OUT);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    77
        run("--full-version").stdoutShouldMatch(FULLVERSION_OUT)
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    78
                             .stderrShouldNotMatch(FULLVERSION_OUT)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    79
                             .stderrShouldNotMatch(FULLVERSION_ERR);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    80
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    81
        run("-X").stderrShouldMatch(NONSTD).stdoutShouldNotMatch(NONSTD);
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    82
        run("--help-extra").stdoutShouldMatch(NONSTD).stderrShouldNotMatch(NONSTD);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    83
    }
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    84
}