From: arved Date: Thu, 10 May 2001 01:44:04 +0000 (+0000) Subject: K. Liddle: testing support X-Git-Tag: PRE_CODEFORMATTING~140 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=96ef52e8580b3fc5f670b577445e75de020a9fdd;p=xmlgraphics-fop.git K. Liddle: testing support git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194237 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/build.sh b/build.sh index ad0acde7a..f23d25714 100755 --- a/build.sh +++ b/build.sh @@ -16,10 +16,16 @@ LIBDIR=lib LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:$LIBDIR/ant.jar:$LIBDIR/w3c.jar:$LIBDIR/buildtools.jar:$LIBDIR/xerces-1.2.3.jar:$LIBDIR/xalan-2.0.0.jar:$LIBDIR/xalanj1compat.jar:$LIBDIR/bsf.jar:$LIBDIR/jimi-1.0.jar ANT_HOME=$LIBDIR -echo Building with classpath $CLASSPATH:$LOCALCLASSPATH echo +CP=$LOCALCLASSPATH +if [ ! "$CLASSPATH" = "" ] +then +CP=$CP:$CLASSPATH +fi +echo Building with classpath $CP + echo Starting Ant... echo -$JAVA_HOME/bin/java -Dant.home=$ANT_HOME -classpath "$LOCALCLASSPATH:$CLASSPATH" org.apache.tools.ant.Main $* +$JAVA_HOME/bin/java -Dant.home=$ANT_HOME -classpath "$CP" org.apache.tools.ant.Main $* diff --git a/build.xml b/build.xml index 38334334d..47f797953 100644 --- a/build.xml +++ b/build.xml @@ -267,6 +267,7 @@ Sometimes ant gives out this warnings, but the build is finished without any pro + @@ -557,6 +558,12 @@ Sometimes ant gives out this warnings, but the build is finished without any pro includes="org/**,conf/**,hyph/**"/> + + + + + diff --git a/buildtools.xml b/buildtools.xml index e68747124..8b3838fb8 100644 --- a/buildtools.xml +++ b/buildtools.xml @@ -50,7 +50,7 @@ + excludes="${tools}/anttasks/Fop.java,${tools}/TestConverter.java,${hyph}/Hyphenator.java,**/${xalan1},**/${trax}"/> diff --git a/src/org/apache/fop/tools/anttasks/RunTest.java b/src/org/apache/fop/tools/anttasks/RunTest.java new file mode 100644 index 000000000..e051b500f --- /dev/null +++ b/src/org/apache/fop/tools/anttasks/RunTest.java @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. + */ + +package org.apache.fop.tools.anttasks; + +// Ant +import org.apache.tools.ant.*; + +import java.io.*; +import java.lang.reflect.*; +import java.net.URLClassLoader; +import java.net.URL; +import java.net.MalformedURLException; + +import javax.xml.parsers.*; + +import org.w3c.dom.*; +import org.xml.sax.XMLReader; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +/** + */ +public class RunTest extends Task { + String basedir; + String testsuite = ""; + String referenceJar = ""; + String refVersion = ""; + + public RunTest() { + } + + public void setTestSuite(String str) + { + testsuite = str; + } + + public void setBasedir(String str) + { + basedir = str; + } + + public void setReference(String str) { + referenceJar = str; + } + + public void setRefVersion(String str) { + refVersion = str; + } + + /** + * Execute this ant task. + * This creates the reference output, if required, then tests + * the current build. + */ + public void execute() throws BuildException { + runReference(); + testNewBuild(); + } + + /** + * Test the current build. + * This uses the current jar file (in build/fop.jar) to run the + * tests with. + * The output is then compared with the reference output. + */ + protected void testNewBuild() { + try { + ClassLoader loader = new URLClassLoader(new URL[] {new URL("file:build/fop.jar")}); + runConverter(loader); + } catch(MalformedURLException mue) { + mue.printStackTrace(); + } + } + + /** + * Run the tests for the reference jar file. + * This checks that the reference output has not already been + * run and then checks the version of the reference jar against + * the version required. + * The reference output is then created. + */ + protected void runReference() throws BuildException + { + // check not already done + File f = new File(basedir + "reference/output/"); + if(f.exists()) { + return; + } else { + try { + ClassLoader loader = new URLClassLoader(new URL[] {new URL("file:" + basedir + referenceJar)}); + + try { + Class cla = Class.forName("org.apache.fop.apps.Options", true, loader); + Object opts = cla.newInstance(); + cla = Class.forName("org.apache.fop.apps.Version", true, loader); + Method get = cla.getMethod("getVersion", new Class[] {}); + if(!get.invoke(null, new Object[] {}).equals(refVersion)) { + throw new BuildException("Reference jar is not correct version"); + } + } catch(IllegalAccessException iae) { + } catch(IllegalArgumentException are) { + } catch(InvocationTargetException are) { + } catch(ClassNotFoundException are) { + } catch(InstantiationException are) { + } catch(NoSuchMethodException are) { + } + + runConverter(loader); + } catch(MalformedURLException mue) { + mue.printStackTrace(); + } + } + } + + /** + * Run the Converter. + * Runs the test converter using the specified class loader. + * This loads the TestConverter using the class loader and + * then runs the test suite for the current test suite + * file in the base directory. + * @param loader the class loader to use to run the tests with + */ + protected void runConverter(ClassLoader loader) + { + String converter = "org.apache.fop.tools.TestConverter"; + + try { + Class cla = Class.forName(converter, true, loader); + Object tc = cla.newInstance(); + Method meth; + + meth = cla.getMethod("setBaseDir", new Class[] {String.class}); + meth.invoke(tc, new Object[] {basedir}); + + meth = cla.getMethod("runTests", new Class[] {String.class}); + meth.invoke(tc, new Object[] {testsuite}); + } catch(Exception e) { + e.printStackTrace(); + } + } +} diff --git a/test/Testing b/test/Testing new file mode 100644 index 000000000..180e73d87 --- /dev/null +++ b/test/Testing @@ -0,0 +1,59 @@ +Testing procedure for FOP + +(to be written using appropriate xml document) + +1) Aim + +Need an infrastructure to develop and perform tests. +Prevent regressions and make checking results easier. +Quantify the features and conformance. + +This must be done in a uniform and simple way. + +Ideally the testing and verification should all be automatic. + +A new release must not break any previously working features. + +Every time a new feature is added then tests should be made that test the feature in all possible situations. + +2) Infrastructure + +Each test for a feature must be designed to test only that feature and contain no other possible interactions. + +Tests should be as simple as possible and demonstrate the feature working. + +2.1) Options +1. For each possible parameter have a file which fully excercises the parameter over all reasonable bounds. This will mean that the fo must be in a format that will ensure each test is independant (which may not always be possible). A typical test will be large and have some overhead. + +2. For each individual test have a separate fo file or fo fragment. + +The tests are specified in an xml file which is processed using an xsl file (which may simply copy the xml). + +This will be done as a build target. + +There should be an indication about whether the test is correct for the reference FOP snapshot. This will mean that all changes after the snapshot must not break the test and may improve the result for tests that do not work. + +2.2) Details + +make a "test" dir at top level +have a script which can update the code to the snapshot tag, build and create an FOP jar. +this will then be used as the reference point for comparing results. +the tests are run and compared with the results from the reference FOP. +all differences are reported, especially ones that change a test that is marked as working (ie. regressions) + +the output will not be compressed so that the pdf markup can be compared using a diff. + +Each test must contain a unique id, catagory, a description, the test fo data and pass/fail status. + +There will be a number of catagories of test fo files (and possibly sub-catagories). +These will include conformance, bugtests and system tests. + + +3) Problems + +The reference build must be done on a clean cvs build for the appropriate tag. +The information must be updated appropriately to ensure that the results are correct. + + + + diff --git a/test/basictests.xml b/test/basictests.xml new file mode 100644 index 000000000..9a710d885 --- /dev/null +++ b/test/basictests.xml @@ -0,0 +1,14 @@ + + + + + + + +6-4-2-1.xml contains only one fo:root element. + + + + + + diff --git a/test/testsuite.dtd b/test/testsuite.dtd new file mode 100644 index 000000000..bf32ea23b --- /dev/null +++ b/test/testsuite.dtd @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/xml/1.xml b/test/xml/1.xml new file mode 100644 index 000000000..0b41cccc3 --- /dev/null +++ b/test/xml/1.xml @@ -0,0 +1,9 @@ + + + + +text text text text + + + + diff --git a/test/xsl/copy.xsl b/test/xsl/copy.xsl new file mode 100644 index 000000000..4e3e6109f --- /dev/null +++ b/test/xsl/copy.xsl @@ -0,0 +1,4 @@ + + + + diff --git a/test/xsl/doc.xsl b/test/xsl/doc.xsl new file mode 100644 index 000000000..71a2cc434 --- /dev/null +++ b/test/xsl/doc.xsl @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +