Cleaned up tests
This commit is contained in:
parent
6b6057f52e
commit
c8878968ef
4 changed files with 96 additions and 62 deletions
|
@ -48,14 +48,14 @@ public class ExampleBuild extends Project {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// Enable detailed logging for the Kotlin extension
|
// Enable detailed logging for the Kotlin extension
|
||||||
// var level = Level.ALL;
|
var level = Level.ALL;
|
||||||
// var logger = Logger.getLogger("rife.bld.extension");
|
var logger = Logger.getLogger("rife.bld.extension");
|
||||||
// var consoleHandler = new ConsoleHandler();
|
var consoleHandler = new ConsoleHandler();
|
||||||
//
|
|
||||||
// consoleHandler.setLevel(level);
|
consoleHandler.setLevel(level);
|
||||||
// logger.addHandler(consoleHandler);
|
logger.addHandler(consoleHandler);
|
||||||
// logger.setLevel(level);
|
logger.setLevel(level);
|
||||||
// logger.setUseParentHandlers(false);
|
logger.setUseParentHandlers(false);
|
||||||
|
|
||||||
new ExampleBuild().start(args);
|
new ExampleBuild().start(args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,20 @@ import java.util.stream.IntStream;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
class DokkaOperationTest {
|
class DokkaOperationTest {
|
||||||
|
private static final String FILE_1 = "file1";
|
||||||
|
private static final String FILE_2 = "file2";
|
||||||
|
private static final String FILE_3 = "file3";
|
||||||
|
private static final String FILE_4 = "file4";
|
||||||
|
private static final String OPTION_1 = "option1";
|
||||||
|
private static final String OPTION_2 = "option2";
|
||||||
|
private static final String OPTION_3 = "option3";
|
||||||
|
private static final String OPTION_4 = "option4";
|
||||||
|
private static final String PATH_1 = "path1";
|
||||||
|
private static final String PATH_2 = "path2";
|
||||||
|
private static final String PATH_3 = "path3";
|
||||||
|
private static final String PATH_4 = "path4";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings({"PMD.AvoidDuplicateLiterals"})
|
|
||||||
void executeConstructProcessCommandListTest() throws IOException {
|
void executeConstructProcessCommandListTest() throws IOException {
|
||||||
var args = Files.readAllLines(Paths.get("src", "test", "resources", "dokka-args.txt"));
|
var args = Files.readAllLines(Paths.get("src", "test", "resources", "dokka-args.txt"));
|
||||||
|
|
||||||
|
@ -47,15 +59,15 @@ class DokkaOperationTest {
|
||||||
.delayTemplateSubstitution(true)
|
.delayTemplateSubstitution(true)
|
||||||
.failOnWarning(true)
|
.failOnWarning(true)
|
||||||
.fromProject(new BaseProjectBlueprint(examples, "com.example", "Example"))
|
.fromProject(new BaseProjectBlueprint(examples, "com.example", "Example"))
|
||||||
.globalLinks("s", "link")
|
.globalLinks("s", "gLink1")
|
||||||
.globalLinks(Map.of("s2", "link2"))
|
.globalLinks(Map.of("s2", "gLink2"))
|
||||||
.globalPackageOptions("option1", "option2")
|
.globalPackageOptions(OPTION_1, OPTION_2)
|
||||||
.globalPackageOptions(List.of("option3", "option4"))
|
.globalPackageOptions(List.of(OPTION_3, OPTION_4))
|
||||||
.globalSrcLink("link1", "link2")
|
.globalSrcLink("link1", "link2")
|
||||||
.globalSrcLink(List.of("link3", "link4"))
|
.globalSrcLink(List.of("link3", "link4"))
|
||||||
.includes(new File("file1"))
|
.includes(new File(FILE_1))
|
||||||
.includes("file2")
|
.includes(FILE_2)
|
||||||
.includes(List.of(new File("file3"), new File("file4")))
|
.includes(List.of(new File(FILE_3), new File(FILE_4)))
|
||||||
.json(jsonConf)
|
.json(jsonConf)
|
||||||
.loggingLevel(LoggingLevel.DEBUG)
|
.loggingLevel(LoggingLevel.DEBUG)
|
||||||
.moduleName("name")
|
.moduleName("name")
|
||||||
|
@ -66,9 +78,9 @@ class DokkaOperationTest {
|
||||||
.outputFormat(OutputFormat.JAVADOC)
|
.outputFormat(OutputFormat.JAVADOC)
|
||||||
.pluginConfigurations("name", "{\"json\"}")
|
.pluginConfigurations("name", "{\"json\"}")
|
||||||
.pluginConfigurations(Map.of("{\"name2\"}", "json2", "name3}", "{json3"))
|
.pluginConfigurations(Map.of("{\"name2\"}", "json2", "name3}", "{json3"))
|
||||||
.pluginsClasspath(new File("path1"))
|
.pluginsClasspath(new File(PATH_1))
|
||||||
.pluginsClasspath("path2")
|
.pluginsClasspath(PATH_2)
|
||||||
.pluginsClasspath(List.of(new File("path3"), new File("path4")))
|
.pluginsClasspath(List.of(new File(PATH_3), new File(PATH_4)))
|
||||||
.sourceSet(new SourceSet().classpath(
|
.sourceSet(new SourceSet().classpath(
|
||||||
List.of(
|
List.of(
|
||||||
new File("examples/foo.jar"),
|
new File("examples/foo.jar"),
|
||||||
|
@ -104,16 +116,16 @@ class DokkaOperationTest {
|
||||||
path + "/lib/bld/javadoc-plugin-" + dokkaJar + ';' +
|
path + "/lib/bld/javadoc-plugin-" + dokkaJar + ';' +
|
||||||
path + "/lib/bld/korte-jvm-4.0.10.jar;" +
|
path + "/lib/bld/korte-jvm-4.0.10.jar;" +
|
||||||
path + "/lib/bld/kotlin-as-java-plugin-" + dokkaJar + ';' +
|
path + "/lib/bld/kotlin-as-java-plugin-" + dokkaJar + ';' +
|
||||||
TestUtil.localPath("path1", "path2", "path3", "path4"),
|
TestUtils.localPath(PATH_1, PATH_2, PATH_3, PATH_4),
|
||||||
"-sourceSet", "-src " + path + "/src/main/kotlin" + " -classpath " + path + "/foo.jar;"
|
"-sourceSet", "-src " + path + "/src/main/kotlin" + " -classpath " + path + "/foo.jar;"
|
||||||
+ path + "/bar.jar",
|
+ path + "/bar.jar",
|
||||||
"-outputDir", path + "/build",
|
"-outputDir", path + "/build",
|
||||||
"-delayTemplateSubstitution",
|
"-delayTemplateSubstitution",
|
||||||
"-failOnWarning",
|
"-failOnWarning",
|
||||||
"-globalLinks", "s^link^^s2^link2",
|
"-globalLinks", "s^gLink1^^s2^gLink2",
|
||||||
"-globalPackageOptions", "option1;option2;option3;option4",
|
"-globalPackageOptions", OPTION_1 + ';' + OPTION_2 + ';' + OPTION_3 + ';' + OPTION_4,
|
||||||
"-globalSrcLinks_", "link1;link2;link3;link4",
|
"-globalSrcLinks_", "link1;link2;link3;link4",
|
||||||
"-includes", TestUtil.localPath("file1", "file2", "file3", "file4"),
|
"-includes", TestUtils.localPath(FILE_1, FILE_2, FILE_3, FILE_4),
|
||||||
"-loggingLevel", "debug",
|
"-loggingLevel", "debug",
|
||||||
"-moduleName", "name",
|
"-moduleName", "name",
|
||||||
"-moduleVersion", "1.0",
|
"-moduleVersion", "1.0",
|
||||||
|
|
|
@ -23,8 +23,8 @@ import java.util.stream.Collectors;
|
||||||
import static rife.bld.extension.DokkaOperation.SEMICOLON;
|
import static rife.bld.extension.DokkaOperation.SEMICOLON;
|
||||||
|
|
||||||
@SuppressWarnings("PMD.TestClassWithoutTestCases")
|
@SuppressWarnings("PMD.TestClassWithoutTestCases")
|
||||||
public final class TestUtil {
|
public final class TestUtils {
|
||||||
private TestUtil() {
|
private TestUtils() {
|
||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,6 @@ public final class TestUtil {
|
||||||
* @return the local path
|
* @return the local path
|
||||||
*/
|
*/
|
||||||
public static String localPath(String... fileNames) {
|
public static String localPath(String... fileNames) {
|
||||||
return Arrays.stream(fileNames).map(it -> new File(it).getAbsolutePath()).collect(Collectors.joining(SEMICOLON));
|
return Arrays.stream(fileNames).map(f -> new File(f).getAbsolutePath()).collect(Collectors.joining(SEMICOLON));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -27,36 +27,52 @@ import java.util.Map;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static rife.bld.extension.TestUtil.localPath;
|
import static rife.bld.extension.TestUtils.localPath;
|
||||||
|
|
||||||
class SourceSetTest {
|
class SourceSetTest {
|
||||||
public static final String SAMPLES_1 = "samples1";
|
private static final String CLASSPATH_1 = "classpath1";
|
||||||
public static final String SAMPLES_2 = "samples2";
|
private static final String CLASSPATH_2 = "classpath2";
|
||||||
public static final String SUP_1 = "sup1";
|
private static final String INCLUDES_1 = "includes1";
|
||||||
public static final String SUP_2 = "sup2";
|
private static final String INCLUDES_2 = "includes2";
|
||||||
|
private static final String INCLUDES_3 = "includes3";
|
||||||
|
private static final String INCLUDES_4 = "includes4";
|
||||||
|
private static final String OPTION_1 = "option1";
|
||||||
|
private static final String OPTION_2 = "option2";
|
||||||
|
private static final String PATH_1 = "path1";
|
||||||
|
private static final String PATH_2 = "path2";
|
||||||
|
private static final String SAMPLES_1 = "samples1";
|
||||||
|
private static final String SAMPLES_2 = "samples2";
|
||||||
|
private static final String SAMPLES_3 = "samples3";
|
||||||
|
private static final String SRC_1 = "src1";
|
||||||
|
private static final String SRC_2 = "src2";
|
||||||
|
private static final String SRC_3 = "src3";
|
||||||
|
private static final String SRC_4 = "src4";
|
||||||
|
private static final String SUP_1 = "sup1";
|
||||||
|
private static final String SUP_2 = "sup2";
|
||||||
|
private static final String SUP_3 = "sup3";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void sourceSetCollectionsTest() {
|
void sourceSetCollectionsTest() {
|
||||||
var args = new SourceSet()
|
var args = new SourceSet()
|
||||||
.classpath(List.of(new File("path1"), new File("path2")))
|
.classpath(List.of(new File(PATH_1), new File(PATH_2)))
|
||||||
.dependentSourceSets(Map.of("set1", "set2", "set3", "set4"))
|
.dependentSourceSets(Map.of("set1", "set2", "set3", "set4"))
|
||||||
.externalDocumentationLinks(Map.of("link1", "link2", "link3", "link4"))
|
.externalDocumentationLinks(Map.of("link1", "link2", "link3", "link4"))
|
||||||
.perPackageOptions(List.of("option1", "option2"))
|
.perPackageOptions(List.of(OPTION_1, OPTION_2))
|
||||||
.samples(List.of(new File(SAMPLES_1)))
|
.samples(List.of(new File(SAMPLES_1)))
|
||||||
.samples(new File(SAMPLES_2))
|
.samples(new File(SAMPLES_2))
|
||||||
.samples("samples3")
|
.samples(SAMPLES_3)
|
||||||
.suppressedFiles(List.of(new File(SUP_1)))
|
.suppressedFiles(List.of(new File(SUP_1)))
|
||||||
.suppressedFiles(new File(SUP_2))
|
.suppressedFiles(new File(SUP_2))
|
||||||
.suppressedFiles("sup3")
|
.suppressedFiles(SUP_3)
|
||||||
.args();
|
.args();
|
||||||
|
|
||||||
var matches = List.of(
|
var matches = List.of(
|
||||||
"-classpath", localPath("path1", "path2"),
|
"-classpath", localPath(PATH_1, PATH_2),
|
||||||
"-dependentSourceSets", "set1/set2;set3/set4",
|
"-dependentSourceSets", "set1/set2;set3/set4",
|
||||||
"-externalDocumentationLinks", "link3^link4^^link1^link2",
|
"-externalDocumentationLinks", "link3^link4^^link1^link2",
|
||||||
"-perPackageOptions", "option1;option2",
|
"-perPackageOptions", OPTION_1 + ';' + OPTION_2,
|
||||||
"-samples", localPath(SAMPLES_1, SAMPLES_2, "samples3"),
|
"-samples", localPath(SAMPLES_1, SAMPLES_2, SAMPLES_3),
|
||||||
"-suppressedFiles", localPath(SUP_1, SUP_2, "sup3")
|
"-suppressedFiles", localPath(SUP_1, SUP_2, SUP_3)
|
||||||
);
|
);
|
||||||
|
|
||||||
assertThat(args).hasSize(matches.size());
|
assertThat(args).hasSize(matches.size());
|
||||||
|
@ -65,7 +81,12 @@ class SourceSetTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
void sourceSetIntVersionsTest() {
|
||||||
|
var args = new SourceSet().apiVersion(1).languageVersion(2);
|
||||||
|
assertThat(args.args()).containsExactly("-apiVersion", "1", "-languageVersion", "2");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
void sourceSetTest() throws IOException {
|
void sourceSetTest() throws IOException {
|
||||||
var args = Files.readAllLines(Paths.get("src", "test", "resources", "dokka-sourceset-args.txt"));
|
var args = Files.readAllLines(Paths.get("src", "test", "resources", "dokka-sourceset-args.txt"));
|
||||||
|
|
||||||
|
@ -74,32 +95,32 @@ class SourceSetTest {
|
||||||
var sourceSet = new SourceSet()
|
var sourceSet = new SourceSet()
|
||||||
.analysisPlatform(AnalysisPlatform.JVM)
|
.analysisPlatform(AnalysisPlatform.JVM)
|
||||||
.apiVersion("1.0")
|
.apiVersion("1.0")
|
||||||
.classpath("classpath1")
|
.classpath(CLASSPATH_1)
|
||||||
.classpath(new File("classpath2"))
|
.classpath(new File(CLASSPATH_2))
|
||||||
.dependentSourceSets("moduleName", "sourceSetName")
|
.dependentSourceSets("moduleName", "sourceSetName")
|
||||||
.dependentSourceSets("moduleName2", "sourceSetName2")
|
.dependentSourceSets("moduleName2", "sourceSetName2")
|
||||||
.displayName("name")
|
.displayName("name")
|
||||||
.documentedVisibilities(DocumentedVisibility.PACKAGE, DocumentedVisibility.PRIVATE)
|
.documentedVisibilities(DocumentedVisibility.PACKAGE, DocumentedVisibility.PRIVATE)
|
||||||
.externalDocumentationLinks("url1", "packageListUrl1")
|
.externalDocumentationLinks("url1", "packageListUrl1")
|
||||||
.externalDocumentationLinks("url2", "packageListUrl2")
|
.externalDocumentationLinks("url2", "packageListUrl2")
|
||||||
.includes("includes1", "includes2")
|
.includes(INCLUDES_1, INCLUDES_2)
|
||||||
.includes(new File("includes3"))
|
.includes(new File(INCLUDES_3))
|
||||||
.includes(List.of(new File("includes4")))
|
.includes(List.of(new File(INCLUDES_4)))
|
||||||
.jdkVersion(18)
|
.jdkVersion(18)
|
||||||
.languageVersion("2.0")
|
.languageVersion("2.0")
|
||||||
.noJdkLink(true)
|
.noJdkLink(true)
|
||||||
.noSkipEmptyPackages(true)
|
.noSkipEmptyPackages(true)
|
||||||
.noStdlibLink(true)
|
.noStdlibLink(true)
|
||||||
.perPackageOptions("options1", "options2")
|
.perPackageOptions(OPTION_1, OPTION_2)
|
||||||
.reportUndocumented(true)
|
.reportUndocumented(true)
|
||||||
.samples(SAMPLES_1, SAMPLES_2)
|
.samples(SAMPLES_1, SAMPLES_2)
|
||||||
.skipDeprecated(true)
|
.skipDeprecated(true)
|
||||||
.sourceSetName("setName")
|
.sourceSetName("setName")
|
||||||
.src("src1", "src2")
|
.src(SRC_1, SRC_2)
|
||||||
.src(new File("src3"))
|
.src(new File(SRC_3))
|
||||||
.src(List.of(new File("src4")))
|
.src(List.of(new File(SRC_4)))
|
||||||
.srcLink("path1", "remote1", "#suffix1")
|
.srcLink(PATH_1, "remote1", "#suffix1")
|
||||||
.srcLink(new File("path2"), "remote2", "#suffix2")
|
.srcLink(new File(PATH_2), "remote2", "#suffix2")
|
||||||
.suppressedFiles(SUP_1, SUP_2);
|
.suppressedFiles(SUP_1, SUP_2);
|
||||||
|
|
||||||
assertThat(sourceSet.classpath()).as("classpath").hasSize(2);
|
assertThat(sourceSet.classpath()).as("classpath").hasSize(2);
|
||||||
|
@ -129,31 +150,32 @@ class SourceSetTest {
|
||||||
var matches = List.of(
|
var matches = List.of(
|
||||||
"-analysisPlatform", "jvm",
|
"-analysisPlatform", "jvm",
|
||||||
"-apiVersion", "1.0",
|
"-apiVersion", "1.0",
|
||||||
"-classpath", localPath("classpath1", "classpath2"),
|
"-classpath", localPath(CLASSPATH_1, CLASSPATH_2),
|
||||||
"-dependentSourceSets", "moduleName/sourceSetName;moduleName2/sourceSetName2",
|
"-dependentSourceSets", "moduleName/sourceSetName;moduleName2/sourceSetName2",
|
||||||
"-displayName", "name",
|
"-displayName", "name",
|
||||||
"-documentedVisibilities", "package;private",
|
"-documentedVisibilities", "package;private",
|
||||||
"-externalDocumentationLinks", "url1^packageListUrl1^^url2^packageListUrl2",
|
"-externalDocumentationLinks", "url1^packageListUrl1^^url2^packageListUrl2",
|
||||||
"-jdkVersion", "18",
|
"-jdkVersion", "18",
|
||||||
"-includes", localPath("includes1", "includes2", "includes3", "includes4"),
|
"-includes", localPath(INCLUDES_1, INCLUDES_2, INCLUDES_3, INCLUDES_4),
|
||||||
"-languageVersion", "2.0",
|
"-languageVersion", "2.0",
|
||||||
"-noJdkLink", "true",
|
"-noJdkLink",
|
||||||
"-noSkipEmptyPackages", "true",
|
"-noSkipEmptyPackages",
|
||||||
"-noStdlibLink", "true",
|
"-noStdlibLink",
|
||||||
"-reportUndocumented", "true",
|
"-reportUndocumented",
|
||||||
"-perPackageOptions", "options1;options2",
|
"-perPackageOptions", OPTION_1 + ';' + OPTION_2,
|
||||||
"-samples", localPath(SAMPLES_1, SAMPLES_2),
|
"-samples", localPath(SAMPLES_1, SAMPLES_2),
|
||||||
"-skipDeprecated", "true",
|
"-skipDeprecated",
|
||||||
"-src", localPath("src1", "src2", "src3", "src4"),
|
"-src", localPath(SRC_1, SRC_2, SRC_3, SRC_4),
|
||||||
"-srcLink", localPath("path2") + "=remote2#suffix2;path1=remote1#suffix1",
|
"-srcLink", localPath(PATH_2) + "=remote2#suffix2;path1=remote1#suffix1",
|
||||||
"-sourceSetName", "setName",
|
"-sourceSetName", "setName",
|
||||||
|
|
||||||
"-suppressedFiles", localPath(SUP_1, SUP_2));
|
"-suppressedFiles", localPath(SUP_1, SUP_2));
|
||||||
|
|
||||||
assertThat(params).hasSize(matches.size());
|
assertThat(params).hasSize(matches.size());
|
||||||
|
|
||||||
IntStream.range(0, params.size()).forEach(i -> assertThat(params.get(i)).isEqualTo(matches.get(i)));
|
IntStream.range(0, params.size()).forEach(i -> assertThat(params.get(i)).isEqualTo(matches.get(i)));
|
||||||
|
|
||||||
sourceSet.classpath(List.of(new File("classpath1"), new File("classpath2")));
|
sourceSet.classpath(List.of(new File(CLASSPATH_1), new File(CLASSPATH_2)));
|
||||||
|
|
||||||
IntStream.range(0, params.size()).forEach(i -> assertThat(params.get(i)).isEqualTo(matches.get(i)));
|
IntStream.range(0, params.size()).forEach(i -> assertThat(params.get(i)).isEqualTo(matches.get(i)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue