-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[sleepiq] Fix the failing tests on Windows #7983
Conversation
Fix openhab#7981 Signed-off-by: Laurent Garnier <[email protected]>
Please read my comment in the issue, I am not sure that it is the best way to fix the problem with endline encoding. |
Travis tests were successfulHey @lolodomo, |
I just copy pasted the files from the orignal repo. On my machines Git is configured to not automatically convert line endings to my OS default. I think your Git is configured to automatically convert line endings? That's why you probably run into such issues. Gson apparently always serializes JSON with /**
* Read all lines from a file. This method ensures that the file is
* closed when all bytes have been read or an I/O error, or other runtime
* exception, is thrown. Bytes from the file are decoded into characters
* using the specified charset.
*
* <p> This method recognizes the following as line terminators:
* <ul>
* <li> <code>\u000D</code> followed by <code>\u000A</code>,
* CARRIAGE RETURN followed by LINE FEED </li>
* <li> <code>\u000A</code>, LINE FEED </li>
* <li> <code>\u000D</code>, CARRIAGE RETURN </li>
* </ul>
* <p> Additional Unicode line terminators may be recognized in future
* releases.
*
* <p> Note that this method is intended for simple cases where it is
* convenient to read all lines in a single operation. It is not intended
* for reading in large files.
*
* @param path
* the path to the file
* @param cs
* the charset to use for decoding
*
* @return the lines from the file as a {@code List}; whether the {@code
* List} is modifiable or not is implementation dependent and
* therefore not specified
*
* @throws IOException
* if an I/O error occurs reading from the file or a malformed or
* unmappable byte sequence is read
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, the {@link SecurityManager#checkRead(String) checkRead}
* method is invoked to check read access to the file.
*
* @see #newBufferedReader
*/
public static List<String> readAllLines(Path path, Charset cs) throws IOException { |
Ok, reading how Git is working, that is now clearer for me and I understand that all .json files are converted from LF to CRLF on Windows. It explains why I have CRLF on these files while in Git database they have only LF. Note that I see that our .gitattributes file contains:
Maybe we should add |
Signed-off-by: Laurent Garnier <[email protected]>
Travis tests were successfulHey @lolodomo, |
Done. Ready for a review & merge. |
That makes sense since .xml is already there. It will make checkouts between users of the same OS more consistent. It might initially cause some test failures. Linux is tested using Travis/Jenkins so it will be easy to see if tests still work. You've already checked conversion to Windows line endings yourself. 😉 |
The change of .gitattributes is out of the scope of this PR. I have not tested it yet. In my case, with default Git settings, as nothing is set for .json files in .gitattributes, I understand that Git setting core.autocrlf is used which is set to true, meaning files will be converted to CRLF on Windows (core.eol is unset). Changing the file .gitattributes should have no impact in practice. It would just avoid involving different Git settings for .xml and .json files. |
Yes that's how it works. Another benefit would be that it's also easier to search (and replace) text spanning multiple lines in many files when they consistently use the OS default line endings. |
Signed-off-by: Laurent Garnier <[email protected]>
Signed-off-by: Laurent Garnier <[email protected]> Signed-off-by: CSchlipp <[email protected]>
Signed-off-by: Laurent Garnier <[email protected]> Signed-off-by: MPH80 <[email protected]>
Signed-off-by: Laurent Garnier <[email protected]>
Signed-off-by: Laurent Garnier <[email protected]>
Signed-off-by: Laurent Garnier <[email protected]>
Signed-off-by: Laurent Garnier <[email protected]>
Signed-off-by: Laurent Garnier <[email protected]> Signed-off-by: Daan Meijer <[email protected]>
Signed-off-by: Laurent Garnier <[email protected]>
Fix #7981
Signed-off-by: Laurent Garnier [email protected]