changeset 53391:a99bd2570660

8217034: JavadocTester should check for missing files by default Reviewed-by: hannesw
author jjg
date Fri, 18 Jan 2019 11:26:30 -0800
parents 46db9786cd67
children cb7347310fa1
files src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java test/langtools/jdk/javadoc/doclet/testBreakIterator/TestBreakIterator.java test/langtools/jdk/javadoc/doclet/testBreakIterator/pkg/BreakIteratorTest.java test/langtools/jdk/javadoc/doclet/testCopyFiles/packages/p2/doc-files/theme.css test/langtools/jdk/javadoc/doclet/testDocRootInlineTag/TestDocRootInlineTag.java test/langtools/jdk/javadoc/doclet/testDocRootInlineTag/TestDocRootTag.java test/langtools/jdk/javadoc/doclet/testDocRootLink/TestDocRootLink.java test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java test/langtools/jdk/javadoc/doclet/testIndexWithModules/TestIndexWithModules.java test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java test/langtools/jdk/javadoc/doclet/testRelativeLinks/TestRelativeLinks.java test/langtools/jdk/javadoc/lib/javadoc/tester/LinkChecker.java
diffstat 12 files changed, 64 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java	Fri Jan 18 13:49:45 2019 -0500
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java	Fri Jan 18 11:26:30 2019 -0800
@@ -25,6 +25,8 @@
 
 package jdk.javadoc.internal.doclets.formats.html;
 
+import java.util.Collections;
+
 import jdk.javadoc.internal.doclets.formats.html.markup.Head;
 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.DocType;
@@ -78,6 +80,7 @@
         Content htmlComment = contents.newPage;
         Head head = new Head(path, configuration.htmlVersion, configuration.docletVersion)
                 .setTimestamp(true)
+                .setStylesheets(configuration.getMainStylesheet(), Collections.emptyList()) // avoid reference to default stylesheet
                 .addDefaultScript(false);
 
         String title = (configuration.windowtitle.length() > 0)
--- a/test/langtools/jdk/javadoc/doclet/testBreakIterator/TestBreakIterator.java	Fri Jan 18 13:49:45 2019 -0500
+++ b/test/langtools/jdk/javadoc/doclet/testBreakIterator/TestBreakIterator.java	Fri Jan 18 11:26:30 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,9 +65,8 @@
                 "<div class=\"block\">with a block tag</div>");
 
         checkOutput("pkg/BreakIteratorTest.html", true,
-                "<div class=\"block\">Return methods to the specified\n" +
-                " <a href=\"../com/sun/javadoc/package-summary.html#included\">access\n" +
-                " modifier option</a>.</div>");
+                "<div class=\"block\">with an anchor for the\n" +
+                " <a href=\"../index-all.html\">top level index</a>.</div>");
 
         checkOutput("pkg/BreakIteratorTest.html", true,
                 "<div class=\"block\">A constant indicating that the keyLocation is indeterminate\n" +
--- a/test/langtools/jdk/javadoc/doclet/testBreakIterator/pkg/BreakIteratorTest.java	Fri Jan 18 13:49:45 2019 -0500
+++ b/test/langtools/jdk/javadoc/doclet/testBreakIterator/pkg/BreakIteratorTest.java	Fri Jan 18 11:26:30 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,9 +43,8 @@
     public void baz(){}
 
     /**
-     * Return methods to the specified
-     * <a href="{@docRoot}/com/sun/javadoc/package-summary.html#included">access
-     * modifier option</a>.  Second line.
+     * with an anchor for the
+     * <a href="{@docRoot}/index-all.html">top level index</a>.  Second line.
      */
     public void foobar(){}
 
--- a/test/langtools/jdk/javadoc/doclet/testDocRootInlineTag/TestDocRootInlineTag.java	Fri Jan 18 13:49:45 2019 -0500
+++ b/test/langtools/jdk/javadoc/doclet/testDocRootInlineTag/TestDocRootInlineTag.java	Fri Jan 18 11:26:30 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,7 @@
         checkOutput("TestDocRootTag.html", true,
                 "<a href=\"" + uri + "/java/io/File.html?is-external=true\" "
                 + "title=\"class or interface in java.io\" class=\"externalLink\"><code>File</code></a>",
-                "<a href=\"./glossary.html\">glossary</a>",
+                "<a href=\"./index-all.html\">index</a>",
                 "<a href=\"" + uri + "/java/io/File.html?is-external=true\" "
                 + "title=\"class or interface in java.io\" class=\"externalLink\"><code>Second File Link</code></a>",
                 "The value of @docRoot is \"./\"");
--- a/test/langtools/jdk/javadoc/doclet/testDocRootInlineTag/TestDocRootTag.java	Fri Jan 18 13:49:45 2019 -0500
+++ b/test/langtools/jdk/javadoc/doclet/testDocRootInlineTag/TestDocRootTag.java	Fri Jan 18 11:26:30 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /**
  * Here is the use of link: {@link java.io.File File}
- * Here is the use of docRoot: <a href="{@docRoot}/glossary.html">glossary</a>.
+ * Here is the use of docRoot: <a href="{@docRoot}/index-all.html">index</a>.
  * Here is the use of link: {@link java.io.File Second File Link}
  */
 public class TestDocRootTag {}
--- a/test/langtools/jdk/javadoc/doclet/testDocRootLink/TestDocRootLink.java	Fri Jan 18 13:49:45 2019 -0500
+++ b/test/langtools/jdk/javadoc/doclet/testDocRootLink/TestDocRootLink.java	Fri Jan 18 11:26:30 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,14 @@
 
     public static void main(String... args) throws Exception {
         TestDocRootLink tester = new TestDocRootLink();
+
+        // The test files intentionally contain examples of links that should
+        // or should not be affected by the -Xdocrootparent option, and the
+        // results are checked explicitly; so, disable the automatic link
+        // checker to prevent spurious "missing files" errors from some of
+        // these links.
+        tester.setAutomaticCheckLinks(false);
+
         tester.runTests();
     }
 
--- a/test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java	Fri Jan 18 13:49:45 2019 -0500
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java	Fri Jan 18 11:26:30 2019 -0800
@@ -57,6 +57,7 @@
 
     TestHtmlLandmarkRegions() {
         tb = new ToolBox();
+        setAutomaticCheckLinks(false); // @ignore 8217013
     }
 
     @Test
--- a/test/langtools/jdk/javadoc/doclet/testIndexWithModules/TestIndexWithModules.java	Fri Jan 18 13:49:45 2019 -0500
+++ b/test/langtools/jdk/javadoc/doclet/testIndexWithModules/TestIndexWithModules.java	Fri Jan 18 11:26:30 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -83,6 +83,7 @@
     //multiple modules with frames
     @Test
     public void testIndexWithMultipleModules1(Path base) throws Exception {
+        setAutomaticCheckLinks(false); // @ignore 8217013
         Path out = base.resolve("out");
         javadoc("-d", out.toString(),
                 "--module-source-path", src.toString(),
@@ -98,6 +99,7 @@
                 "<a href=\"m1/module-summary.html\">m1</a>",
                 "<a href=\"m3/module-summary.html\">m3</a>",
                 "<a href=\"m4/module-summary.html\">m4</a>");
+        setAutomaticCheckLinks(true); // @ignore 8217013
     }
 
     //multiple modules with out frames
--- a/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java	Fri Jan 18 13:49:45 2019 -0500
+++ b/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java	Fri Jan 18 11:26:30 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -115,6 +115,7 @@
         );
 
         String out1_html4 = "out1-html4";
+        setAutomaticCheckLinks(false); // The example code has toy/bad links
         javadoc("-d", out1_html4,
                 "-source", "8",
                 "-html4",
@@ -134,6 +135,8 @@
                 + "<a href=\"#createTempFile-java.lang.String-java.lang.String-java.io.File-\">"
                 + "<code>createTempFile(prefix,&nbsp;suffix,&nbsp;null)</code></a></code>.</div>");
 
+        setAutomaticCheckLinks(true); // re-enable checks
+
         // Generate the documentation using -linkoffline and a relative path as the first parameter.
         // We will try linking to the docs generated in test 1 with a relative path.
         String out2 = "out2";
@@ -182,6 +185,7 @@
         );
 
         // check multiple linkoffline options
+        setAutomaticCheckLinks(false); // The example code has toy/bad links
         javadoc("-d", "out6",
                 "-sourcepath", testSrc,
                 "-linkoffline", "../copy/out1", "out1",
@@ -200,6 +204,8 @@
                         + "title=\"class or interface in mylib.lang\" class=\"externalLink\">"
                         + "<code>link to mylib.lang.StringBuilderChild</code></a>.</div>\n"
         );
+
+        setAutomaticCheckLinks(true); // re-enable checks
     }
 
     /*
--- a/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java	Fri Jan 18 13:49:45 2019 -0500
+++ b/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java	Fri Jan 18 11:26:30 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4749567 8071982 8175200 8186332 8185371 8182765
+ * @bug      4749567 8071982 8175200 8186332 8185371 8182765 8217034
  * @summary  Test the output for -header, -footer, -nooverview, -nodeprecatedlist, -nonavbar, -notree,
  *           -stylesheetfile, --main-stylesheet, --add-stylesheet options.
  * @author   Bhavesh Patel
--- a/test/langtools/jdk/javadoc/doclet/testRelativeLinks/TestRelativeLinks.java	Fri Jan 18 13:49:45 2019 -0500
+++ b/test/langtools/jdk/javadoc/doclet/testRelativeLinks/TestRelativeLinks.java	Fri Jan 18 11:26:30 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,10 @@
  * @run main TestRelativeLinks
  */
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
 import javadoc.tester.JavadocTester;
 
 public class TestRelativeLinks extends JavadocTester {
@@ -106,5 +110,27 @@
                 "-sourcepath", testSrc,
                 "pkg", "pkg2");
         checkExit(Exit.OK);
+    }
+
+    @Override
+    public void checkLinks() {
+        // since the test uses explicit links to non-existent files,
+        // we create those files to avoid false positive errors from checkLinks
+        touch("pkg/relative-class-link.html");
+        touch("pkg/relative-field-link.html");
+        touch("pkg/relative-method-link.html");
+        touch("pkg/relative-package-link.html");
+        touch("pkg/relative-multi-line-link.html");
+        super.checkLinks();
+    }
+
+    private void touch(String file) {
+        File f = new File(outputDir, file);
+        out.println("touch " + f);
+        try (FileOutputStream fos = new FileOutputStream(f)) {
+        } catch (IOException e) {
+            checking("Touch file");
+            failed("Error creating file: " + e);
+        }
+    }
 }
-}
--- a/test/langtools/jdk/javadoc/lib/javadoc/tester/LinkChecker.java	Fri Jan 18 13:49:45 2019 -0500
+++ b/test/langtools/jdk/javadoc/lib/javadoc/tester/LinkChecker.java	Fri Jan 18 11:26:30 2019 -0800
@@ -72,7 +72,7 @@
             missingFiles.stream()
                     .sorted()
                     .forEach(this::reportMissingFile);
-
+            errors += missingFiles.size();
         }
 
         if (!allURIs.isEmpty()) {