Skip to content

Commit

Permalink
regression snapshot was missing source images, now using Ant to make …
Browse files Browse the repository at this point in the history
…copy of entire source reference tree and including this in snapshot diff. rebuild R8 snapshot so it includes these files. have ref comparison only report failures.
  • Loading branch information
pdoubleya committed Apr 17, 2009
1 parent 2e53460 commit 927efc5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 29 deletions.
14 changes: 11 additions & 3 deletions etc/build/tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@
</target>

<target name="regress.snapshot" depends="check.app.version, jar.core">
<!-- copy current test files -->
<delete dir="${regress.temp.dir}" failonerror="true" includeemptydirs="true" quiet="true" />
<delete file="${regress.target.zip}" />
<mkdir dir="${regress.temp.dir}" />
<copy todir="${regress.temp.dir}">
<fileset dir="${regress.source.dir}" />
</copy>
<java classname="org.xhtmlrenderer.test.Regress"
fork="${java-exec.fork.tests}">
<classpath>
Expand All @@ -210,9 +217,10 @@
<syspropertyset>
<propertyref prefix="xr."/>
</syspropertyset>
<arg value="${regress.source.dir}"/>
<arg value="${regress.target.zip}"/>
<arg value="${regress.temp.dir}"/>
</java>
<zip basedir="${regress.temp.dir}" zipfile="${regress.target.zip}" encoding="utf-8" level="9" />
<delete file="${regress.temp.dir}" />
</target>

<target name="regress.verify" depends="check.app.version, jar.core">
Expand Down Expand Up @@ -245,7 +253,7 @@
<syspropertyset>
<propertyref prefix="xr."/>
</syspropertyset>
<jvmarg line="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005" />
<!--<jvmarg line="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005" />-->
<arg value="${regress.source.dir}"/>
<arg value="${regress.verify.dir}"/>
<arg value="${regress.verify.failed.dir}"/>
Expand Down
10 changes: 8 additions & 2 deletions src/java/org/xhtmlrenderer/test/ReferenceComparison.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ReferenceComparison {

public static void main(String[] args) throws IOException {
// TODO: check args
ReferenceComparison rc = new ReferenceComparison(1024, true);
ReferenceComparison rc = new ReferenceComparison(1024, false);
File source = new File(args[0]);
File reference = new File(args[1]);
File failed = new File(args[2]);
Expand Down Expand Up @@ -280,11 +280,17 @@ public boolean succeeded() {
}

public void report() {
int failed = 0;
for (Iterator it = files.keySet().iterator(); it.hasNext();) {
File file = (File) it.next();
Result result = (Result) files.get(file);
System.out.println(result.describe(file));

if (result instanceof FailedResult) {
failed++;
System.out.println(result.describe(file));
}
}
System.out.println("Checked " + files.keySet().size() + " files, " + (failed > 0 ? failed + " failed." : "all OK."));
}

private class RenderFailed implements Result {
Expand Down
26 changes: 2 additions & 24 deletions src/java/org/xhtmlrenderer/test/Regress.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,13 @@ public class Regress {

public static void main(String[] args) throws Exception {
final File sourceDir = getArgSourceDir(args);
final File outputZip = getArgOutputZipFile(args);
final File outputDir = createOutputDir();
final File outputDir = sourceDir;
final int width = 1024;

System.out.println("Running regression against files in " + sourceDir + " to output directory " + outputDir);
System.out.println("Running regression against files in " + sourceDir);
Regress regress = new Regress(sourceDir, outputDir, width);
regress.snapshot();
System.out.println("Ran regressions against " + regress.getFileCount() + " files in source directory; " + regress.getFailedCount() + " failed to generate");
new Zipper(outputDir, outputZip).zipDirectory();
outputDir.delete();
System.out.println("Built regressions ZIP file: " + outputZip.getPath());
}

/**
Expand Down Expand Up @@ -128,7 +124,6 @@ private int getFileCount() {
public void snapshot() throws IOException {
fileCount = 0;
failedCount = 0;
IOUtil.deleteAllFiles(outputDir);
final boolean wasLogging = enableLogging(false);
try {
Iterator iter = listInputFiles(sourceDir);
Expand Down Expand Up @@ -163,7 +158,6 @@ private void saveImage(File page, File outputDir, int width) throws IOException
}
String fileName = outputFile.getPath();
imageWriter.write(img, fileName);
new File(fileName).deleteOnExit();
} catch (Exception e) {
System.err.println("Could not render input file to image, skipping: " + page + " err: " + e.getMessage());
}
Expand All @@ -181,8 +175,6 @@ private void saveBoxModel(File page, File outputDir, int width) throws IOExcepti
}
LayoutContext layoutContext = renderer.getLayoutContext();
String inputFileName = page.getName();
final File copy = IOUtil.copyFile(page, outputDir);
copy.deleteOnExit();
writeToFile(outputDir, inputFileName + RENDER_SFX, box.dump(layoutContext, "", Box.DUMP_RENDER));
writeToFile(outputDir, inputFileName + LAYOUT_SFX, box.dump(layoutContext, "", Box.DUMP_LAYOUT));
fileCount++;
Expand All @@ -195,7 +187,6 @@ private void writeToFile(File outputDir, String fileName, String output) throws
"On rendering, could not delete new output file (.delete failed) " + outputFile.getAbsolutePath()
);
}
outputFile.deleteOnExit();
OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8");
PrintWriter pw = new PrintWriter(new BufferedWriter(fw));
pw.print(output);
Expand Down Expand Up @@ -235,19 +226,6 @@ private static File getArgSourceDir(String[] args) {
return sourceDir;
}

private static File createOutputDir() {
File parent = new File(System.getProperty("java.io.tmpdir"));
File outputDir = new File(parent, "reference");
if (!outputDir.exists() && !outputDir.mkdirs()) {
throw new RuntimeException(
"Could not create temporary output directory (.mkdirs failed) " +
outputDir.getAbsoluteFile()
);
}
outputDir.deleteOnExit();
return outputDir;
}

private boolean enableLogging(final boolean isEnabled) {
final String prop = "xr.util-logging.loggingEnabled";
final boolean orgVal = Boolean.valueOf(System.getProperty(prop)).booleanValue();
Expand Down
Binary file modified tests/regress/snapshots/regress-output-R8.zip
Binary file not shown.

0 comments on commit 927efc5

Please sign in to comment.