New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JDK-8273154: Provide a JavadocTester method for non-overlapping, unordered output matching #5743
JDK-8273154: Provide a JavadocTester method for non-overlapping, unordered output matching #5743
Conversation
…dered output matching
|
@jonathan-gibbons The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Reviewing the JBS issue, I see I did not address the following, which had been my intent to do so. I will update the PR.
|
Unrelated to this PR. Every time I see these lines in JavadocTester, I cannot help thinking that we could use more specific APIs:
The above lines can be translated into:
I note that neither |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for doing this, Jon. Do you think you could also address closely related JDK-8270836 in this PR? Meanwhile, I'll keep reviewing the code.
test/langtools/jdk/javadoc/lib/javadoc/tester/JavadocTester.java
Outdated
Show resolved
Hide resolved
* Checks for the presence (or absence) of an item. | ||
* | ||
* @param finder a function to find the next occurrence of an item starting at a given position | ||
* @param kind the kind of the item ({@code "text"} or {@code "pattern:} to include in messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param kind the kind of the item ({@code "text"} or {@code "pattern:} to include in messages | |
* @param kind the kind of the item ({@code "text"} or {@code "pattern"}) to include in messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
* @param select if {@code true}, lines that match the pattern will be checked for uniqueness; | ||
* if {@code false}, lines that do not match the pattern will be checked | ||
*/ | ||
public OutputChecker checkUnique(String pattern, boolean select ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public OutputChecker checkUnique(String pattern, boolean select ) { | |
public OutputChecker checkUnique(String pattern, boolean select) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
public OutputChecker checkUnique(String pattern, boolean select ) { | ||
checking("checkUnique"); | ||
Pattern filter = Pattern.compile(pattern); | ||
Matcher m = filter.matcher(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A reusable matcher; nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, not sure it makes much difference, compared to allocating new ones.
I dislike importing |
test/langtools/jdk/javadoc/testJavadocTester/TestJavadocTester.java
Outdated
Show resolved
Hide resolved
test/langtools/jdk/javadoc/testJavadocTester/TestJavadocTester.java
Outdated
Show resolved
Hide resolved
test/langtools/jdk/javadoc/testJavadocTester/TestJavadocTester.java
Outdated
Show resolved
Hide resolved
.map(this::fix) | ||
.toArray(String[]::new); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…nto 8273154.JavadocTester-checker
|
@@ -430,8 +431,8 @@ private String fix(String item) { | |||
* @param items the strings | |||
*/ | |||
private String[] fix(String... items) { | |||
return List.of(items).stream() | |||
return Stream.of(items) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While List.of(items).stream() is not equivalent to Stream.of(items), that fix
method (as a whole) still behaves the same way. One difference between those two approaches of creating an ordered stream is their behavior in regard to the null item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I'm looking forward to using this in testing the snippets feature (JEP 413).
@jonathan-gibbons This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 30 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
|
/integrate |
Going to push as commit ce3ed65.
Your commit was automatically rebased without conflicts. |
@jonathan-gibbons Pushed as commit ce3ed65. |
Please review a moderately simple improvement for
JavadocTester
and a related new test.A new
OutputChecker
class is introduced that mostly supersedes the existing methods to check the output generated by javadoc and the standard doclet. A self-imposed restriction is that no existing tests are modified.The new class can be used to check files generated by the doclet and the streams written by the tool. It can be configured to check for ordered output or not, overlapping output, and complete coverage, and can search for literal strings and regular expressions.
There is a corresponding new test which is a non-standard use of
JavadocTester
, since it is designed to testJavadocTester
itself, and not javadoc or the doclet. (Quis custodiet ipsos custodes?) Various methods are overridden so that the operation of the underlying methods can be checked.Although it is a goal to NOT modify the code of any existing tests, it turns out to be reasonable to adapt some of the existing
check...
methods to use the newOutputChecker
. All javadoc tests pass, both locally and on all standard platforms. Many/most uses of the existingcheckOutput
method provide "ordered" strings, and are candidates to use the new ordered check. But enough uses are not ordered, so it is not reasonable to change the default at this time. It is noted as a TODO to examine the appropriate test cases, so that we can decide whether to fix those tests and change the default.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5743/head:pull/5743
$ git checkout pull/5743
Update a local copy of the PR:
$ git checkout pull/5743
$ git pull https://git.openjdk.java.net/jdk pull/5743/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5743
View PR using the GUI difftool:
$ git pr show -t 5743
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5743.diff