test/jdk/tools/launcher/InfoStreams.java
author iignatyev
Fri, 07 Sep 2018 14:01:52 -0700
changeset 51675 b487c1e914d0
parent 49538 707553fcca04
permissions -rw-r--r--
8210112: remove jdk.testlibrary.ProcessTools Reviewed-by: alanb, sspitsyn, jcbeyler
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     1
/*
51675
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 49538
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
42338
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
51675
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 49538
diff changeset
    26
 * @library /test/lib
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 49538
diff changeset
    27
 * @build InfoStreams jdk.test.lib.process.ProcessTools
42338
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
51675
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 49538
diff changeset
    32
import jdk.test.lib.process.ProcessTools;
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 49538
diff changeset
    33
import jdk.test.lib.process.OutputAnalyzer;
42338
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
public class InfoStreams {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    36
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    37
    public static OutputAnalyzer run(String ... opts) throws Exception {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    38
        return ProcessTools.executeTestJava(opts).shouldHaveExitValue(0);
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    39
    }
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
    private static final String
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    42
        java_version = System.getProperty("java.version"),
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    43
        USAGE = "^Usage: java ",
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    44
        VERSION_ERR = "^(java|openjdk) version \"" + java_version + "\"",
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    45
        VERSION_OUT = "^(java|openjdk) " + java_version,
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    46
        FULLVERSION_ERR = "^(java|openjdk) full version \"" + java_version + ".*\"",
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    47
        FULLVERSION_OUT = "^(java|openjdk) " + java_version,
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    48
        NONSTD = ".*These extra options are subject to change";
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    49
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    50
    public static void main(String ... args) throws Exception {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    51
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    52
        String classPath = System.getProperty("java.class.path");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    53
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    54
        run("-help").stderrShouldMatch(USAGE).stdoutShouldNotMatch(USAGE);
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    55
        run("--help").stdoutShouldMatch(USAGE).stderrShouldNotMatch(USAGE);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    56
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    57
        run("-version").stderrShouldMatch(VERSION_ERR)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    58
                       .stdoutShouldNotMatch(VERSION_ERR)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    59
                       .stdoutShouldNotMatch(VERSION_OUT);
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    60
        run("--version").stdoutShouldMatch(VERSION_OUT)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    61
                        .stderrShouldNotMatch(VERSION_OUT)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    62
                        .stderrShouldNotMatch(VERSION_ERR);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    63
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    64
        run("-showversion", "--dry-run", "-cp", classPath, "InfoStreams")
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    65
            .stderrShouldMatch(VERSION_ERR)
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    66
            .stdoutShouldNotMatch(VERSION_ERR)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    67
            .stdoutShouldNotMatch(VERSION_OUT);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    68
        run("--show-version", "--dry-run", "-cp", classPath, "InfoStreams")
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    69
            .stdoutShouldMatch(VERSION_OUT)
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    70
            .stderrShouldNotMatch(VERSION_OUT)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    71
            .stderrShouldNotMatch(VERSION_ERR);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    72
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    73
        run("-fullversion").stderrShouldMatch(FULLVERSION_ERR)
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    74
                           .stdoutShouldNotMatch(FULLVERSION_ERR)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    75
                           .stdoutShouldNotMatch(FULLVERSION_OUT);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    76
        run("--full-version").stdoutShouldMatch(FULLVERSION_OUT)
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    77
                             .stderrShouldNotMatch(FULLVERSION_OUT)
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    78
                             .stderrShouldNotMatch(FULLVERSION_ERR);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    79
49538
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    80
        run("-X").stderrShouldMatch(NONSTD).stdoutShouldNotMatch(NONSTD);
707553fcca04 8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents: 47216
diff changeset
    81
        run("--help-extra").stdoutShouldMatch(NONSTD).stderrShouldNotMatch(NONSTD);
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    82
    }
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    83
}