Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/javadoc/6964914/Test.java
38813 views
/*1* Copyright (c) 2010, 2013, 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 696491426* @summary javadoc does not output number of warnings using user written doclet27*/2829import java.io.*;3031public class Test {32public static void main(String... args) throws Exception {33new Test().run();34}3536public void run() throws Exception {37javadoc("Error.java", "1 error");38javadoc("JavacWarning.java", "1 warning");39javadoc("JavadocWarning.java", "1 warning");40if (errors > 0)41throw new Exception(errors + " errors found");42}4344void javadoc(String path, String expect) {45File testSrc = new File(System.getProperty("test.src"));46String[] args = {47"-Xdoclint:none",48"-source", "1.4", // enables certain Parser warnings49"-bootclasspath", System.getProperty("sun.boot.class.path"),50"-classpath", ".",51"-package",52new File(testSrc, path).getPath()53};5455StringWriter sw = new StringWriter();56PrintWriter pw = new PrintWriter(sw);57int rc = com.sun.tools.javadoc.Main.execute(58"javadoc",59pw, pw, pw,60com.sun.tools.doclets.standard.Standard.class.getName(),61args);62pw.close();63String out = sw.toString();64if (!out.isEmpty())65System.err.println(out);66System.err.println("javadoc exit: rc=" + rc);6768if (!out.contains(expect))69error("expected text not found: " + expect);70}7172void error(String msg) {73System.err.println("Error: " + msg);74errors++;75}7677int errors;78}798081