Skip to content

Commit

Permalink
scoverage#171 Migrate ScoveragePlugin from Groovy to Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
eyalroth committed Oct 8, 2021
1 parent 16fc1c6 commit 600cbb0
Show file tree
Hide file tree
Showing 21 changed files with 788 additions and 774 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
`java-gradle-plugin`
`kotlin-dsl`
id("com.gradle.plugin-publish") version "0.15.0"
id("org.jetbrains.gradle.plugin.idea-ext") version "1.0"
kotlin("jvm") version "1.5.31"
id("org.jetbrains.dokka") version "1.5.30"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ public ScalaCrossVersionAggregationTest() {
@Test
public void checkAndAggregateAll() throws Exception {

AssertableBuildResult result = run("clean", ScoveragePlugin.getCHECK_NAME(),
ScoveragePlugin.getAGGREGATE_NAME());

result.assertTaskSkipped(ScoveragePlugin.getREPORT_NAME());
result.assertTaskSucceeded("2_12:" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSucceeded("2_13:" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSucceeded(ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded("2_12:" + ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded("2_13:" + ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded(ScoveragePlugin.getAGGREGATE_NAME());
AssertableBuildResult result = run("clean", ScoveragePlugin.CHECK_NAME,
ScoveragePlugin.AGGREGATE_NAME);

result.assertTaskSkipped(ScoveragePlugin.REPORT_NAME);
result.assertTaskSucceeded("2_12:" + ScoveragePlugin.REPORT_NAME);
result.assertTaskSucceeded("2_13:" + ScoveragePlugin.REPORT_NAME);
result.assertTaskSucceeded(ScoveragePlugin.CHECK_NAME);
result.assertTaskSucceeded("2_12:" + ScoveragePlugin.CHECK_NAME);
result.assertTaskSucceeded("2_13:" + ScoveragePlugin.CHECK_NAME);
result.assertTaskSucceeded(ScoveragePlugin.AGGREGATE_NAME);

assertAggregationFilesExist();
assertCoverage(100.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public ScalaVersionTest(String scalaVersion) {
@Test
public void report() throws Exception {

AssertableBuildResult result = run("clean", ":" + scalaVersion + ":" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSucceeded(scalaVersion + ":" + ScoveragePlugin.getREPORT_NAME());
AssertableBuildResult result = run("clean", ":" + scalaVersion + ":" + ScoveragePlugin.REPORT_NAME);
result.assertTaskSucceeded(scalaVersion + ":" + ScoveragePlugin.REPORT_NAME);

File reportDir = reportDir(projectDir().toPath().resolve(scalaVersion).toFile());
Assert.assertTrue(resolve(reportDir, "index.html").exists());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void buildComposite() {
@Test
public void reportComposite() {

runComposite("clean", ScoveragePlugin.getREPORT_NAME());
runComposite("clean", ScoveragePlugin.REPORT_NAME);
}

private AssertableBuildResult runComposite(String... arguments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public class DetectScalaLibraryTest extends ScoverageFunctionalTest {
@Parameterized.Parameters(name = "{index}: Project {0} ")
public static Collection<Object[]> data() {
Object[][] data = new Object[][]{
{"/compile", new String[] {".0", ".+"}, true, new String[0]},
{"/compileOnly", new String[] {".0", ".+"}, true, new String[0]},
{"/implementation", new String[] {".0", ".+"}, true, new String[0]},
{"/dependency-management", new String[] {".0", ".+"}, true, new String[0]},
{"/compile", new String[]{".0", ".+"}, true, new String[0]},
{"/compileOnly", new String[]{".0", ".+"}, true, new String[0]},
{"/implementation", new String[]{".0", ".+"}, true, new String[0]},
{"/dependency-management", new String[]{".0", ".+"}, true, new String[0]},
// disabled until the consistent-versions plugin supports Gradle 7
// {"/gradle-consistent-versions", new String[] {"ignored"}, false, new String[] {"--write-locks"}},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ public MultiModulePluginNotConfiguredForScalaTest() {
@Test
public void checkAndAggregateScoverage() throws Exception {

AssertableBuildResult result = run("clean", ScoveragePlugin.getCHECK_NAME(),
ScoveragePlugin.getAGGREGATE_NAME());

result.assertTaskSkipped(ScoveragePlugin.getREPORT_NAME());
result.assertTaskSkipped("scala_only:" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSkipped("java_only:" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSkipped(ScoveragePlugin.getCHECK_NAME());
result.assertTaskSkipped("scala_only:" + ScoveragePlugin.getCHECK_NAME());
result.assertTaskSkipped("java_only:" + ScoveragePlugin.getCHECK_NAME());
result.assertTaskSkipped(ScoveragePlugin.getAGGREGATE_NAME());
AssertableBuildResult result = run("clean", ScoveragePlugin.CHECK_NAME,
ScoveragePlugin.AGGREGATE_NAME);

result.assertTaskSkipped(ScoveragePlugin.REPORT_NAME);
result.assertTaskSkipped("scala_only:" + ScoveragePlugin.REPORT_NAME);
result.assertTaskSkipped("java_only:" + ScoveragePlugin.REPORT_NAME);
result.assertTaskSkipped(ScoveragePlugin.CHECK_NAME);
result.assertTaskSkipped("scala_only:" + ScoveragePlugin.CHECK_NAME);
result.assertTaskSkipped("java_only:" + ScoveragePlugin.CHECK_NAME);
result.assertTaskSkipped(ScoveragePlugin.AGGREGATE_NAME);

assertReportDirsEmpty();

Expand Down
23 changes: 16 additions & 7 deletions src/functionalTest/java/org/scoverage/MultipleCheckTasksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ protected void assertOutput(AssertableBuildResult result, CoverageType type, dou

private AssertableBuildResult run() {
if (shouldSucceed) {
return run("clean", ScoveragePlugin.getCHECK_NAME(), "--info");
return run("clean", ScoveragePlugin.CHECK_NAME, "--info");
} else {
return runAndFail(ScoveragePlugin.getCHECK_NAME(), "--info");
return runAndFail(ScoveragePlugin.CHECK_NAME, "--info");
}
}

Expand All @@ -40,52 +40,61 @@ public static class MultipleChecks extends MultipleCheckTasksTest {
public MultipleChecks() {
super("multiple-checks", true);
}

@Override
protected void assertResult(AssertableBuildResult result) {

result.assertTaskSucceeded(ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded(ScoveragePlugin.CHECK_NAME);
assertOutput(result, CoverageType.Line, 0.3);
assertOutput(result, CoverageType.Branch, 0.1);
assertOutput(result, CoverageType.Statement, 0.6);

}
}

public static class SingleCheckNewSyntax extends MultipleCheckTasksTest {
public SingleCheckNewSyntax() {
super("single-check-new-syntax", true);
}

@Override
protected void assertResult(AssertableBuildResult result) {
result.assertTaskSucceeded(ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded(ScoveragePlugin.CHECK_NAME);
assertOutput(result, CoverageType.Line, 0.3);
}
}

public static class SingleCheckOldSyntax extends MultipleCheckTasksTest {
public SingleCheckOldSyntax() {
super("single-check-old-syntax", true);
}

@Override
protected void assertResult(AssertableBuildResult result) {
result.assertTaskSucceeded(ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded(ScoveragePlugin.CHECK_NAME);
assertOutput(result, CoverageType.Line, 0.3);
}
}

public static class OldAndNewSyntax extends MultipleCheckTasksTest {
public OldAndNewSyntax() {
super("old-and-new-syntax", false);
}

@Override
protected void assertResult(AssertableBuildResult result) {
}
}

public static class NoCheck extends MultipleCheckTasksTest {
public NoCheck() {
super("no-check", true);
}

@Override
protected void assertResult(AssertableBuildResult result) {
result.assertTaskSucceeded(ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded(ScoveragePlugin.CHECK_NAME);
assertOutput(result, ScoverageExtension.DEFAULT_COVERAGE_TYPE, ScoverageExtension.DEFAULT_MINIMUM_RATE);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ public ScalaJavaAnnotationProcessorTest() {
@Test
public void checkAndAggregateScoverage() throws Exception {

AssertableBuildResult result = run("clean", ScoveragePlugin.getCHECK_NAME(),
ScoveragePlugin.getAGGREGATE_NAME());
AssertableBuildResult result = run("clean", ScoveragePlugin.CHECK_NAME,
ScoveragePlugin.AGGREGATE_NAME);

result.assertTaskSkipped("java_only:" + ScoveragePlugin.getCOMPILE_NAME());
result.assertTaskSkipped("java_only:" + ScoveragePlugin.COMPILE_NAME);

result.assertTaskSkipped(ScoveragePlugin.getREPORT_NAME());
result.assertTaskSucceeded("mixed_scala_java:" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSkipped("java_only:" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSkipped(ScoveragePlugin.REPORT_NAME);
result.assertTaskSucceeded("mixed_scala_java:" + ScoveragePlugin.REPORT_NAME);
result.assertTaskSkipped("java_only:" + ScoveragePlugin.REPORT_NAME);

result.assertTaskSucceeded(ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded("mixed_scala_java:" + ScoveragePlugin.getCHECK_NAME());
result.assertTaskSkipped("java_only:" + ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded(ScoveragePlugin.CHECK_NAME);
result.assertTaskSucceeded("mixed_scala_java:" + ScoveragePlugin.CHECK_NAME);
result.assertTaskSkipped("java_only:" + ScoveragePlugin.CHECK_NAME);

result.assertTaskSucceeded(ScoveragePlugin.getAGGREGATE_NAME());
result.assertTaskSucceeded(ScoveragePlugin.AGGREGATE_NAME);

assertAllReportFilesExist();
assertCoverage(100.0);
Expand Down
24 changes: 12 additions & 12 deletions src/functionalTest/java/org/scoverage/ScalaJavaMultiModuleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ public ScalaJavaMultiModuleTest() {
@Test
public void checkAndAggregateScoverage() throws Exception {

AssertableBuildResult result = run("clean", ScoveragePlugin.getCHECK_NAME(),
ScoveragePlugin.getAGGREGATE_NAME());
AssertableBuildResult result = run("clean", ScoveragePlugin.CHECK_NAME,
ScoveragePlugin.AGGREGATE_NAME);

result.assertTaskSkipped("java_only:" + ScoveragePlugin.getCOMPILE_NAME());
result.assertTaskSkipped("java_only:" + ScoveragePlugin.COMPILE_NAME);

result.assertTaskSkipped(ScoveragePlugin.getREPORT_NAME());
result.assertTaskSucceeded("scala_only:" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSucceeded("mixed_scala_java:" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSkipped("java_only:" + ScoveragePlugin.getREPORT_NAME());
result.assertTaskSkipped(ScoveragePlugin.REPORT_NAME);
result.assertTaskSucceeded("scala_only:" + ScoveragePlugin.REPORT_NAME);
result.assertTaskSucceeded("mixed_scala_java:" + ScoveragePlugin.REPORT_NAME);
result.assertTaskSkipped("java_only:" + ScoveragePlugin.REPORT_NAME);

result.assertTaskSucceeded(ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded("scala_only:" + ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded("mixed_scala_java:" + ScoveragePlugin.getCHECK_NAME());
result.assertTaskSkipped("java_only:" + ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded(ScoveragePlugin.CHECK_NAME);
result.assertTaskSucceeded("scala_only:" + ScoveragePlugin.CHECK_NAME);
result.assertTaskSucceeded("mixed_scala_java:" + ScoveragePlugin.CHECK_NAME);
result.assertTaskSkipped("java_only:" + ScoveragePlugin.CHECK_NAME);

result.assertTaskSucceeded(ScoveragePlugin.getAGGREGATE_NAME());
result.assertTaskSucceeded(ScoveragePlugin.AGGREGATE_NAME);

assertAllReportFilesExist();
assertCoverage(100.0);
Expand Down
Loading

0 comments on commit 600cbb0

Please sign in to comment.