test/langtools/jdk/javadoc/tool/OptionSyntaxTest.java
author bobv
Tue, 07 Nov 2017 10:30:53 -0500
changeset 47801 c7b50c23ea71
parent 47216 71c04702a3d5
permissions -rw-r--r--
8190283: Default heap sizing options select a MaxHeapSize larger than available physical memory in some cases Reviewed-by: tschatzl, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
     1
/*
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
     2
 * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
     4
 *
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
     8
 *
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    13
 * accompanied this code).
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    14
 *
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    18
 *
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    21
 * questions.
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    22
 */
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    23
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    24
/*
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    25
 * @test
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    26
 * @bug 8166144
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    27
 * @summary support new-style options
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    28
 * @modules jdk.compiler/com.sun.tools.javac.api
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    29
 * @modules jdk.compiler/com.sun.tools.javac.main
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    30
 * @modules jdk.javadoc/jdk.javadoc.internal.api
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    31
 * @modules jdk.javadoc/jdk.javadoc.internal.tool
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    32
 * @library /tools/lib
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    33
 * @build toolbox.JavacTask toolbox.JavadocTask toolbox.ModuleBuilder toolbox.TestRunner toolbox.ToolBox
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    34
 * @run main OptionSyntaxTest
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    35
 */
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    36
import java.io.IOException;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    37
import java.nio.file.Path;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    38
import java.nio.file.Paths;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    39
import java.util.ArrayList;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    40
import java.util.Arrays;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    41
import java.util.HashSet;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    42
import java.util.List;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    43
import java.util.Locale;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    44
import java.util.Set;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    45
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    46
import javax.lang.model.SourceVersion;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    47
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    48
import jdk.javadoc.doclet.Doclet;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    49
import jdk.javadoc.doclet.DocletEnvironment;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    50
import jdk.javadoc.doclet.Reporter;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    51
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    52
import toolbox.JavadocTask;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    53
import toolbox.ModuleBuilder;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    54
import toolbox.Task;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    55
import toolbox.TestRunner;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    56
import toolbox.ToolBox;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    57
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    58
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    59
public class OptionSyntaxTest extends TestRunner {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    60
    public static class TestDoclet implements Doclet {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    61
        @Override
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    62
        public boolean run(DocletEnvironment root) {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    63
            System.out.println("TestDoclet.run");
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    64
            return true;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    65
        }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    66
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    67
        @Override
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    68
        public String getName() {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    69
            return "Test";
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    70
        }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    71
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    72
        @Override
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    73
        public Set<Option> getSupportedOptions() {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    74
            return options;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    75
        }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    76
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    77
        @Override
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    78
        public SourceVersion getSupportedSourceVersion() {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    79
            return SourceVersion.latest();
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    80
        }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    81
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    82
        @Override
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    83
        public void init(Locale locale, Reporter reporter) {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    84
        }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    85
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    86
        private final Set<Doclet.Option> options = new HashSet<>(Arrays.asList(
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    87
                new DOption("-old", 0),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    88
                new DOption("-oldWithArg", 1),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    89
                new DOption("-oldWithArgs", 2),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    90
                new DOption("--new", 0),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    91
                new DOption("--newWithArg", 1),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    92
                new DOption("--newWithArgs", 2)
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    93
        ));
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    94
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    95
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    96
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    97
    static class DOption implements Doclet.Option {
42277
2668b0bc7ad7 8164316: Refine the Doclet APIs
ksrini
parents: 41252
diff changeset
    98
        private final List<String> names = new ArrayList<>();
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
    99
        private final int argCount;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   100
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   101
        DOption(String name, int argCount) {
42277
2668b0bc7ad7 8164316: Refine the Doclet APIs
ksrini
parents: 41252
diff changeset
   102
            this.names.add(name);
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   103
            this.argCount = argCount;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   104
        }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   105
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   106
        @Override
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   107
        public int getArgumentCount() {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   108
            return argCount;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   109
        }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   110
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   111
        @Override
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   112
        public String getDescription() {
42277
2668b0bc7ad7 8164316: Refine the Doclet APIs
ksrini
parents: 41252
diff changeset
   113
            return "description[" + names.get(0) + "]";
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   114
        }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   115
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   116
        @Override
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   117
        public Kind getKind() {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   118
            return Doclet.Option.Kind.STANDARD;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   119
        }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   120
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   121
        @Override
42277
2668b0bc7ad7 8164316: Refine the Doclet APIs
ksrini
parents: 41252
diff changeset
   122
        public List<String> getNames() {
2668b0bc7ad7 8164316: Refine the Doclet APIs
ksrini
parents: 41252
diff changeset
   123
            return names;
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   124
        }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   125
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   126
        @Override
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   127
        public String getParameters() {
42277
2668b0bc7ad7 8164316: Refine the Doclet APIs
ksrini
parents: 41252
diff changeset
   128
            return argCount > 0 ? "parameters[" + names.get(0) + "," + argCount + "]" : null;
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   129
        }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   130
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   131
        @Override
42277
2668b0bc7ad7 8164316: Refine the Doclet APIs
ksrini
parents: 41252
diff changeset
   132
        public boolean process(String option, List<String> arguments) {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   133
            List<String> args = new ArrayList<>();
42277
2668b0bc7ad7 8164316: Refine the Doclet APIs
ksrini
parents: 41252
diff changeset
   134
            for (int i = 0; i < argCount && i < arguments.size(); i++) {
2668b0bc7ad7 8164316: Refine the Doclet APIs
ksrini
parents: 41252
diff changeset
   135
                args.add(arguments.get(i));
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   136
            }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   137
            System.out.println("process " + option + " " + args);
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   138
            return args.stream().filter(s -> s.startsWith("arg")).count() == argCount;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   139
        }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   140
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   141
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   142
    public static void main(String... args) throws Exception {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   143
        OptionSyntaxTest t = new OptionSyntaxTest();
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   144
        t.runTests();
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   145
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   146
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   147
    private final ToolBox tb = new ToolBox();
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   148
    private final Path src = Paths.get("src");
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   149
    private final Path modules = Paths.get("modules");
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   150
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   151
    OptionSyntaxTest() throws IOException {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   152
        super(System.err);
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   153
        initModules();
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   154
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   155
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   156
    void initModules() throws IOException {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   157
        new ModuleBuilder(tb, "m1")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   158
                .exports("p1")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   159
                .classes("package p1; public class C1 { }")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   160
                .write(src);
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   161
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   162
        new ModuleBuilder(tb, "m2")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   163
                .exports("p2")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   164
                .classes("package p2; public class C2 { }")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   165
                .build(modules);
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   166
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   167
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   168
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   169
    @Test
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   170
    public void testBasic() {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   171
        new JavadocTask(tb, Task.Mode.CMDLINE)
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   172
                .options("-docletpath", System.getProperty("test.classes"),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   173
                       "-doclet", TestDoclet.class.getName(),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   174
                       "-sourcepath", "src/m1",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   175
                       "p1")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   176
                .run()
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   177
                .writeAll();
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   178
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   179
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   180
    @Test
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   181
    public void testNewSourcePath() {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   182
        new JavadocTask(tb, Task.Mode.CMDLINE)
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   183
                .options("-docletpath", System.getProperty("test.classes"),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   184
                       "-doclet", TestDoclet.class.getName(),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   185
                       "--source-path", "src/m1",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   186
                       "p1")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   187
                .run()
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   188
                .writeAll();
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   189
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   190
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   191
    @Test
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   192
    public void testNewSourcePathEquals() {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   193
        new JavadocTask(tb, Task.Mode.CMDLINE)
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   194
                .options("-docletpath", System.getProperty("test.classes"),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   195
                       "-doclet", TestDoclet.class.getName(),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   196
                       "--source-path=src/m1",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   197
                       "p1")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   198
                .run()
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   199
                .writeAll();
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   200
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   201
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   202
    @Test
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   203
    public void testOldDocletArgs() {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   204
        new JavadocTask(tb, Task.Mode.CMDLINE)
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   205
                .options("-docletpath", System.getProperty("test.classes"),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   206
                       "-doclet", TestDoclet.class.getName(),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   207
                       "-sourcepath", "src/m1",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   208
                       "-old",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   209
                       "-oldWithArg", "arg",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   210
                       "-oldWithArgs", "arg1", "arg2",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   211
                       "p1")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   212
                .run()
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   213
                .writeAll();
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   214
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   215
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   216
    @Test
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   217
    public void testNewDocletArgs() {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   218
        new JavadocTask(tb, Task.Mode.CMDLINE)
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   219
                .options("-docletpath", System.getProperty("test.classes"),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   220
                       "-doclet", TestDoclet.class.getName(),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   221
                       "-sourcepath", "src/m1",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   222
                       "--new",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   223
                       "--newWithArg", "arg",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   224
                       "--newWithArgs", "arg1", "arg2",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   225
                       "p1")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   226
                .run()
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   227
                .writeAll();
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   228
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   229
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   230
    @Test
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   231
    public void testNewDocletArgsEquals() {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   232
        new JavadocTask(tb, Task.Mode.CMDLINE)
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   233
                .options("-docletpath", System.getProperty("test.classes"),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   234
                       "-doclet", TestDoclet.class.getName(),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   235
                       "-sourcepath", "src/m1",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   236
                       "--new", "--newWithArg=arg",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   237
                       "p1")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   238
                .run()
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   239
                .writeAll();
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   240
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   241
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   242
    @Test
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   243
    public void testNewDocletArgsMissingArgs() throws Exception {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   244
        String log = new JavadocTask(tb, Task.Mode.CMDLINE)
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   245
                .options("-docletpath", System.getProperty("test.classes"),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   246
                       "-doclet", TestDoclet.class.getName(),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   247
                       "-sourcepath", "src/m1",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   248
                       "--newWithArg")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   249
                .run(Task.Expect.FAIL)
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   250
                .writeAll()
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   251
                .getOutput(Task.OutputKind.DIRECT);
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   252
        if (!log.contains("option --newWithArg requires an argument"))
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   253
            throw new Exception("expected output not found");
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   254
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   255
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   256
    @Test
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   257
    public void testNewDocletArgsExtraArgs() throws Exception {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   258
        String log = new JavadocTask(tb, Task.Mode.CMDLINE)
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   259
                .options("-docletpath", System.getProperty("test.classes"),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   260
                       "-doclet", TestDoclet.class.getName(),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   261
                       "-sourcepath", "src/m1",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   262
                       "--new=arg",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   263
                       "p1")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   264
                .run(Task.Expect.FAIL)
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   265
                .writeAll()
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   266
                .getOutput(Task.OutputKind.DIRECT);
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   267
        if (!log.contains("option --new does not require an argument"))
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   268
            throw new Exception("expected output not found");
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   269
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   270
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   271
    @Test
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   272
    public void testNewDocletArgsExtraArgs2() throws Exception {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   273
        String log = new JavadocTask(tb, Task.Mode.CMDLINE)
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   274
                .options("-docletpath", System.getProperty("test.classes"),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   275
                       "-doclet", TestDoclet.class.getName(),
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   276
                       "-sourcepath", "src/m1",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   277
                       "--newWithArgs=arg1 arg2",
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   278
                       "p1")
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   279
                .run(Task.Expect.FAIL)
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   280
                .writeAll()
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   281
                .getOutput(Task.OutputKind.DIRECT);
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   282
        if (!log.contains("cannot use '=' syntax for options that require multiple arguments"))
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   283
            throw new Exception("expected output not found");
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   284
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   285
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
diff changeset
   286
}