DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3913>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3913 The covreport task does not remove classes not in the reference classpath Summary: The covreport task does not remove classes not in the reference classpath Product: Ant Version: 1.4 Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Normal Priority: Other Component: Optional Tasks AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] The documentation states classes will be removed from the coverage report if they are not in the reference classpath. The implementation does not filter out these classes properly. Here is a patch to fix the problem: Index: XMLReport.java =================================================================== RCS file: /home/cvspublic/jakarta- ant/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/XMLReport.java,v retrieving revision 1.1 diff -u -r1.1 XMLReport.java --- XMLReport.java 2001/07/31 08:40:12 1.1 +++ XMLReport.java 2001/09/14 18:18:23 @@ -88,6 +88,9 @@ /** parsed document */ protected Document report; + /** mapping of class names to <code>ClassFile</code>s from the reference classpath. It is used to filter the JProbe report. */ + protected Hashtable classFiles; + /** mapping package name / package node for faster access */ protected Hashtable pkgMap; @@ -155,7 +158,7 @@ methodname.delete(methodname.toString ().indexOf("(") , methodname.toString().length()); String signature = classname + "." + methodname + "()"; if (filters.accept(signature)){ - log("keeped method:" + signature); + log("kept method:" + signature); nbmethods++; } else { @@ -163,7 +166,7 @@ } } // if we don't keep any method, we don't keep the class - if (nbmethods != 0){ + if (nbmethods != 0 && classFiles.containsKey (classname)){ log("Adding class '" + classname + "'"); classMap.put(classname, clazz); nbclasses++; @@ -186,19 +189,8 @@ /** create the whole new document */ public Document createDocument(String[] classPath) throws Exception { - DocumentBuilder dbuilder = newBuilder(); - InputSource is = new InputSource( new FileInputStream(file) ); - if (jprobeHome != null){ - File dtdDir = new File(jprobeHome, "Dtd/snapshot.dtd"); - is.setSystemId( "file:///" + dtdDir.getAbsolutePath() ); - } - report = dbuilder.parse( is ); - report.normalize(); - - // create maps for faster node access - createNodeMaps(); - - // iterate over the classpath... + // Iterate over the classpath to identify reference classes + classFiles = new Hashtable(); ClassPathLoader cpl = new ClassPathLoader(classPath); Enumeration enum = cpl.loaders(); while ( enum.hasMoreElements() ){ @@ -207,8 +199,28 @@ log("Processing " + classes.length + " classes in " + fl.getFile()); // process all classes for (int i = 0; i < classes.length; i++){ - serializeClass(classes[i]); + classFiles.put(classes[i].getFullName(), classes [i]); } + } + + // Load the JProbe coverage XML report + DocumentBuilder dbuilder = newBuilder(); + InputSource is = new InputSource( new FileInputStream(file) ); + if (jprobeHome != null){ + File dtdDir = new File(jprobeHome, "Dtd"); + is.setSystemId( "file:///" + dtdDir.getAbsolutePath() + "/"); + } + report = dbuilder.parse( is ); + report.normalize(); + + // create maps for faster node access (also filters out unwanted nodes) + createNodeMaps(); + + // Make sure each class from the reference path ends up in the report + Enumeration classes = classFiles.elements(); + while ( classes.hasMoreElements() ){ + ClassFile cf = (ClassFile) classes.nextElement(); + serializeClass(cf); } // update the document with the stats update();
