Skip to content
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

8273544: Increase test coverage for snippets #6359

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -35,9 +35,12 @@
import java.util.stream.Stream;

import javadoc.tester.JavadocTester;
import toolbox.ToolBox;

public class SnippetTester extends JavadocTester {

protected final ToolBox tb = new ToolBox();

protected void checkOrder(Output output, String... strings) {
new OutputChecker(output).setExpectOrdered(true).check(strings);
}
Expand Down Expand Up @@ -87,17 +90,10 @@ protected static void addSnippetFile(Path srcDir, String packageName, String fil
}
}

// TODO: perhaps this method could be added to JavadocTester
protected void checkOutputEither(Output out, String first, String... other) {
checking("checkOutputEither");
String output = getOutput(out);
Stream<String> strings = Stream.concat(Stream.of(first), Stream.of(other));
Optional<String> any = strings.filter(output::contains).findAny();
if (any.isPresent()) {
passed(": following text is found:\n" + any.get());
} else {
failed(": nothing found");
}
var strings = Stream.concat(Stream.of(first), Stream.of(other))
.toArray(String[]::new);
new OutputChecker(out).checkAnyOf(strings);
Comment on lines +94 to +96
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, and is a clever solution for now. Maybe "one of these days" we remove the checkOutputEither method.

}

protected String getSnippetHtmlRepresentation(String pathToHtmlFile,
Expand Down
Expand Up @@ -21,6 +21,18 @@
* questions.
*/

/*
* @test
* @bug 8266666
* @summary Implementation for snippets
* @library /tools/lib ../../lib
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* jdk.javadoc/jdk.javadoc.internal.tool
* @build javadoc.tester.* toolbox.ToolBox toolbox.ModuleBuilder builder.ClassBuilder
* @run main TestSnippetMarkup
*/

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -58,23 +70,8 @@

import static javax.tools.DocumentationTool.Location.DOCUMENTATION_OUTPUT;

/*
* @test
* @bug 8266666
* @summary Implementation for snippets
* @library /tools/lib ../../lib
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* jdk.javadoc/jdk.javadoc.internal.tool
* @build javadoc.tester.* toolbox.ToolBox toolbox.ModuleBuilder builder.ClassBuilder
* @run main TestSnippetMarkup
*/
public class TestSnippetMarkup extends SnippetTester {

private final ToolBox tb = new ToolBox();

private TestSnippetMarkup() {}

public static void main(String... args) throws Exception {
new TestSnippetMarkup().runTests(m -> new Object[]{Paths.get(m.getName())});
}
Expand Down Expand Up @@ -228,7 +225,7 @@ public void testCornerCases(Path base) throws Exception {
* next line.
*/
// @Test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(minor) maybe add // TODO

public void testPositiveInlineExternalTagMarkupNextLine(Path base) throws Exception {
public void testPositiveInlineExternalTagMarkup_NextLine(Path base) throws Exception {
throw new RuntimeException("Not yet implemented");
}

Expand All @@ -237,7 +234,7 @@ public void testPositiveInlineExternalTagMarkupNextLine(Path base) throws Except
* an error occurs.
*/
@Test
public void testNegativeInlineExternalHybridTagMarkupNextLinePutOnLastLine(Path base) throws Exception {
public void testNegativeInlineExternalHybridTagMarkup_NextLinePutOnLastLine(Path base) throws Exception {
Path srcDir = base.resolve("src");
Path outDir = base.resolve("out");
var goodFile = "good.txt";
Expand Down
Expand Up @@ -21,15 +21,6 @@
* questions.
*/

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import toolbox.ToolBox;

/*
* @test
* @bug 8266666
Expand All @@ -41,11 +32,15 @@
* @build javadoc.tester.* toolbox.ToolBox toolbox.ModuleBuilder builder.ClassBuilder
* @run main TestSnippetPathOption
*/
public class TestSnippetPathOption extends SnippetTester {

private final ToolBox tb = new ToolBox();
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Collectors;
import java.util.stream.Stream;

private TestSnippetPathOption() {}
public class TestSnippetPathOption extends SnippetTester {

public static void main(String... args) throws Exception {
new TestSnippetPathOption().runTests(m -> new Object[]{Paths.get(m.getName())});
Expand Down