File tree 3 files changed +25
-3
lines changed
main/groovy/org/scoverage
test/groovy/org/scoverage
3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import org.gradle.api.GradleException
5
5
import org.gradle.api.tasks.TaskAction
6
6
7
7
import java.text.DecimalFormat
8
+ import java.text.NumberFormat
8
9
9
10
/**
10
11
* Handles different types of coverage Scoverage can measure.
@@ -71,8 +72,10 @@ class OverallCheckTask extends DefaultTask {
71
72
File reportFile = new File (reportDir ? reportDir : extension. reportDir, coverageType. fileName)
72
73
73
74
try {
74
- def xml = parser. parse(reportFile)
75
- Double overallRate = coverageType. normalize(xml. attribute(coverageType. paramName). toDouble())
75
+ Node xml = parser. parse(reportFile)
76
+ NumberFormat nf = NumberFormat . getInstance(Locale . getDefault());
77
+ Double coverageValue = nf. parse(xml. attribute(coverageType. paramName) as String ). doubleValue();
78
+ Double overallRate = coverageType. normalize(coverageValue)
76
79
def difference = (minimumRate - overallRate)
77
80
78
81
if (difference > 1e-7 ) {
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import org.gradle.tooling.GradleConnector
5
5
import org.hamcrest.core.Is
6
6
import org.junit.Assert
7
7
8
+ import java.text.NumberFormat
9
+
8
10
/**
9
11
* Some utils for easy acceptance testing.
10
12
*/
@@ -38,6 +40,8 @@ class AcceptanceTestUtils {
38
40
protected Double coverage (File reportDir , CoverageType coverageType ) {
39
41
File reportFile = new File (reportDir, coverageType. fileName)
40
42
def xml = parser. parse(reportFile)
41
- xml. attribute(coverageType. paramName). toDouble()
43
+ println (" reportfile path: ${ reportFile.absolutePath} " )
44
+ NumberFormat nf = NumberFormat . getInstance(Locale . getDefault());
45
+ nf. parse(xml. attribute(coverageType. paramName) as String ). doubleValue();
42
46
}
43
47
}
Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ import org.gradle.api.Project
5
5
import org.gradle.testfixtures.ProjectBuilder
6
6
import org.hamcrest.Description
7
7
import org.hamcrest.TypeSafeMatcher
8
+ import org.junit.After
9
+ import org.junit.AfterClass
10
+ import org.junit.Before
11
+ import org.junit.BeforeClass
8
12
import org.junit.Rule
9
13
import org.junit.Test
10
14
import org.junit.rules.ExpectedException
@@ -37,6 +41,17 @@ class CauseMatcher extends TypeSafeMatcher<Throwable> {
37
41
}
38
42
39
43
class OverallCheckTaskTest {
44
+ private static Locale defaultLocale
45
+ @BeforeClass
46
+ public static void setup () {
47
+ defaultLocale = Locale . getDefault()
48
+ Locale . setDefault(Locale . US )
49
+ }
50
+
51
+ @AfterClass
52
+ public static void tearDown () {
53
+ Locale . setDefault(defaultLocale)
54
+ }
40
55
41
56
@Rule
42
57
public ExpectedException expectedException = ExpectedException . none()
You can’t perform that action at this time.
0 commit comments