Skip to content

Commit ab404ab

Browse files
committed
(WIP)
1 parent e1a91fe commit ab404ab

File tree

6 files changed

+101
-0
lines changed

6 files changed

+101
-0
lines changed

inline-example/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

inline-example/README.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Unfortunately even Ant task can't get data from tests:
2+
3+
----
4+
[ant:jacoco:report] Loading execution data file /Users/evgeny.mandrikov/projects/jacoco/jacoco/example/build/jacoco/test.exec
5+
[ant:jacoco:report] Got org/example/ExampleKt within org/example/ExampleKt
6+
[ant:jacoco:report] Got org/example/ExampleKt within org/example/ExampleKt
7+
[ant:jacoco:report] Got org/example/ExampleKt within org/example/ExampleKt
8+
[ant:jacoco:report] Writing bundle 'main' with 1 classes
9+
[ant:jacoco:report] Got org/example/ExampleKt within org/example/ExampleTests
10+
[ant:jacoco:report] Got org/example/ExampleKt within org/example/ExampleTests
11+
[ant:jacoco:report] Writing bundle 'test' with 1 classes
12+
----
13+
14+
* https://github.com/Kotlin/kotlinx-kover/blob/v0.7.3/kover-gradle-plugin/src/main/kotlin/kotlinx/kover/gradle/plugin/tools/jacoco/JacocoAnt.kt#L48-L55
15+
* https://github.com/gradle/gradle/blob/v8.4.0/subprojects/jacoco/src/main/java/org/gradle/internal/jacoco/AbstractAntJacocoReport.java#L66-L82

inline-example/build.gradle

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
plugins {
2+
id 'org.jetbrains.kotlin.jvm' version '1.9.10'
3+
id 'jacoco'
4+
}
5+
6+
repositories {
7+
mavenLocal()
8+
mavenCentral()
9+
}
10+
11+
dependencies {
12+
testImplementation(platform("org.junit:junit-bom:5.10.0"))
13+
testImplementation("org.junit.jupiter:junit-jupiter")
14+
}
15+
16+
test {
17+
useJUnitPlatform()
18+
}
19+
20+
jacoco {
21+
toolVersion = '0.8.12-SNAPSHOT'
22+
}
23+
24+
task report {
25+
doLast {
26+
// See
27+
// https://docs.gradle.org/current/userguide/ant.html
28+
// https://jacoco.org/jacoco/trunk/doc/ant.html
29+
ant.taskdef(
30+
resource: 'org/jacoco/ant/antlib.xml',
31+
classpath: project.configurations.jacocoAnt.asPath,
32+
uri: 'jacoco'
33+
)
34+
ant.'jacoco:report'() {
35+
html(destdir: 'build/report')
36+
executiondata() {
37+
fileset(file: 'build/jacoco/test.exec')
38+
}
39+
structure(name: 'Example') {
40+
Group(name: 'combined') {
41+
classfiles() { fileset(dir: 'build/classes/kotlin/') }
42+
sourcefiles() { fileset(dir: 'src/main/kotlin/') }
43+
}
44+
Group(name: 'separate') {
45+
Group(name: 'main') {
46+
classfiles() { fileset(dir: 'build/classes/kotlin/main') }
47+
sourcefiles() { fileset(dir: 'src/main/kotlin/') }
48+
}
49+
Group(name: 'test') {
50+
classfiles() { fileset(dir: 'build/classes/kotlin/test') }
51+
sourcefiles() { fileset(dir: 'src/test/kotlin/') }
52+
}
53+
}
54+
}
55+
}
56+
}
57+
}

inline-example/run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
gradle clean build
4+
gradle report --info
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.example;
2+
3+
inline fun inlined() {
4+
}
5+
6+
fun callsite() {
7+
inlined()
8+
}
9+
10+
inline fun inlined2() {
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.example;
2+
3+
import org.junit.jupiter.api.Test
4+
5+
class ExampleTests {
6+
7+
@Test
8+
fun test() {
9+
callsite()
10+
inlined2()
11+
}
12+
13+
}

0 commit comments

Comments
 (0)