Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8204355

[Graal] org.graalvm.compiler.debug.test.CSVUtilTest fails on Windows due to improper line separator used

XMLWordPrintable

    • b21

        org.graalvm.compiler.debug.test.CSVUtilTest fails on Windows due to improper line separator used

        org.graalvm.compiler.debug.test.CSVUtilTest$Escape started (1 of 5)
          testEscape['XXX"YYY' to '"XXX\\"YYY"']: Passed 105.9 ms
          testEscape['X\\XX"YYY' to '"X\\\\XX\\"YYY"']: Passed 2.1 ms
        org.graalvm.compiler.debug.test.CSVUtilTest$Escape finished 113.6 ms
        org.graalvm.compiler.debug.test.CSVUtilTest$FormatStringBuilder started (2 of 5)
          testBuildFormatString[ [] to "" ]: Passed 6.5 ms
          testBuildFormatString[ [%s] to "%s" ]: Passed 3.2 ms
          testBuildFormatString[ [%s,%s] to "%s;%s" ]: Passed 3.1 ms
        org.graalvm.compiler.debug.test.CSVUtilTest$FormatStringBuilder finished 16.2 ms
        org.graalvm.compiler.debug.test.CSVUtilTest$Formatter started (3 of 5)
          testFormatter[format='%s;%s' args='XXX,YYY' output='XXX;YYY']: FAILED
        testFormatter[format='%s;%s' args='XXX,YYY' output='XXX;YYY'](org.graalvm.compiler.debug.test.CSVUtilTest$Formatter)
        org.junit.ComparisonFailure: expected:<XXX;YYY[]> but was:<XXX;YYY[
        ]>
        at org.junit.Assert.assertEquals(Assert.java:115)
        at org.junit.Assert.assertEquals(Assert.java:144)
        at org.graalvm.compiler.debug.test.CSVUtilTest$Formatter.testFormatter(CSVUtilTest.java:119)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        The issue is on line 119:
           111 @Test
           112 public void testFormatter() {
           113 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
           114 // call the method under test
           115 CSVUtil.Escape.println(new PrintStream(outputStream), format, toObjectArray(args));
           116 // get the actual string
           117 String printedStream = new String(outputStream.toByteArray(), StandardCharsets.UTF_8);
           118 // remove newline
           119 assertEquals(expected, printedStream.substring(0, printedStream.length() - 1));
           120 }


        System.getProperty("line.separator") or System.lineSeparator() (jdk8+) should be used instead of 1.

        It seems similar issue exists in org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/Util.java as well
        where new line is defined as
         final String newLine = "\n";

              iignatyev Igor Ignatyev (Inactive)
              epavlova Ekaterina Pavlova
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: