tmf: Fix remote.ui test on Windows due to line separators
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Mon, 21 Dec 2015 04:07:49 +0000 (23:07 -0500)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tue, 5 Jan 2016 15:53:58 +0000 (10:53 -0500)
This can happen when core.autocrlf is set to false in the git config.
The file containing an expected string is then not converted to crlf and
since the generated string in the test contains crlf, the comparison
fails.

To make tests consistent everywhere, I suggest to disable the autocrlf
of git directly in the Git repository using .gitattributes, see
http://git-scm.com/docs/gitattributes

And to fix the test on Windows, we can always convert the generated
String to lf line endings.

Change-Id: Ife8912ace7895ebca4d19adb53c6ba169ca2d003
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/63080
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
.gitattributes [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.remote.ui.tests/src/org/eclipse/tracecompass/tmf/remote/ui/tests/fetch/RemoteImportProfilesWriterTest.java

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..cae8cbf
--- /dev/null
@@ -0,0 +1 @@
+*       -text
\ No newline at end of file
index ad3444ead32f6adf3d14a5b2264bb09ee113f308..0d7eccbde4b400dedbb9199903b3d97481c3a66d 100644 (file)
@@ -36,6 +36,7 @@ public class RemoteImportProfilesWriterTest extends
         AbstractRemoteImportProfilesIOTest {
 
     private static final String ENCODING = "UTF-8"; //$NON-NLS-1$
+    private static final String LINE_SEPARATOR_PROPERTY = "line.separator";
 
     /**
      * Test writing a profiles file.
@@ -53,6 +54,12 @@ public class RemoteImportProfilesWriterTest extends
         File expectedFile = getProfilesFile(VALID_PROFILE_PATH);
         String expectedContent = new String(
                 Files.readAllBytes(Paths.get(expectedFile.toURI())), ENCODING);
+
+        // On windows, \r\n will be written to the XML. Replace them with \n for
+        // proper comparison.
+        String sysLineSeparator = System.getProperty(LINE_SEPARATOR_PROPERTY);
+        writtenXML = writtenXML.replace(sysLineSeparator, "\n");
+
         assertEquals(expectedContent, writtenXML);
     }
 
This page took 0.02559 seconds and 5 git commands to generate.