Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/javadoc/parser/7091528/T7091528.java
38828 views
/*1* Copyright (c) 2009, 2014, 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 7091528 8029145 803748426* @summary ensures javadoc parses unique source files and ignores all class files27* @compile p/C1.java p/q/C2.java28* @run main T709152829*/3031import java.io.File;32import java.io.PrintWriter;33import java.io.StringWriter;3435public class T7091528 {36public static void main(String... args) {37new T7091528().run();38}39void run() {40File testSrc = new File(System.getProperty("test.src"));41File testClasses = new File(System.getProperty("test.classes"));42// 7091528, tests if class files are being ignored43runTest("-d", ".",44"-sourcepath", testClasses + File.pathSeparator + testSrc,45"-subpackages",46"p");47// 8029145, tests if unique source files are parsed48runTest("-d", ".",49"-sourcepath", testSrc.getAbsolutePath(),50"-subpackages",51"p:p.q");52File testPkgDir = new File(testSrc, "p");53File testFile = new File(testPkgDir, "C3.java");54runTest("-d", ".",55"-sourcepath", testSrc.getAbsolutePath(),56testFile.getAbsolutePath(),57"p");58runTest("-d", ".",59"-classpath", testSrc.getAbsolutePath(),60testFile.getAbsolutePath(),61"p");6263}64void runTest(String... args) {65StringWriter sw = new StringWriter();66PrintWriter pw = new PrintWriter(sw);67String doclet = com.sun.tools.doclets.standard.Standard.class.getName();68int rc = com.sun.tools.javadoc.Main.execute("javadoc", pw, pw, pw, doclet, args);69pw.close();7071String out = sw.toString();72if (!out.isEmpty()) {73System.err.println(out);74}7576if (rc != 0)77throw new Error("javadoc failed: exit code = " + rc);7879if (out.matches("(?s).*p/[^ ]+\\.class.*"))80throw new Error("reading .class files");8182if (!new File("index.html").exists())83throw new Error("index.html not found");84}85}868788