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:
Nizar Benalla 2025-06-05 11:05:52 +00:00
parent bd08932d5b
commit c5daf89053
3 changed files with 22 additions and 20 deletions

View File

@ -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.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,7 @@
/*
* @test
* @bug 8337109
* @bug 8337109 8349369
* @summary Check Links in the generated documentation
* @library /test/langtools/tools/lib ../../doccheck /test/lib ../../../../tools/tester
* @build DocTester toolbox.TestRunner

View File

@ -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.
*
* 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) {
try {
Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
Files.walkFileTree(directory, new SimpleFileVisitor<>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
if (file.toString().endsWith(".html"))
files.add(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
return FileVisitResult.CONTINUE;
}
});

View File

@ -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.
*
* This code is free software; you can redistribute it and/or modify it
@ -220,20 +220,14 @@ public class LinkChecker implements HtmlChecker {
@Override
public boolean isOK() {
return duplicateIds == 0
&& missingIds == 0
&& missingFiles == 0
&& badSchemes == 0;
return log.noErrors() && (missingFiles == 0);
}
@Override
public void close() {
report();
if (!isOK()) {
throw new RuntimeException(
"LinkChecker encountered errors. Duplicate IDs: "
+ duplicateIds + ", Missing IDs: " + missingIds
+ ", Missing Files: " + missingFiles + ", Bad Schemes: " + badSchemes);
if (!log.noErrors()) {
report();
throw new RuntimeException("LinkChecker encountered errors; see log above.");
}
}
@ -276,6 +270,11 @@ public class LinkChecker implements HtmlChecker {
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()) {
foundReference(line, p, fragment);
}
@ -392,7 +391,7 @@ public class LinkChecker implements HtmlChecker {
void addID(int line, String name) {
if (checked) {
throw new IllegalStateException("Adding ID after file has been");
throw new IllegalStateException("Adding ID after file has been checked");
}
Objects.requireNonNull(name);
IDInfo info = map.computeIfAbsent(name, _ -> new IDInfo());
@ -413,7 +412,9 @@ public class LinkChecker implements HtmlChecker {
if (name != null) {
IDInfo id = map.get(name);
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 {
@ -429,7 +430,8 @@ public class LinkChecker implements HtmlChecker {
map.forEach((name, id) -> {
if (name != null && !id.declared) {
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++;
}