8349369: test/docs/jdk/javadoc/doccheck/checks/jdkCheckLinks.java did not report on missing man page files
Reviewed-by: hannesw
This commit is contained in:
parent
bd08932d5b
commit
c5daf89053
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8337109
|
* @bug 8337109 8349369
|
||||||
* @summary Check Links in the generated documentation
|
* @summary Check Links in the generated documentation
|
||||||
* @library /test/langtools/tools/lib ../../doccheck /test/lib ../../../../tools/tester
|
* @library /test/langtools/tools/lib ../../doccheck /test/lib ../../../../tools/tester
|
||||||
* @build DocTester toolbox.TestRunner
|
* @build DocTester toolbox.TestRunner
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -44,16 +44,16 @@ public class FileProcessor {
|
|||||||
|
|
||||||
public void processFiles(Path directory) {
|
public void processFiles(Path directory) {
|
||||||
try {
|
try {
|
||||||
Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
|
Files.walkFileTree(directory, new SimpleFileVisitor<>() {
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||||
if (file.toString().endsWith(".html"))
|
if (file.toString().endsWith(".html"))
|
||||||
files.add(file);
|
files.add(file);
|
||||||
return FileVisitResult.CONTINUE;
|
return FileVisitResult.CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
|
public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
|
||||||
return FileVisitResult.CONTINUE;
|
return FileVisitResult.CONTINUE;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -220,20 +220,14 @@ public class LinkChecker implements HtmlChecker {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOK() {
|
public boolean isOK() {
|
||||||
return duplicateIds == 0
|
return log.noErrors() && (missingFiles == 0);
|
||||||
&& missingIds == 0
|
|
||||||
&& missingFiles == 0
|
|
||||||
&& badSchemes == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
report();
|
if (!log.noErrors()) {
|
||||||
if (!isOK()) {
|
report();
|
||||||
throw new RuntimeException(
|
throw new RuntimeException("LinkChecker encountered errors; see log above.");
|
||||||
"LinkChecker encountered errors. Duplicate IDs: "
|
|
||||||
+ duplicateIds + ", Missing IDs: " + missingIds
|
|
||||||
+ ", Missing Files: " + missingFiles + ", Bad Schemes: " + badSchemes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,6 +270,11 @@ public class LinkChecker implements HtmlChecker {
|
|||||||
p = currFile.getParent().resolve(resolvedUriPath).normalize();
|
p = currFile.getParent().resolve(resolvedUriPath).normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Files.exists(p)) {
|
||||||
|
log.log(currFile, line, "missing file reference: " + log.relativize(p));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (fragment != null && !fragment.isEmpty()) {
|
if (fragment != null && !fragment.isEmpty()) {
|
||||||
foundReference(line, p, fragment);
|
foundReference(line, p, fragment);
|
||||||
}
|
}
|
||||||
@ -392,7 +391,7 @@ public class LinkChecker implements HtmlChecker {
|
|||||||
|
|
||||||
void addID(int line, String name) {
|
void addID(int line, String name) {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
throw new IllegalStateException("Adding ID after file has been");
|
throw new IllegalStateException("Adding ID after file has been checked");
|
||||||
}
|
}
|
||||||
Objects.requireNonNull(name);
|
Objects.requireNonNull(name);
|
||||||
IDInfo info = map.computeIfAbsent(name, _ -> new IDInfo());
|
IDInfo info = map.computeIfAbsent(name, _ -> new IDInfo());
|
||||||
@ -413,7 +412,9 @@ public class LinkChecker implements HtmlChecker {
|
|||||||
if (name != null) {
|
if (name != null) {
|
||||||
IDInfo id = map.get(name);
|
IDInfo id = map.get(name);
|
||||||
if (id == null || !id.declared) {
|
if (id == null || !id.declared) {
|
||||||
log.log(log.relativize(from), line, "id not found: " + this.pathOrURI + "#" + name);
|
log.log(log.relativize(from), line,
|
||||||
|
"id not found: " + this.pathOrURI + "#" + name);
|
||||||
|
LinkChecker.this.missingIds++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -429,7 +430,8 @@ public class LinkChecker implements HtmlChecker {
|
|||||||
map.forEach((name, id) -> {
|
map.forEach((name, id) -> {
|
||||||
if (name != null && !id.declared) {
|
if (name != null && !id.declared) {
|
||||||
for (Position ref : id.references) {
|
for (Position ref : id.references) {
|
||||||
log.log(log.relativize(ref.path), ref.line, "id not found: " + this.pathOrURI + "#" + name);
|
log.log(log.relativize(ref.path), ref.line,
|
||||||
|
"id not found: " + this.pathOrURI + "#" + name);
|
||||||
}
|
}
|
||||||
missingIds++;
|
missingIds++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user