You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by vl...@apache.org on 2019/08/02 16:44:52 UTC

[jmeter] branch master updated: Normalize end of lines for batch test results

This is an automated email from the ASF dual-hosted git repository.

vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new 8235f61  Normalize end of lines for batch test results
8235f61 is described below

commit 8235f614868589ba03774009d115d04e741d28e0
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Fri Aug 2 19:44:34 2019 +0300

    Normalize end of lines for batch test results
---
 .../org/apache/jmeter/buildtools/batchtest/BatchTest.kt    | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/buildSrc/subprojects/batchtest/src/main/kotlin/org/apache/jmeter/buildtools/batchtest/BatchTest.kt b/buildSrc/subprojects/batchtest/src/main/kotlin/org/apache/jmeter/buildtools/batchtest/BatchTest.kt
index 3a2ad2c..8658bf7 100644
--- a/buildSrc/subprojects/batchtest/src/main/kotlin/org/apache/jmeter/buildtools/batchtest/BatchTest.kt
+++ b/buildSrc/subprojects/batchtest/src/main/kotlin/org/apache/jmeter/buildtools/batchtest/BatchTest.kt
@@ -22,6 +22,7 @@ import org.eclipse.jgit.diff.DiffAlgorithm
 import org.eclipse.jgit.diff.DiffFormatter
 import org.eclipse.jgit.diff.RawText
 import org.eclipse.jgit.diff.RawTextComparator
+import org.eclipse.jgit.util.io.AutoCRLFInputStream
 import org.gradle.api.GradleException
 import org.gradle.api.model.ObjectFactory
 import org.gradle.api.tasks.*
@@ -128,12 +129,15 @@ open class BatchTest @Inject constructor(objects: ObjectFactory) : JavaExec() {
         project.delete(csvFile, xmlFile, logFile, jtlFile, errFile)
     }
 
+    private fun File.readAsCrLf() =
+        inputStream().use { AutoCRLFInputStream(it, false).readBytes() }
+
     fun compareFiles(summary: MutableList<String>, actualFile: File): Boolean {
-        val actual = actualFile.readText()
+        val actual = actualFile.readAsCrLf()
         val fileName = actualFile.name
         val expectedFile = inputDirectory.file(fileName).get().asFile
-        val expected = expectedFile.readText()
-        if (expected == actual) {
+        val expected = expectedFile.readAsCrLf()
+        if (expected.contentEquals(actual)) {
             return true
         }
 
@@ -142,8 +146,8 @@ open class BatchTest @Inject constructor(objects: ObjectFactory) : JavaExec() {
         println("  - expected ${expectedFile.length()} bytes, $expectedFile")
         println("  + actual ${actualFile.length()} bytes, $actualFile")
 
-        val e = RawText(expectedFile)
-        val a = RawText(actualFile)
+        val e = RawText(expected)
+        val a = RawText(actual)
         val diffAlgorithm = DiffAlgorithm.getAlgorithm(DiffAlgorithm.SupportedAlgorithm.HISTOGRAM)
         val edits = diffAlgorithm.diff(RawTextComparator.DEFAULT, e, a)
         DiffFormatter(System.out).format(edits, e, a)