Pretty-print actual XML in tests

This means that, when writing new tests that are failing, you get much more
useful logs that show the actual XML in a more comprehensible format that is
suitable for pasting back into the golden file in the test (if the change was
intended).

This requires outputting the standalone parameter in the XML transformer, and
some minor changes to some tests as a result that were relying on it being
stripped out.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=204513690
This commit is contained in:
mcilwain 2018-07-13 12:48:50 -07:00 committed by jianglai
parent df5d9957f7
commit 278ec2b289
5 changed files with 11 additions and 7 deletions

View file

@ -303,6 +303,7 @@ public class XmlTransformer {
try {
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
transformer.transform(
new StreamSource(new StringReader(xmlString)),