Make the save game validator return useful exit codes.

This commit is contained in:
Mike Pope 2017-02-14 15:22:43 +10:30
parent 98c71550ab
commit cb08aa8e0b
2 changed files with 7 additions and 2 deletions

View File

@ -828,7 +828,8 @@
<condition property="savegame" else="">
<isset property="savegame" />
</condition>
<java classname="net.sf.freecol.tools.SaveGameValidator">
<java classname="net.sf.freecol.tools.SaveGameValidator"
failonerror="true">
<classpath refid="test.run.classpath"/>
<arg value="${savegame}" />
</java>

View File

@ -61,8 +61,9 @@ public class SaveGameValidator {
}
}
int ret = 0;
for (File file : allFiles) {
System.out.println("Processing file " + file.getPath());
//System.out.println("Processing file " + file.getPath());
try {
FreeColSavegameFile mapFile = new FreeColSavegameFile(file);
saveGameValidator.validate(new StreamSource(mapFile.getSavegameInputStream()));
@ -71,10 +72,13 @@ public class SaveGameValidator {
System.out.println(e.getMessage()
+ " at line=" + e.getLineNumber()
+ " column=" + e.getColumnNumber());
ret = Math.max(ret, 1);
} catch (IOException | SAXException e) {
System.out.println("Failed to read " + file.getName());
ret = 2;
}
}
System.exit(ret);
}
}