Skip to content

Commit 468e2c9

Browse files
authored
Merge pull request #323 from AikidoSec/codecov-fix
Load JaCoCo before our agent
2 parents 8b590f7 + 559b933 commit 468e2c9

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test: check_binaries
2727
AIKIDO_LOG_LEVEL="error" AIKIDO_TOKEN="token" ./gradlew test
2828

2929
cov: check_binaries
30-
AIKIDO_LOG_LEVEL="error" AIKIDO_TOKEN="token" ./gradlew test --rerun-tasks -PcoverageRun jacocoTestReport
30+
AIKIDO_LOG_LEVEL="error" AIKIDO_TOKEN="token" ./gradlew test --rerun-tasks -PcoverageRun jacocoTestReport jacocoTestCoverageVerification
3131

3232

3333
# Binaries :

agent_api/build.gradle

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
jacoco {
8-
toolVersion "0.8.12"
8+
toolVersion "0.8.15"
99
reportsDirectory = layout.buildDirectory.dir('jacoco')
1010
}
1111

@@ -46,7 +46,6 @@ dependencies {
4646
test {
4747
jvmArgs '--add-opens', 'java.base/java.util=ALL-UNNAMED'
4848
jvmArgs '--add-opens', 'java.base/java.lang=ALL-UNNAMED'
49-
jvmArgs "-javaagent:${project.rootDir}/dist/agent.jar=mode=daemon-disabled"
5049
jvmArgs '-Dnet.bytebuddy.experimental=true' // Mockito support.
5150

5251
systemProperty 'AIK_agent_dir', "${project.rootDir}/dist"
@@ -64,6 +63,12 @@ test {
6463
jacoco {
6564
enabled = true
6665
}
66+
doFirst {
67+
// JaCoCo starts tracking a class when Java loads it.
68+
// Our agent loads agent_api classes, so JaCoCo must start first.
69+
jvmArgs jacoco.getAsJvmArg(), "-javaagent:${project.rootDir}/dist/agent.jar=mode=daemon-disabled"
70+
jacoco.enabled = false
71+
}
6772
}
6873

6974
jacocoTestReport {
@@ -75,8 +80,20 @@ jacocoTestReport {
7580
dependsOn test
7681
}
7782

83+
jacocoTestCoverageVerification {
84+
violationRules {
85+
rule {
86+
limit {
87+
counter = 'LINE'
88+
minimum = 0.80
89+
}
90+
}
91+
}
92+
dependsOn test
93+
}
94+
7895
shadowJar {
7996
mergeServiceFiles()
8097
manifest {
8198
}
82-
}
99+
}

0 commit comments

Comments
 (0)