public void compareFile(File source, File referenceDir, File failedDirectory, CompareStatistics stat) throws IOException {
log("Comparing " + source.getPath());
stat.checking(source);
// TODO: reuse code from Regress
BoxRenderer renderer = new BoxRenderer(source, width);
Box box;
try {
log("rendering");
box = renderer.render();
log("rendered");
} catch (Exception e) {
e.printStackTrace();
stat.failedToRender(e);
storeFailed(failedDirectory, source);
log("Could not render input file, skipping: " + source + " err: " + e.getMessage());
return;
}
LayoutContext layoutContext = renderer.getLayoutContext();
String inputFileName = source.getName();
String refRendered = trimTrailingLS(readReference(referenceDir, inputFileName, Regress.RENDER_SFX));
String rendered = trimTrailingLS(box.dump(layoutContext, "", Box.DUMP_RENDER));
if (!compareLines(refRendered, rendered, stat)) {
storeFailed(failedDirectory, new File(referenceDir, inputFileName), Regress.RENDER_SFX, rendered);