Path: blob/master/test/langtools/jdk/javadoc/tool/parser/7091528/T7091528.java
40984 views
/*1* Copyright (c) 2009, 2016, 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* @modules jdk.javadoc/jdk.javadoc.internal.tool28* @compile p/C1.java p/q/C2.java29* @run main T709152830*/3132import java.io.File;33import java.io.PrintWriter;34import java.io.StringWriter;3536public class T7091528 {37public static void main(String... args) {38new T7091528().run();39}40void run() {41File testSrc = new File(System.getProperty("test.src"));42File testClasses = new File(System.getProperty("test.classes"));43// 7091528, tests if class files are being ignored44runTest("-d", "out-1",45"-sourcepath", testClasses + File.pathSeparator + testSrc,46"-subpackages",47"p");48// 8029145, tests if unique source files are parsed49runTest("-d", "out-2",50"-sourcepath", testSrc.getAbsolutePath(),51"-subpackages",52"p:p.q");53File testPkgDir = new File(testSrc, "p");54File testFile = new File(testPkgDir, "C3.java");55runTest("-d", "out-3",56"-sourcepath", testSrc.getAbsolutePath(),57testFile.getAbsolutePath());58runTest("-d", "out-4",59"-classpath", testSrc.getAbsolutePath(),60testFile.getAbsolutePath());6162}6364String getOutputDir(String... args) {65for (int i = 0; i < args.length; i++) {66if (args[i].equals("-d")) {67i++;68return args[i];69}70}71return ".";72}7374void runTest(String... args) {75String outdirname = getOutputDir(args);76StringWriter sw = new StringWriter();77PrintWriter pw = new PrintWriter(sw);78int rc = jdk.javadoc.internal.tool.Main.execute(args, pw);79pw.close();8081String out = sw.toString();82if (!out.isEmpty()) {83System.err.println(out);84}8586if (rc != 0)87throw new Error("javadoc failed: exit code = " + rc);8889if (out.matches("(?s).*p/[^ ]+\\.class.*"))90throw new Error("reading .class files");9192if (!new File(outdirname, "index.html").exists())93throw new Error("index.html not found");94}95}969798