-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathvalidate.groovy
38 lines (34 loc) · 1.51 KB
/
validate.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def checkModule(logText, module, coverageLog) {
assert new File(basedir, module + "/target/scoverage.xml").exists()
assert new File(basedir, module + "/target/site/scoverage/index.html").exists()
def entry = logText.find {
it.startsWith("scoverage-maven-plugin:") &&
it.contains(":check (default-cli) @ " + module + " ---\n")
}
assert entry != null
assert entry.endsWith(" @ " + module + " ---" + coverageLog + "[INFO] ")
}
try {
// check coverage minima
def logText = (new File(basedir, "build.log")).text.split(/\n\[INFO\] \-\-\- /)
checkModule(logText, "module01",
"""
|[INFO] Coverage is above minimum [100.00% >= 95.00%]: Statement:Total
|[INFO] Coverage is above minimum [100.00% >= 90.00%]: Branch:Total
|""".stripMargin()
)
checkModule(logText, "module02",
"""
|[ERROR] Coverage is below minimum [50.00% < 95.00%]: Statement:Total
|[INFO] Coverage is above minimum [100.00% >= 90.00%]: Branch:Total
|[ERROR] Coverage is below minimum [0.00% < 90.00%]: Statement:Package:pkg02
|[ERROR] Coverage is below minimum [0.00% < 85.00%]: Branch:Package:pkg02
|[ERROR] Coverage is below minimum [0.00% < 85.00%]: Statement:File:HelloService1.scala
|[ERROR] Coverage is below minimum [0.00% < 80.00%]: Branch:File:HelloService1.scala
|""".stripMargin()
)
return true
} catch (Throwable e) {
e.printStackTrace()
return false
}