diff --git a/src/main/groovy/org/scoverage/OverallCheckTask.groovy b/src/main/groovy/org/scoverage/OverallCheckTask.groovy index 1c623ee..3038b38 100644 --- a/src/main/groovy/org/scoverage/OverallCheckTask.groovy +++ b/src/main/groovy/org/scoverage/OverallCheckTask.groovy @@ -5,6 +5,7 @@ import org.gradle.api.GradleException import org.gradle.api.tasks.TaskAction import java.text.DecimalFormat +import java.text.NumberFormat /** * Handles different types of coverage Scoverage can measure. @@ -71,8 +72,10 @@ class OverallCheckTask extends DefaultTask { File reportFile = new File(reportDir ? reportDir : extension.reportDir, coverageType.fileName) try { - def xml = parser.parse(reportFile) - Double overallRate = coverageType.normalize(xml.attribute(coverageType.paramName).toDouble()) + Node xml = parser.parse(reportFile) + NumberFormat nf = NumberFormat.getInstance(Locale.getDefault()); + Double coverageValue = nf.parse(xml.attribute(coverageType.paramName) as String).doubleValue(); + Double overallRate = coverageType.normalize(coverageValue) def difference = (minimumRate - overallRate) if (difference > 1e-7) { diff --git a/src/test/groovy/org/scoverage/AcceptanceTestUtils.groovy b/src/test/groovy/org/scoverage/AcceptanceTestUtils.groovy index 320bfca..dff1f0f 100644 --- a/src/test/groovy/org/scoverage/AcceptanceTestUtils.groovy +++ b/src/test/groovy/org/scoverage/AcceptanceTestUtils.groovy @@ -5,6 +5,8 @@ import org.gradle.tooling.GradleConnector import org.hamcrest.core.Is import org.junit.Assert +import java.text.NumberFormat + /** * Some utils for easy acceptance testing. */ @@ -38,6 +40,8 @@ class AcceptanceTestUtils { protected Double coverage(File reportDir, CoverageType coverageType) { File reportFile = new File(reportDir, coverageType.fileName) def xml = parser.parse(reportFile) - xml.attribute(coverageType.paramName).toDouble() + println("reportfile path: ${reportFile.absolutePath}") + NumberFormat nf = NumberFormat.getInstance(Locale.getDefault()); + nf.parse(xml.attribute(coverageType.paramName) as String).doubleValue(); } } diff --git a/src/test/groovy/org/scoverage/OverallCheckTaskTest.groovy b/src/test/groovy/org/scoverage/OverallCheckTaskTest.groovy index 7daeeb2..5ba4abf 100644 --- a/src/test/groovy/org/scoverage/OverallCheckTaskTest.groovy +++ b/src/test/groovy/org/scoverage/OverallCheckTaskTest.groovy @@ -5,6 +5,10 @@ import org.gradle.api.Project import org.gradle.testfixtures.ProjectBuilder import org.hamcrest.Description import org.hamcrest.TypeSafeMatcher +import org.junit.After +import org.junit.AfterClass +import org.junit.Before +import org.junit.BeforeClass import org.junit.Rule import org.junit.Test import org.junit.rules.ExpectedException @@ -37,6 +41,17 @@ class CauseMatcher extends TypeSafeMatcher { } class OverallCheckTaskTest { + private static Locale defaultLocale + @BeforeClass + public static void setup() { + defaultLocale = Locale.getDefault() + Locale.setDefault(Locale.US) + } + + @AfterClass + public static void tearDown() { + Locale.setDefault(defaultLocale) + } @Rule public ExpectedException expectedException = ExpectedException.none()