-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve test module detection on Mill 0.11.7+ (#74)
This prepared mill-jacoco to better catch exactly the correct module sources. It especially detects any custom test module and excludes it's coverage data from the reports. Perviously, we only detected test modules by naming conventions, which was rather sloppy. Fix #3 This feature only works when used with Mill 0.11.7 or newer. This is a soft requirement and will checked at runtime. Pull request: #74
- Loading branch information
Showing
10 changed files
with
123 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version = "3.7.13" | ||
version = "3.7.15" | ||
|
||
align.preset = none | ||
align.openParenCallSite = false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// mill plugins under test | ||
import $file.shared | ||
|
||
import de.tobiasroeser.mill.jacoco._ | ||
|
||
import mill._ | ||
import mill.scalalib._ | ||
import mill.define.Command | ||
|
||
object main extends JavaModule { | ||
// no tests in here | ||
object test extends JavaModuleTests with JacocoTestModule with TestModule.Junit4 | ||
// but here | ||
object customTest extends JavaModuleTests with JacocoTestModule with TestModule.Junit4 { | ||
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg( | ||
ivy"com.novocode:junit-interface:0.11", | ||
ivy"junit:junit:4.12" | ||
) | ||
} | ||
} | ||
|
||
def verify(millVersion: String): Command[Unit] = T.command { | ||
val jacocoPath = os.pwd / "out" / "de" / "tobiasroeser" / "mill" / "jacoco" / "Jacoco" / "jacocoReportFull.dest" | ||
val xml = jacocoPath / "jacoco.xml" | ||
assert(os.exists(jacocoPath)) | ||
assert(os.exists(xml)) | ||
val contents = os.read(xml) | ||
assert(contents.contains("""<class name="test/Main" sourcefilename="Main.java">""")) | ||
assert(contents.contains("""<sourcefile name="Main.java">""")) | ||
if (millVersion.startsWith("0.11.") && millVersion.drop(5).takeWhile(_.isDigit).toInt >= 7) { | ||
// this file should be excluded from report, as it belongs to the test sources | ||
assert(!contents.contains("""<class name="test/MainTest" sourcefilename="MainTest.java">""")) | ||
} | ||
() | ||
} |
10 changes: 10 additions & 0 deletions
10
itest/src-0.11+/custom-test/main/customTest/src/test/MainTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package test; | ||
|
||
import org.junit.Test; | ||
|
||
public class MainTest { | ||
@Test | ||
public void testMain() { | ||
Main.main(new String[]{}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package test; | ||
|
||
class Main { | ||
public static void main(String[] args) { | ||
System.out.println("Hello Main!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package test; | ||
|
||
import org.junit.Test; | ||
|
||
public class MainTest { | ||
@Test | ||
public void testMain() { | ||
Main.main(new String[]{}); | ||
} | ||
} |