Added test for all parameters

This commit is contained in:
Erik C. Thauvin 2024-05-26 17:59:39 -07:00
parent 61c200ee54
commit 6fa52100ec
Signed by: erik
GPG key ID: 776702A6A2DA330E
4 changed files with 71 additions and 16 deletions

14
.idea/misc.xml generated
View file

@ -3,20 +3,6 @@
<component name="EntryPointsManager"> <component name="EntryPointsManager">
<pattern value="rife.bld.extension.DetektOperationBuild" method="pmd" /> <pattern value="rife.bld.extension.DetektOperationBuild" method="pmd" />
</component> </component>
<component name="PDMPlugin">
<option name="customRuleSets">
<list>
<option value="K:\java\semver\config\pmd.xml" />
<option value="$PROJECT_DIR$/../bld-generated-version/config/pmd.xml" />
<option value="$PROJECT_DIR$/../bld-pitest/config/pmd.xml" />
<option value="$PROJECT_DIR$/../bld-jacoco-report/config/pmd.xml" />
<option value="$PROJECT_DIR$/../bld-checkstyle/config/pmd.xml" />
<option value="$PROJECT_DIR$/../bld-exec/config/pmd.xml" />
<option value="$PROJECT_DIR$/../bld-testng/config/pmd.xml" />
</list>
</option>
<option name="skipTestSources" value="false" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build" /> <output url="file://$PROJECT_DIR$/build" />
</component> </component>

View file

@ -34,7 +34,7 @@ public class DetektOperationBuild extends Project {
public DetektOperationBuild() { public DetektOperationBuild() {
pkg = "rife.bld.extension"; pkg = "rife.bld.extension";
name = "DetektOperation"; name = "DetektOperation";
version = version(0, 9, 4); version = version(0, 9, 5, "SNAPSHOT");
javaRelease = 17; javaRelease = 17;
downloadSources = true; downloadSources = true;

View file

@ -402,7 +402,7 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
// report // report
if (!report_.isEmpty()) { if (!report_.isEmpty()) {
report_.forEach(it -> { report_.forEach(it -> {
args.add("-r"); args.add("--report");
args.add(it.id().name().toLowerCase() + ":" + it.path()); args.add(it.id().name().toLowerCase() + ":" + it.path());
}); });
} }

View file

@ -18,6 +18,7 @@ package rife.bld.extension;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import rife.bld.BaseProject;
import rife.bld.blueprints.BaseProjectBlueprint; import rife.bld.blueprints.BaseProjectBlueprint;
import rife.bld.operations.exceptions.ExitStatusException; import rife.bld.operations.exceptions.ExitStatusException;
@ -57,6 +58,74 @@ class DetektOperationTest {
} }
} }
@Test
void testCheckAllParameters() {
var params = List.of(
"--all-rules",
"--auto-correct",
"--base-path",
"--baseline",
"--build-upon-default-config",
"--classpath",
"--config",
"--config-resource",
"--create-baseline",
"--debug",
"--disable-default-rulesets",
"--excludes",
"--generate-config",
"--includes",
"--input",
"--jdk-home",
"--jvm-target",
"--language-version",
"--max-issues",
"--parallel",
"--plugins",
"--report"
);
var args = new DetektOperation()
.fromProject(new BaseProject())
.allRules(true)
.autoCorrect(true)
.basePath("basePath")
.baseline("baseline")
.buildUponDefaultConfig(true)
.classPath("classpath")
.classPath(List.of("path2", "path3"))
.config("config")
.config(List.of("config2", "config4"))
.configResource("configResource")
.createBaseline(true)
.debug(true)
.disableDefaultRuleSets(true)
.excludes("excludes")
.generateConfig(true)
.includes("patterns")
.input("input")
.jdkHome("jdkHome")
.jvmTarget("jvmTarget")
.languageVersion("languageVersion")
.maxIssues(10)
.parallel(true)
.plugins("jars")
.plugins(List.of("jars2", "jar3"))
.report(new DetektReport(DetektReportId.HTML, "reports"))
.executeConstructProcessCommandList();
for (var p : params) {
var found = false;
for (var a : args) {
if (a.startsWith(p)) {
found = true;
break;
}
}
assertThat(found).as(p + " not found.").isTrue();
}
}
@Test @Test
void testExampleBaseline() throws IOException, ExitStatusException, InterruptedException { void testExampleBaseline() throws IOException, ExitStatusException, InterruptedException {
var tmpDir = Files.createTempDirectory("bld-detekt-").toFile(); var tmpDir = Files.createTempDirectory("bld-detekt-").toFile();