LearnLib / automatalib

A free, open-source Java library for modeling automata, graphs, and transition systems
http://automatalib.net
Apache License 2.0
92 stars 34 forks source link

Error testing serilaization-dot #25

Closed omarzd closed 6 years ago

omarzd commented 6 years ago

Hi I faced the following error during a mvn clean install. The setup is JDK 1.8 on Windows 7 x64.

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running net.automatalib.serialization.dot.DOTSerializationTest
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[ERROR] Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.648 s <<< FAILURE! - in net.automatalib.serialization.dot.DOTSerializationTest
[ERROR] testRegularExport(net.automatalib.serialization.dot.DOTSerializationTest)  Time elapsed: 0.087 s  <<< FAILURE!
java.lang.AssertionError:
expected [digraph g {

        s0 [shape="circle" label="0"];
        s1 [shape="circle" label="1"];
        s2 [shape="circle" label="2"];
        s0 -> s1 [label="a / 1"];
        s1 -> s2 [label="b / 2"];
        s2 -> s0 [label="c / 3"];

__start0 [label="" shape="none" width="0" height="0"];
__start0 -> s0;

}
] but found [digraph g {

        s0 [shape="circle" label="0"];
        s1 [shape="circle" label="1"];
        s2 [shape="circle" label="2"];
        s0 -> s1 [label="a / 1"];
        s1 -> s2 [label="b / 2"];
        s2 -> s0 [label="c / 3"];

__start0 [label="" shape="none" width="0" height="0"];
__start0 -> s0;

}
]
        at net.automatalib.serialization.dot.DOTSerializationTest.checkDOTOutput(DOTSerializationTest.java:96)
        at net.automatalib.serialization.dot.DOTSerializationTest.testRegularExport(DOTSerializationTest.java:59)

[ERROR] testVisualizationHelper(net.automatalib.serialization.dot.DOTSerializationTest)  Time elapsed: 0.014 s  <<< FAILURE!
java.lang.AssertionError:
expected [digraph g {
// this is a preamble

        s0 [shape="doublecircle" label="0"];
        s1 [shape="circle" label="1"];
        s2 [shape="doublecircle" label="2"];
        s3 [shape="circle" label="3"];
        s4 [shape="doublecircle" label="4"];
        s5 [shape="circle" label="5"];
        s6 [shape="doublecircle" label="6"];
        s7 [shape="circle" label="7"];
        s8 [shape="doublecircle" label="8"];
        s9 [shape="circle" label="9"];
        s10 [shape="doublecircle" label="10"];
        s0 -> s1 [color="red" label="null"];
        s1 -> s2 [color="red" label="null"];
        s2 -> s3 [color="red" label="null"];
        s3 -> s4 [color="red" label="null"];
        s4 -> s5 [color="red" label="null"];
        s5 -> s6 [color="red" label="null"];
        s6 -> s7 [color="red" label="null"];
        s7 -> s8 [color="red" label="null"];
        s8 -> s9 [color="red" label="null"];
        s9 -> s10 [color="red" label="null"];
        s10 -> s0 [color="red" label="null"];

// this is a postamble

}
] but found [digraph g {
// this is a preamble

        s0 [shape="doublecircle" label="0"];
        s1 [shape="circle" label="1"];
        s2 [shape="doublecircle" label="2"];
        s3 [shape="circle" label="3"];
        s4 [shape="doublecircle" label="4"];
        s5 [shape="circle" label="5"];
        s6 [shape="doublecircle" label="6"];
        s7 [shape="circle" label="7"];
        s8 [shape="doublecircle" label="8"];
        s9 [shape="circle" label="9"];
        s10 [shape="doublecircle" label="10"];
        s0 -> s1 [color="red" label="null"];
        s1 -> s2 [color="red" label="null"];
        s2 -> s3 [color="red" label="null"];
        s3 -> s4 [color="red" label="null"];
        s4 -> s5 [color="red" label="null"];
        s5 -> s6 [color="red" label="null"];
        s6 -> s7 [color="red" label="null"];
        s7 -> s8 [color="red" label="null"];
        s8 -> s9 [color="red" label="null"];
        s9 -> s10 [color="red" label="null"];
        s10 -> s0 [color="red" label="null"];

// this is a postamble

}
]
        at net.automatalib.serialization.dot.DOTSerializationTest.checkDOTOutput(DOTSerializationTest.java:96)
        at net.automatalib.serialization.dot.DOTSerializationTest.testVisualizationHelper(DOTSerializationTest.java:82)

[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]   DOTSerializationTest.testRegularExport:59->checkDOTOutput:96 expected [digraph g {

        s0 [shape="circle" label="0"];
        s1 [shape="circle" label="1"];
        s2 [shape="circle" label="2"];
        s0 -> s1 [label="a / 1"];
        s1 -> s2 [label="b / 2"];
        s2 -> s0 [label="c / 3"];

__start0 [label="" shape="none" width="0" height="0"];
__start0 -> s0;

}
] but found [digraph g {

        s0 [shape="circle" label="0"];
        s1 [shape="circle" label="1"];
        s2 [shape="circle" label="2"];
        s0 -> s1 [label="a / 1"];
        s1 -> s2 [label="b / 2"];
        s2 -> s0 [label="c / 3"];

__start0 [label="" shape="none" width="0" height="0"];
__start0 -> s0;

}
]
[ERROR]   DOTSerializationTest.testVisualizationHelper:82->checkDOTOutput:96 expected [digraph g {
// this is a preamble

        s0 [shape="doublecircle" label="0"];
        s1 [shape="circle" label="1"];
        s2 [shape="doublecircle" label="2"];
        s3 [shape="circle" label="3"];
        s4 [shape="doublecircle" label="4"];
        s5 [shape="circle" label="5"];
        s6 [shape="doublecircle" label="6"];
        s7 [shape="circle" label="7"];
        s8 [shape="doublecircle" label="8"];
        s9 [shape="circle" label="9"];
        s10 [shape="doublecircle" label="10"];
        s0 -> s1 [color="red" label="null"];
        s1 -> s2 [color="red" label="null"];
        s2 -> s3 [color="red" label="null"];
        s3 -> s4 [color="red" label="null"];
        s4 -> s5 [color="red" label="null"];
        s5 -> s6 [color="red" label="null"];
        s6 -> s7 [color="red" label="null"];
        s7 -> s8 [color="red" label="null"];
        s8 -> s9 [color="red" label="null"];
        s9 -> s10 [color="red" label="null"];
        s10 -> s0 [color="red" label="null"];

// this is a postamble

}
] but found [digraph g {
// this is a preamble

        s0 [shape="doublecircle" label="0"];
        s1 [shape="circle" label="1"];
        s2 [shape="doublecircle" label="2"];
        s3 [shape="circle" label="3"];
        s4 [shape="doublecircle" label="4"];
        s5 [shape="circle" label="5"];
        s6 [shape="doublecircle" label="6"];
        s7 [shape="circle" label="7"];
        s8 [shape="doublecircle" label="8"];
        s9 [shape="circle" label="9"];
        s10 [shape="doublecircle" label="10"];
        s0 -> s1 [color="red" label="null"];
        s1 -> s2 [color="red" label="null"];
        s2 -> s3 [color="red" label="null"];
        s3 -> s4 [color="red" label="null"];
        s4 -> s5 [color="red" label="null"];
        s5 -> s6 [color="red" label="null"];
        s6 -> s7 [color="red" label="null"];
        s7 -> s8 [color="red" label="null"];
        s8 -> s9 [color="red" label="null"];
        s9 -> s10 [color="red" label="null"];
        s10 -> s0 [color="red" label="null"];

// this is a postamble

}
]
[INFO]
[ERROR] Tests run: 2, Failures: 2, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] AutomataLib ........................................ SUCCESS [  1.144 s]
[INFO] AutomataLib :: Build Parent ........................ SUCCESS [  0.023 s]
[INFO] AutomataLib :: Commons ............................. SUCCESS [  0.031 s]
[INFO] AutomataLib :: Commons :: Utilities ................ SUCCESS [  6.547 s]
[INFO] AutomataLib :: API ................................. SUCCESS [  5.936 s]
[INFO] AutomataLib :: Adapters ............................ SUCCESS [  0.025 s]
[INFO] AutomataLib :: Adapters :: BRICS ................... SUCCESS [  2.485 s]
[INFO] AutomataLib :: Commons :: Smart Collections ........ SUCCESS [  1.834 s]
[INFO] AutomataLib :: Core ................................ SUCCESS [  7.390 s]
[INFO] AutomataLib :: Utilities ........................... SUCCESS [  8.460 s]
[INFO] AutomataLib :: Incremental ......................... SUCCESS [  2.516 s]
[INFO] AutomataLib :: Serialization ....................... SUCCESS [  0.035 s]
[INFO] AutomataLib :: Serialization :: ETF ................ SUCCESS [  1.877 s]
[INFO] AutomataLib :: Serialization :: FSM ................ SUCCESS [  1.912 s]
[INFO] AutomataLib :: Model Checking ...................... SUCCESS [  0.028 s]
[INFO] AutomataLib :: Model Checking :: LTSmin ............ SUCCESS [  2.445 s]
[INFO] AutomataLib :: Serialization :: Core ............... SUCCESS [  0.361 s]
[INFO] AutomataLib :: Serialization :: AUT ................ SUCCESS [  1.911 s]
[INFO] AutomataLib :: Serialization :: DOT ................ FAILURE [  1.707 s]
[INFO] AutomataLib :: Serialization :: LearnLibV2 ......... SKIPPED
[INFO] AutomataLib :: Serialization :: SAF ................ SKIPPED
[INFO] AutomataLib :: Serialization :: TAF ................ SKIPPED
[INFO] AutomataLib :: Visualization ....................... SKIPPED
[INFO] AutomataLib :: Visualization :: DOT Visualizer ..... SKIPPED
[INFO] AutomataLib :: Visualization :: JUNG Visualizer .... SKIPPED
[INFO] AutomataLib :: Distribution ........................ SKIPPED
[INFO] AutomataLib :: Archetypes .......................... SKIPPED
[INFO] AutomataLib :: Archetypes :: Basic ................. SKIPPED
[INFO] AutomataLib :: Archetypes :: Complete .............. SKIPPED
[INFO] AutomataLib :: Build Tools ......................... SKIPPED
[INFO] AutomataLib :: Examples ............................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 47.118 s
[INFO] Finished at: 2018-07-10T13:54:30+02:00
[INFO] Final Memory: 54M/1028M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20:test (default-test) on project automata-serialization-dot: There are test failures.
[ERROR]
[ERROR] Please refer to C:\eclipse\workspace\automatalib\serialization\dot\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :automata-serialization-dot
mtf90 commented 6 years ago

From the looks of your terminal output, the difference seems to be quite subtle. It could the handling of newlines (\r\n vs \n) on Windows or do you have any special language configured?

Could you maybe try to debug the DOTSerializationTest, and tell me what the actual difference between the two values is right before the violating check? (Any IDE with TestNG support should be able to this).

omarzd commented 6 years ago

You're absolutely right. dotWriter.toString() has \n. expectedWriter.toString() has \r\n. How do I fix this?

mtf90 commented 6 years ago

Great, thanks for the info. We will look into this. At this point I'm not sure yet, if this is an issue with the test or the way, the serializer works.

For now, if you're just interested in building the latest AutomataLib artifacts, you could run mvn clean install -DskipTests or use the public snapshot artifacts

mtf90 commented 6 years ago

@omarzd, could you maybe try to build https://github.com/mtf90/automatalib/tree/platformFixes? If this works for you, I can merge the changes in the main repo.

mtf90 commented 6 years ago

@omarzd did you have the chance to test my branch?

omarzd commented 6 years ago

@mtf90 I just did. It gives the same error.

mtf90 commented 6 years ago

@omarzd Hm, that is weird. I set up AppVeyor to have continuous integration on Windows platforms and merged the changes from my branch. As you can see, the build succeeds.

However, I did have to enable git's autocrlf (so that the test files committed with \n are checked out with \r\n newlines). I assume you use the same configuration, because in your initial feedback you said, that the expectedWriter (which is reading the file) contained \r\n. Do the test files (e.g. serialization/dot/src/test/resources/graph.dot) have correct newlines if you open them in an arbitrary editor?

omarzd commented 6 years ago

@mtf90 It looks like you merged the fix. I just set my git using git config --global core.autocrlf true and compiled again and it passed the tests. Maybe the git config should be mentioned in the README. Thank you

mtf90 commented 6 years ago

@omarzd You haven't configured anything similar before? This makes me wonder how you ended up with \r\n newlines in the first place (see your comment), because we mainly use UNIX systems for development (which only use \n).

Anyway, it looks like everything is working out now. Thanks for raising this issue and reminding us to share more love for windows users :P.

Edit: Also, you probably don't have to set this as a global setting, which may interfere with other projects of yours. Apparently, we can also solve this by adding a .gitattributes file to the repository, so that we can provide a proper out-of-the-box configuration. I'll have a look at that.

mtf90 commented 6 years ago

@omarzd 3c1a0c5 added a .gitattributes file which should automatically take care of correct, platform dependent newlines conversion, so you shouldn't need to manually configure anything for Automatalib. Although AppVeyor VMs still seem to require manual configuration via core.autocrlf, I checked at least one Windows box where everything worked out-of-the-box.