kaitai-io/kaitai_struct

Warnings (and maybe errors) are reported in unstable order

Mingun opened this issue · 1 comments

This can be demonstrated by test encoding_str_warnings which is failed with the following message:

[info] - encoding_str_warnings *** FAILED ***
[info]   encoding_str_warnings.ksy: /seq/1/encoding:
[info]   	warning: use canonical encoding name `UTF-8` instead of `utF-8` (see https://doc.kaitai.io/ksy_style_guide.html#encoding-name)
[info]   
[info]   encoding_str_warnings.ksy: /seq/2/encoding:
[info]   	warning: use canonical encoding name `ISO-8859-1` instead of `latin1` (see https://doc.kaitai.io/ksy_style_guide.html#encoding-name)
[info]   
[info]   encoding_str_warnings.ksy: /instances/alias/encoding:
[info]   	warning: use canonical encoding name `ISO-8859-1` instead of `ISo8859-1` (see https://doc.kaitai.io/ksy_style_guide.html#encoding-name)
[info]   
[info]   encoding_str_warnings.ksy: /instances/wrong_case/encoding:
[info]   	warning: use canonical encoding name `ISO-8859-1` instead of `iSo-8859-1` (see https://doc.kaitai.io/ksy_style_guide.html#encoding-name)
[info]    did not equal encoding_str_warnings.ksy: /seq/1/encoding:
[info]   	warning: use canonical encoding name `UTF-8` instead of `utF-8` (see https://doc.kaitai.io/ksy_style_guide.html#encoding-name)
[info]   
[info]   encoding_str_warnings.ksy: /seq/2/encoding:
[info]   	warning: use canonical encoding name `ISO-8859-1` instead of `latin1` (see https://doc.kaitai.io/ksy_style_guide.html#encoding-name)
[info]   
[info]   encoding_str_warnings.ksy: /instances/wrong_case/encoding:
[info]   	warning: use canonical encoding name `ISO-8859-1` instead of `iSo-8859-1` (see https://doc.kaitai.io/ksy_style_guide.html#encoding-name)
[info]   
[info]   encoding_str_warnings.ksy: /instances/alias/encoding:
[info]   	warning: use canonical encoding name `ISO-8859-1` instead of `ISo8859-1` (see https://doc.kaitai.io/ksy_style_guide.html#encoding-name) (SimpleMatchers.scala:34)

The reason because /instances/wrong_case and /instances/alias instances reported in different order in expected message and by the compiler.

flatMap here traverses maps in order that the map provides, and default Map implementation is unordered.

Actually, that is test that wrong, because all properties with fields was changed to SortedMap in kaitai-io/kaitai_struct_compiler@5f561e1