Path: blob/master/test/langtools/jdk/javadoc/tool/6964914/Test.java
40971 views
/*1* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 6964914 818276526* @summary javadoc does not output number of warnings using user written doclet27* @modules jdk.javadoc/jdk.javadoc.internal.tool28*/2930import java.io.*;3132public class Test {33public static void main(String... args) throws Exception {34new Test().run();35}3637public void run() throws Exception {38javadoc("Error.java", "1 error");39javadoc("JavacWarning.java", "1 warning");40javadoc("JavadocWarning.java", "1 warning");41if (errors > 0)42throw new Exception(errors + " errors found");43}4445void javadoc(String path, String expect) {46File testSrc = new File(System.getProperty("test.src"));47String[] args = {48"-Xdoclint:none",49"-source", "8",50"-classpath", ".",51"-package",52new File(testSrc, path).getPath()53};5455StringWriter sw = new StringWriter();56PrintWriter pw = new PrintWriter(sw);57int rc = jdk.javadoc.internal.tool.Main.execute(args, pw);58pw.close();59String out = sw.toString();60if (!out.isEmpty())61System.err.println(out);62System.err.println("javadoc exit: rc=" + rc);6364if (!out.contains(expect))65error("expected text not found: " + expect);66}6768void error(String msg) {69System.err.println("Error: " + msg);70errors++;71}7273int errors;74}757677