mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8217034: JavadocTester should check for missing files by default
Reviewed-by: hannesw
This commit is contained in:
parent
454cbfacaa
commit
c932d8294b
@ -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 @@ public class IndexRedirectWriter extends HtmlDocletWriter {
|
||||
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)
|
||||
|
||||
@ -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 @@ public class TestBreakIterator extends JavadocTester {
|
||||
"<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" +
|
||||
|
||||
@ -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 class BreakIteratorTest {
|
||||
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(){}
|
||||
|
||||
|
||||
@ -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 @@ public class TestDocRootInlineTag extends JavadocTester {
|
||||
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 \"./\"");
|
||||
|
||||
@ -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 {}
|
||||
|
||||
@ -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 class TestDocRootLink extends JavadocTester {
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@ -57,6 +57,7 @@ public class TestHtmlLandmarkRegions extends JavadocTester {
|
||||
|
||||
TestHtmlLandmarkRegions() {
|
||||
tb = new ToolBox();
|
||||
setAutomaticCheckLinks(false); // @ignore 8217013
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -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 @@ public class TestIndexWithModules extends JavadocTester {
|
||||
//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 @@ public class TestIndexWithModules extends JavadocTester {
|
||||
"<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
|
||||
|
||||
@ -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 @@ public class TestLinkOption extends JavadocTester {
|
||||
);
|
||||
|
||||
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 @@ public class TestLinkOption extends JavadocTester {
|
||||
+ "<a href=\"#createTempFile-java.lang.String-java.lang.String-java.io.File-\">"
|
||||
+ "<code>createTempFile(prefix, suffix, 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 @@ public class TestLinkOption extends JavadocTester {
|
||||
);
|
||||
|
||||
// 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 @@ public class TestLinkOption extends JavadocTester {
|
||||
+ "title=\"class or interface in mylib.lang\" class=\"externalLink\">"
|
||||
+ "<code>link to mylib.lang.StringBuilderChild</code></a>.</div>\n"
|
||||
);
|
||||
|
||||
setAutomaticCheckLinks(true); // re-enable checks
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 @@ public class TestRelativeLinks extends JavadocTester {
|
||||
"-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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class LinkChecker extends HtmlChecker {
|
||||
missingFiles.stream()
|
||||
.sorted()
|
||||
.forEach(this::reportMissingFile);
|
||||
|
||||
errors += missingFiles.size();
|
||||
}
|
||||
|
||||
if (!allURIs.isEmpty()) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user