jjg@1094: /* ksrini@2281: * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. jjg@1094: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@1094: * jjg@1094: * This code is free software; you can redistribute it and/or modify it jjg@1094: * under the terms of the GNU General Public License version 2 only, as jjg@1094: * published by the Free Software Foundation. jjg@1094: * jjg@1094: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@1094: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@1094: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@1094: * version 2 for more details (a copy is included in the LICENSE file that jjg@1094: * accompanied this code). jjg@1094: * jjg@1094: * You should have received a copy of the GNU General Public License version jjg@1094: * 2 along with this work; if not, write to the Free Software Foundation, jjg@1094: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@1094: * jjg@1094: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jjg@1094: * or visit www.oracle.com if you need additional information or have any jjg@1094: * questions. jjg@1094: */ jjg@1094: jjg@1094: /** jjg@1094: * @test ksrini@2367: * @bug 7091528 8029145 8037484 ksrini@2281: * @summary ensures javadoc parses unique source files and ignores all class files jjg@1094: * @compile p/C1.java p/q/C2.java jjg@1094: * @run main T7091528 jjg@1094: */ jjg@1094: jjg@1094: import java.io.File; jjg@1094: import java.io.PrintWriter; jjg@1094: import java.io.StringWriter; jjg@1094: jjg@1094: public class T7091528 { jjg@1094: public static void main(String... args) { jjg@1094: new T7091528().run(); jjg@1094: } jjg@1094: void run() { jjg@1094: File testSrc = new File(System.getProperty("test.src")); jjg@1094: File testClasses = new File(System.getProperty("test.classes")); ksrini@2281: // 7091528, tests if class files are being ignored ksrini@2281: runTest("-d", ".", jjg@1094: "-sourcepath", testClasses + File.pathSeparator + testSrc, jjg@1094: "-subpackages", ksrini@2281: "p"); ksrini@2281: // 8029145, tests if unique source files are parsed ksrini@2281: runTest("-d", ".", ksrini@2281: "-sourcepath", testSrc.getAbsolutePath(), ksrini@2281: "-subpackages", ksrini@2281: "p:p.q"); ksrini@2367: File testPkgDir = new File(testSrc, "p"); ksrini@2367: File testFile = new File(testPkgDir, "C3.java"); ksrini@2367: runTest("-d", ".", ksrini@2367: "-sourcepath", testSrc.getAbsolutePath(), ksrini@2367: testFile.getAbsolutePath(), ksrini@2367: "p"); ksrini@2367: runTest("-d", ".", ksrini@2367: "-classpath", testSrc.getAbsolutePath(), ksrini@2367: testFile.getAbsolutePath(), ksrini@2367: "p"); jjg@1094: ksrini@2281: } ksrini@2281: void runTest(String... args) { jjg@1094: StringWriter sw = new StringWriter(); jjg@1094: PrintWriter pw = new PrintWriter(sw); jjg@1094: String doclet = com.sun.tools.doclets.standard.Standard.class.getName(); jjg@1094: int rc = com.sun.tools.javadoc.Main.execute("javadoc", pw, pw, pw, doclet, args); jjg@1094: pw.close(); jjg@1094: jjg@1094: String out = sw.toString(); jjg@1094: if (!out.isEmpty()) { jjg@1094: System.err.println(out); jjg@1094: } jjg@1094: jjg@1094: if (rc != 0) ksrini@2367: throw new Error("javadoc failed: exit code = " + rc); jjg@1094: jjg@1094: if (out.matches("(?s).*p/[^ ]+\\.class.*")) jjg@1094: throw new Error("reading .class files"); jjg@1094: jjg@1094: if (!new File("index.html").exists()) jjg@1094: throw new Error("index.html not found"); jjg@1094: } jjg@1094: }