Ensured all missing Kolin compiler arguments are handled
This commit is contained in:
parent
b4c8952538
commit
1623b902f9
7 changed files with 197 additions and 33 deletions
|
@ -19,6 +19,9 @@ package rife.bld.extension;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
@ -30,8 +33,10 @@ class CompileKotlinOptionsTest {
|
|||
@Test
|
||||
void argsCollectionTest() {
|
||||
var args = new CompileKotlinOptions()
|
||||
.advancedOptions(List.of("Xoption1", "Xoption2"))
|
||||
.argFile(List.of("arg1.txt", "arg2.txt"))
|
||||
.classpath(List.of("path1", "path2"))
|
||||
.jvmOptions(List.of("option1", "option2"))
|
||||
.noStdLib(false)
|
||||
.optIn(List.of("opt1", "opt2"))
|
||||
.options(List.of("-foo", "-bar"))
|
||||
|
@ -40,19 +45,27 @@ class CompileKotlinOptionsTest {
|
|||
var matches = List.of(
|
||||
"@arg1.txt", "@arg2.txt",
|
||||
"-classpath", "path1:path2",
|
||||
"-Joption1", "-Joption2",
|
||||
"-opt-in", "opt1",
|
||||
"-opt-in", "opt2",
|
||||
"-foo",
|
||||
"-bar",
|
||||
"-script-templates", "temp1,temp2");
|
||||
|
||||
assertThat(args).hasSize(matches.size());
|
||||
|
||||
IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i)));
|
||||
|
||||
"-foo", "-bar",
|
||||
"-script-templates",
|
||||
"temp1,temp2",
|
||||
"-XXoption1", "-XXoption2");
|
||||
|
||||
for (var arg : args) {
|
||||
var found = false;
|
||||
for (var match : matches) {
|
||||
if (match.equals(arg)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertThat(found).as(arg).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void argsTest() {
|
||||
var options = new CompileKotlinOptions()
|
||||
|
@ -93,7 +106,7 @@ class CompileKotlinOptionsTest {
|
|||
"-module-name", "module",
|
||||
"-no-jdk",
|
||||
"-no-reflect",
|
||||
"-no-warn",
|
||||
"-nowarn",
|
||||
"-opt-in", "opt1",
|
||||
"-opt-in", "opt2",
|
||||
"-foo",
|
||||
|
@ -114,4 +127,47 @@ class CompileKotlinOptionsTest {
|
|||
IntStream.range(0, a.size()).forEach(i -> assertThat(a.get(i)).isEqualTo(matches.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkAllParamsTest() throws IOException {
|
||||
var args = Files.readAllLines(Paths.get("src", "test", "resources", "kotlinc-args.txt"));
|
||||
|
||||
assertThat(args).isNotEmpty();
|
||||
|
||||
var params = new CompileKotlinOptions()
|
||||
.advancedOptions("Xoption")
|
||||
.argFile("file")
|
||||
.classpath("classpath")
|
||||
.expression("expression")
|
||||
.jvmOptions("option")
|
||||
.includeRuntime(true)
|
||||
.javaParameters(true)
|
||||
.jdkHome("jdkhome")
|
||||
.jvmTarget(12)
|
||||
.kotlinHome("kotlin")
|
||||
.moduleName("moduleName")
|
||||
.noJdk(true)
|
||||
.noReflect(true)
|
||||
.noStdLib(true)
|
||||
.noWarn(true)
|
||||
.optIn("annotation")
|
||||
.options("option")
|
||||
.path("path")
|
||||
.plugin("id", "option", "value")
|
||||
.progressive(true)
|
||||
.scriptTemplates("template")
|
||||
.verbose(true)
|
||||
.wError(true);
|
||||
|
||||
for (var p : args) {
|
||||
var found = false;
|
||||
for (var a : params.args()) {
|
||||
if (a.startsWith(p)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertThat(found).as(p + " not found.").isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,13 +34,13 @@ class DokkaOperationTest {
|
|||
@Test
|
||||
@SuppressWarnings({"ExtractMethodRecommender", "PMD.AvoidDuplicateLiterals"})
|
||||
void executeConstructProcessCommandListTest() throws IOException {
|
||||
var params = Files.readAllLines(Paths.get("src", "test", "resources", "dokka-args.txt"));
|
||||
var args = Files.readAllLines(Paths.get("src", "test", "resources", "dokka-args.txt"));
|
||||
|
||||
assertThat(params).isNotEmpty();
|
||||
assertThat(args).isNotEmpty();
|
||||
|
||||
var examples = new File("examples");
|
||||
var jsonConf = new File("config.json");
|
||||
var args = new DokkaOperation()
|
||||
var params = new DokkaOperation()
|
||||
.delayTemplateSubstitution(true)
|
||||
.failOnWarning(true)
|
||||
.fromProject(new BaseProjectBlueprint(examples, "com.example", "Example"))
|
||||
|
@ -72,9 +72,9 @@ class DokkaOperationTest {
|
|||
.suppressInheritedMembers(true)
|
||||
.executeConstructProcessCommandList();
|
||||
|
||||
for (var p : params) {
|
||||
for (var p : args) {
|
||||
var found = false;
|
||||
for (var a : args) {
|
||||
for (var a : params) {
|
||||
if (a.startsWith(p)) {
|
||||
found = true;
|
||||
break;
|
||||
|
@ -109,14 +109,14 @@ class DokkaOperationTest {
|
|||
"-suppressInheritedMembers",
|
||||
jsonConf.getAbsolutePath());
|
||||
|
||||
assertThat(args).hasSize(matches.size());
|
||||
assertThat(params).hasSize(matches.size());
|
||||
|
||||
IntStream.range(0, args.size()).forEach(i -> {
|
||||
if (args.get(i).contains(".jar;")) {
|
||||
var jars = args.get(i).split(";");
|
||||
IntStream.range(0, params.size()).forEach(i -> {
|
||||
if (params.get(i).contains(".jar;")) {
|
||||
var jars = params.get(i).split(";");
|
||||
Arrays.stream(jars).forEach(jar -> assertThat(matches.get(i)).as(matches.get(i)).contains(jar));
|
||||
} else {
|
||||
assertThat(args.get(i)).as(args.get(i)).isEqualTo(matches.get(i));
|
||||
assertThat(params.get(i)).as(params.get(i)).isEqualTo(matches.get(i));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue