Skip to content
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

ParsertTest.ioReaderTest() depends system settings, leads to failure #127

Closed
xzel23 opened this issue Apr 4, 2018 · 1 comment
Closed

Comments

@xzel23
Copy link

xzel23 commented Apr 4, 2018

Steps to reproduce the problem (provide example input):

  • clone the commonmark repository on a machine with a platform dependent standard charset that is not UTF-8. Note that the default charset used by InputStreamReader depends on different settings and so this may not be reproducible without effort. The test passed on my Mac (english locale) and failed on Windows 7 (english version with german locale).

  • compile and run tests

Expected behavior:

  • tests should pass

Actual behavior:

  • Failure in ParserTest
    org.commonmark.test.ParserTest > ioReaderTest FAILED
        org.junit.ComparisonFailure at ParserTest.java:45
    
    1357 tests completed, 1 failed, 1 skipped
    

Cause/Fix: ParserTest.ioReaderTest() creates an InputStreamReader that uses platform standard encoding and compares to results obtained when using UTF-8 charset (in TestResources.readAsString(URL)):

    @Test
    public void ioReaderTest() throws IOException {
        ...
        try (InputStreamReader reader = new InputStreamReader(input1)) {

should be (requires Java 7, or use Charset.forName("UTF-8") as in TestResources.java):

    @Test
    public void ioReaderTest() throws IOException {
        ...
        try (InputStreamReader reader = new InputStreamReader(input1, StandardCharsets.UTF_8)) {

Caveat: this happened while I was working on my own fork where I am working towards solving #125, not on master. However I only changed build files so far and this is quite obvious.

@robinst
Copy link
Collaborator

robinst commented Apr 26, 2018

Thanks, fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants