Skip to content

Commit

Permalink
Backport 0fb9469d93bffd662848b63792406717f7b4ec0d
Browse files Browse the repository at this point in the history
  • Loading branch information
GoeLin committed Apr 3, 2024
1 parent 9f6b099 commit b687db5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ public void test() {
testSrc("DocTest.java")
);
checkExit(Exit.OK);

// javadoc does not report an exit code for an internal exception (!)
// so monitor stderr for stack dumps.
checkOutput(Output.STDERR, false, "at com.sun");
}

/**
Expand Down
19 changes: 16 additions & 3 deletions test/langtools/jdk/javadoc/lib/javadoc/tester/JavadocTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public enum DirectoryCheck {
NONE(null) { @Override void check(Path dir) { } };

/** The filter used to detect that files should <i>not</i> be present. */
DirectoryStream.Filter<Path> filter;
private final DirectoryStream.Filter<Path> filter;

DirectoryCheck(DirectoryStream.Filter<Path> f) {
filter = f;
Expand Down Expand Up @@ -245,6 +245,7 @@ void check(Path dir) {
private boolean automaticCheckAccessibility = true;
private boolean automaticCheckLinks = true;
private boolean automaticCheckUniqueOUT = true;
private boolean automaticCheckNoStacktrace = true;
private boolean useStandardStreams = false;

/** The current subtest number. Incremented when checking(...) is called. */
Expand Down Expand Up @@ -478,6 +479,11 @@ public void javadoc(String... args) {
}
});

if (automaticCheckNoStacktrace) {
// Any stacktrace will have javadoc near the bottom of the stack
checkOutput(Output.STDERR, false, "at jdk.javadoc/jdk.javadoc.internal.");
}

if (exitCode == Exit.OK.code && Files.exists(outputDir)) {
if (automaticCheckLinks) {
checkLinks();
Expand Down Expand Up @@ -523,6 +529,13 @@ public void setAutomaticCheckUniqueOUT(boolean b) {
automaticCheckUniqueOUT = b;
}

/**
* Sets whether or not to check for stacktraces.
*/
public void setAutomaticCheckNoStacktrace(boolean b) {
automaticCheckNoStacktrace = b;
}

/**
* Sets whether to use standard output streams (stdout and stderr)
* instead of a single temporary stream.
Expand Down Expand Up @@ -1128,7 +1141,7 @@ public OutputChecker setAllowOverlaps(boolean allowOverlaps) {
public OutputChecker check(String... strings) {
if (name == null) {
out.println("Skipping checks for:" + NL
+ List.of(strings).stream()
+ Stream.of(strings)
.map(s -> " " + toShortString(s))
.collect(Collectors.joining(NL)));
return this;
Expand All @@ -1150,7 +1163,7 @@ public OutputChecker check(String... strings) {
public OutputChecker check(Pattern... patterns) {
if (name == null) {
out.println("Skipping checks for:" + NL
+ List.of(patterns).stream()
+ Stream.of(patterns)
.map(p -> " " + toShortString(p.pattern()))
.collect(Collectors.joining(NL)));
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void main(String... args) throws Exception {
tester.setup().runTests();
}

private final List<String> messages = new ArrayList<>();
protected final List<String> messages = new ArrayList<>();
private int testErrors = 0;

/**
Expand Down Expand Up @@ -158,7 +158,7 @@ private void report(String message) {

//-------------------------------------------------

private final ToolBox tb = new ToolBox();
protected final ToolBox tb = new ToolBox();

TestJavadocTester setup() throws IOException {
Path src = Path.of("src");
Expand Down

0 comments on commit b687db5

Please sign in to comment.