GateNLP / gate-core

The GATE Embedded core API and GATE Developer application
GNU Lesser General Public License v3.0
78 stars 29 forks source link

Test fails on Windows #117

Closed johann-petrak closed 4 years ago

johann-petrak commented 4 years ago

Trying to build Windows 10 with Java 8:

openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)

This fails with:

Failed tests:   testReadFromURL(gate.creole.TestResourceReference): Length of data read not as expected expected:<98> but was:<104>
  testReadFromURLPlugin(gate.creole.TestResourceReference): Length of data read not as expected expected:<658> but was:<680>

The same happend when I tried to compile with Java 13 as well.

ianroberts commented 4 years ago

This looks to be an encoding issue - the test uses IOUtils.toString(InputStream) which is sensitive to the platform default encoding, we should use the two parameter version and specify a fixed charset.

ianroberts commented 4 years ago

On further investigation I believe it’s actually to do with the way Git by default converts LF to CRLF on text files when you check them out on Windows (i.e. it does by default what subversion used to do only if you opted in with svn:eol-style=native). The fix would be either to turn off that setting for these specific files using .gitattributes or .replace("\r\n", "\n") on the test string before comparing it. Or change what we test for, e.g. check what the file .startsWith instead of how long it is.

johann-petrak commented 4 years ago

Yes. startsWith with a length smaller than the first line or just test for the number of lines in the file as Java properly deals with the various alternatives for line separation on different platforms.

johann-petrak commented 4 years ago

OK, test now checks the number of lines plus the non-whitespace content of the first line. Works on Windows and Linux.