3 ms·
if you smash the file permissions and dates on the file it can be deterministic.
by virtue3 6y ago
if you smash the file permissions and dates on the file it can be deterministic.
- Tainnor 6y agoMaybe (didn't look into that), but that wouldn't have solved the "somehow, XML is serialized differently in some cases because of namespaces" issue which, honestly, I didn't even try to understand because it seemed like a pointless rabbit-hole.
- sk5t 6y agoIndeed there's generally no guarantee that two XML serializers will choose the same namespace aliases, or handle ignorable whitespace the same, etc. You gotta think of XML as an object graph (and not a bunch of tags and text nodes) to have any joy at all with it. Unit tests should not compare the serialized bytes, but rather deserialize and/or event-parse and compare the graphs or events. I'm not suggesting any of this is pleasant, but, there it is.
- loopz 6y agoThinking of it as graph helps due to its many branches, but it's still hierarchical.
- Tainnor 6y agoIt's actually an arborescence which is a kind of directed acyclic graph (it's a directed graph in which there is exactly one directed path from the root to any of its children).
- Tainnor 6y agoYep, I ended up using https://www.xmlunit.org/ https://www.xmlunit.org/, which seems to do the job well.