test/tools/javadoc/parser/7091528/T7091528.java

Wed, 14 Nov 2018 10:18:25 -0800

author
diazhou
date
Wed, 14 Nov 2018 10:18:25 -0800
changeset 3762
7909abb85562
parent 2367
1737ad9ac984
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag jdk8u201-b04 for changeset a7f48b9dfb82

jjg@1094 1 /*
ksrini@2281 2 * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
jjg@1094 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jjg@1094 4 *
jjg@1094 5 * This code is free software; you can redistribute it and/or modify it
jjg@1094 6 * under the terms of the GNU General Public License version 2 only, as
jjg@1094 7 * published by the Free Software Foundation.
jjg@1094 8 *
jjg@1094 9 * This code is distributed in the hope that it will be useful, but WITHOUT
jjg@1094 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jjg@1094 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jjg@1094 12 * version 2 for more details (a copy is included in the LICENSE file that
jjg@1094 13 * accompanied this code).
jjg@1094 14 *
jjg@1094 15 * You should have received a copy of the GNU General Public License version
jjg@1094 16 * 2 along with this work; if not, write to the Free Software Foundation,
jjg@1094 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jjg@1094 18 *
jjg@1094 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jjg@1094 20 * or visit www.oracle.com if you need additional information or have any
jjg@1094 21 * questions.
jjg@1094 22 */
jjg@1094 23
jjg@1094 24 /**
jjg@1094 25 * @test
ksrini@2367 26 * @bug 7091528 8029145 8037484
ksrini@2281 27 * @summary ensures javadoc parses unique source files and ignores all class files
jjg@1094 28 * @compile p/C1.java p/q/C2.java
jjg@1094 29 * @run main T7091528
jjg@1094 30 */
jjg@1094 31
jjg@1094 32 import java.io.File;
jjg@1094 33 import java.io.PrintWriter;
jjg@1094 34 import java.io.StringWriter;
jjg@1094 35
jjg@1094 36 public class T7091528 {
jjg@1094 37 public static void main(String... args) {
jjg@1094 38 new T7091528().run();
jjg@1094 39 }
jjg@1094 40 void run() {
jjg@1094 41 File testSrc = new File(System.getProperty("test.src"));
jjg@1094 42 File testClasses = new File(System.getProperty("test.classes"));
ksrini@2281 43 // 7091528, tests if class files are being ignored
ksrini@2281 44 runTest("-d", ".",
jjg@1094 45 "-sourcepath", testClasses + File.pathSeparator + testSrc,
jjg@1094 46 "-subpackages",
ksrini@2281 47 "p");
ksrini@2281 48 // 8029145, tests if unique source files are parsed
ksrini@2281 49 runTest("-d", ".",
ksrini@2281 50 "-sourcepath", testSrc.getAbsolutePath(),
ksrini@2281 51 "-subpackages",
ksrini@2281 52 "p:p.q");
ksrini@2367 53 File testPkgDir = new File(testSrc, "p");
ksrini@2367 54 File testFile = new File(testPkgDir, "C3.java");
ksrini@2367 55 runTest("-d", ".",
ksrini@2367 56 "-sourcepath", testSrc.getAbsolutePath(),
ksrini@2367 57 testFile.getAbsolutePath(),
ksrini@2367 58 "p");
ksrini@2367 59 runTest("-d", ".",
ksrini@2367 60 "-classpath", testSrc.getAbsolutePath(),
ksrini@2367 61 testFile.getAbsolutePath(),
ksrini@2367 62 "p");
jjg@1094 63
ksrini@2281 64 }
ksrini@2281 65 void runTest(String... args) {
jjg@1094 66 StringWriter sw = new StringWriter();
jjg@1094 67 PrintWriter pw = new PrintWriter(sw);
jjg@1094 68 String doclet = com.sun.tools.doclets.standard.Standard.class.getName();
jjg@1094 69 int rc = com.sun.tools.javadoc.Main.execute("javadoc", pw, pw, pw, doclet, args);
jjg@1094 70 pw.close();
jjg@1094 71
jjg@1094 72 String out = sw.toString();
jjg@1094 73 if (!out.isEmpty()) {
jjg@1094 74 System.err.println(out);
jjg@1094 75 }
jjg@1094 76
jjg@1094 77 if (rc != 0)
ksrini@2367 78 throw new Error("javadoc failed: exit code = " + rc);
jjg@1094 79
jjg@1094 80 if (out.matches("(?s).*p/[^ ]+\\.class.*"))
jjg@1094 81 throw new Error("reading .class files");
jjg@1094 82
jjg@1094 83 if (!new File("index.html").exists())
jjg@1094 84 throw new Error("index.html not found");
jjg@1094 85 }
jjg@1094 86 }

mercurial