From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16816 invoked by alias); 25 Apr 2004 12:30:56 -0000 Mailing-List: contact mauve-discuss-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-discuss-owner@sources.redhat.com Received: (qmail 16802 invoked from network); 25 Apr 2004 12:30:54 -0000 Received: from unknown (HELO smtpq3.home.nl) (213.51.128.198) by sources.redhat.com with SMTP; 25 Apr 2004 12:30:54 -0000 Received: from [213.51.128.132] (port=45943 helo=smtp1.home.nl) by smtpq3.home.nl with esmtp (Exim 4.30) id 1BHimc-0004nk-D4 for mauve-discuss@sources.redhat.com; Sun, 25 Apr 2004 14:30:54 +0200 Received: from cc68231-a.ensch1.ov.home.nl ([212.120.112.227]:34670 helo=dumas.thomas.planescape.com) by smtp1.home.nl with esmtp (Exim 4.30) id 1BHimY-0000sk-HH for mauve-discuss@sources.redhat.com; Sun, 25 Apr 2004 14:30:50 +0200 From: Thomas Zander To: mauve-discuss@sources.redhat.com Subject: [PATCH] teach ant to use the mauve-tagsystem Date: Sun, 25 Apr 2004 12:30:00 -0000 User-Agent: KMail/1.6.2 MIME-Version: 1.0 Content-Disposition: inline Content-Type: Multipart/Mixed; boundary="Boundary-00=_u86iAWJfpEAjgY8" Message-Id: <200404251429.45299.zander@javalobby.org> X-AtHome-MailScanner-Information: Please contact support@home.nl for more information X-AtHome-MailScanner: Found to be clean X-SW-Source: 2004-q2/txt/msg00051.txt.bz2 --Boundary-00=_u86iAWJfpEAjgY8 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-length: 486 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Subject says it all.. 2004-04-25 Thomas Zander * gnu/anttask/RunTests: Add javadoc, add setSrcdir, setTestJDK,=20 setTestJDBC * build.xml: fix typo, use new flags srcdir, testjdk, testjdbc Please commit. - --=20 Thomas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFAi68uCojCW6H2z/QRArgSAJ90lQuulIPCRZoyl0ag/HbDq74eTwCfed1e 6Qj15c2gjDCJvCL0aKGZL3M=3D =3DBtQ7 -----END PGP SIGNATURE----- --Boundary-00=_u86iAWJfpEAjgY8 Content-Type: text/x-diff; charset="us-ascii"; name="ant-feature.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ant-feature.diff" Content-length: 10627 Index: ChangeLog =================================================================== RCS file: /cvs/mauve/mauve/ChangeLog,v retrieving revision 1.588 diff -u -3 -p -r1.588 ChangeLog --- ChangeLog 25 Apr 2004 11:10:39 -0000 1.588 +++ ChangeLog 25 Apr 2004 12:23:57 -0000 @@ -1,3 +1,17 @@ +2004-04-25 Thomas Zander + + * gnu/anttask/RunTests: Add javadoc, add setSrcdir, setTestJDK, setTestJDBC + * build.xml: fix typo, use new flags srcdir, testjdk, testjdbc + 2004-04-25 Mark Wielaard * gnu/testlet/java/net/DatagramSocket/DatagramSocketTest2.java: Remove Index: build.xml =================================================================== RCS file: /cvs/mauve/mauve/build.xml,v retrieving revision 1.1 diff -u -3 -p -r1.1 build.xml --- build.xml 13 Apr 2004 17:44:44 -0000 1.1 +++ build.xml 25 Apr 2004 12:23:57 -0000 @@ -59,7 +59,7 @@ @@ -79,6 +79,9 @@ Index: gnu/anttask/RunTests.java =================================================================== RCS file: /cvs/mauve/mauve/gnu/anttask/RunTests.java,v retrieving revision 1.1 diff -u -3 -p -r1.1 RunTests.java --- gnu/anttask/RunTests.java 13 Apr 2004 17:44:45 -0000 1.1 +++ gnu/anttask/RunTests.java 25 Apr 2004 12:23:57 -0000 @@ -28,12 +28,64 @@ import org.apache.tools.ant.*; import org.apache.tools.ant.taskdefs.*; import org.apache.tools.ant.types.*; +/** + * Ant task to run Mauve test-suite. + *

Before asking questions; always refer to the ant manual first.

+

Test classes are passed as child fileset tags, typically you simply pass the build + dir for the project

+

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDescriptionRequired
debugPrints additional debug info for the testsNo
verboseLets the test suite be more verbose; also showing passed-tests for exampleNo
haltonfailuremake the testrun halt as soon as a failure is failed (see also failonerror)No
srcdirprovide the sources directory allowing the parsing of a "Tags:" comment in the header of the file. If the testJDK or testJDBC are also supplied then tests that have tags specifying that their API comatibility are incompatible with the testJDK/testJDBC version will be skipped.No
testJDKThe version of the JDK you are running/simulating. Only tests that are compatible with this version will be run.No
testJDBCThe version of the JDBC API you are running/simulating. Only tests that are compatible with this version will be run.No
failonerrorIf a test fails, should that be flagged as an error? Setting this and haltonfailure to true will stop the run as soon as a failure is found.No
+ */ public class RunTests extends MatchingTask { private boolean verbose=false, debug=false, haltOnFailure=false, failOnError=true; - private Path sourceDir=null; + private File sourceDir=null; private Vector filesets=new Vector(); + private double javaVersion=0d, JDBCVersion=0d; public void execute() throws BuildException { + if(sourceDir == null) + System.err.println("Warning; without 'srcdir' element no Tag checking will be done"); MyTestHarness harness = new MyTestHarness (verbose, debug, haltOnFailure); Iterator iter = filesets.iterator(); @@ -50,8 +102,11 @@ public class RunTests extends MatchingTa continue; // no inner classeS filename=filename.substring(0, filename.length()-6); filename=filename.replace(File.separatorChar, '.'); - - harness.runTest(filename); + if(shouldRunTest(filename)) { + if(!verbose) + System.out.println("Run: "+ filename); + harness.runTest(filename); + } } } catch (BuildException be) { // directory doesn't exist or is not readable @@ -83,6 +138,70 @@ public class RunTests extends MatchingTa filesets.add(set); } + public void setSrcdir(File sourceDir) { + this.sourceDir = sourceDir; + } + + public void setTestJDK(String jdk) { + jdk=jdk.toLowerCase().trim(); + if(jdk.startsWith("jdk")) { + try { + javaVersion = Double.parseDouble(jdk.substring(3)); + return; + } catch(NumberFormatException e) { + } + } + System.err.println("Failed to parse the testJDK argument; format is: 'JDK1.4'"); + } + + public void setTestJDBC(String jdbc) { + jdbc=jdbc.toLowerCase().trim(); + if(jdbc.startsWith("jdbc")) { + try { + javaVersion = Double.parseDouble(jdbc.substring(4)); + return; + } catch(NumberFormatException e) { + } + } + System.err.println("Failed to parse the testJDBC argument; format is: 'JDBC2.0'"); + } + + private boolean shouldRunTest(String filename) { + if(sourceDir == null) + return true; + File sourceFile = new File(sourceDir, filename.replace('.', File.separatorChar)+".java"); + if(! sourceFile.exists()) + return false; + try { + Reader reader = new FileReader(sourceFile); + StringBuffer buf = new StringBuffer(); + int maxLines=20; + while(true) { + int character = reader.read(); + if(character == -1) + break; + if(character == '\n') { + int index = buf.indexOf("Tags:") + 5; // 5 == length of string + if(index > 5 && buf.length() > index) { + String tags = buf.substring(index).trim().toLowerCase(); + if("not-a-test".equals(tags)) + return false; + try { + return new Tags(tags).isValid(javaVersion, JDBCVersion); + } catch(NumberFormatException e) { + System.err.println("Unreadable tags in class: "+ filename); + return false; + } + } + buf = new StringBuffer(); + } + else + buf.append((char) character); + } + } catch(IOException e) { } + return false; + } + private static class MyTestHarness extends SimpleTestHarness { private boolean haltOnFailure; @@ -96,6 +215,58 @@ public class RunTests extends MatchingTa super.runtest(name); if(haltOnFailure && getFailures() > 0) throw new BuildException("Failures"); + } + } + + private static class Tags { + String fromJDK="1.0", toJDK="99.0"; + String fromJDBC="1.0", toJDBC="99.0"; + public Tags(String line) { +//System.out.println("tagLine: '"+ line +"'"); + int start=0; + for(int i=0; i <= line.length();i++) { + if(i == line.length() || line.charAt(i) == ' ') { + if(start < i) + process(line.substring(start, i)); + start = i+1; + } + } + + } + public void process(String token) { +//System.out.println(" +-- '"+ token +"'"); + boolean end = token.startsWith("!"); + if(end) + token = token.substring(1); + if(token.startsWith("jls") || token.startsWith("jdk")) { + String value = token.substring(3); + if(end) + toJDK = value; + else + fromJDK = value; + } + else if(token.startsWith("jdbc")) { + String value = token.substring(4); + if(end) + toJDBC = value; + else + fromJDBC = value; + } + } + public boolean isValid(double javaVersion, double JDBCVersion) throws NumberFormatException { + if(javaVersion != 0d) { + double from = Double.parseDouble(fromJDK); + if(from > javaVersion) return false; + double end = Double.parseDouble(toJDK); + if(end < javaVersion) return false; + } + if(JDBCVersion != 0d) { + double from = Double.parseDouble(fromJDBC); + if(from < JDBCVersion) return false; + double end = Double.parseDouble(toJDBC); + if(end > JDBCVersion) return false; + } + return true; } } } --Boundary-00=_u86iAWJfpEAjgY8--