From bddb666d830e055ce585dc37f42f9f47db7636ab Mon Sep 17 00:00:00 2001 From: david_williams <david_williams> Date: Sun, 18 Mar 2007 05:16:41 +0000 Subject: [PATCH] post M5 test framework changes --- .../wtp/releng/tools/ErrorTracker.java | 224 ------------------ .../wtp/releng/tools/PlatformStatus.java | 59 ----- .../releng/tools/ResultsSummaryGenerator.java | 128 +++------- 3 files changed, 33 insertions(+), 378 deletions(-) delete mode 100644 archive/releng.builder/tools/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/ErrorTracker.java delete mode 100644 archive/releng.builder/tools/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/PlatformStatus.java diff --git a/archive/releng.builder/tools/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/ErrorTracker.java b/archive/releng.builder/tools/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/ErrorTracker.java deleted file mode 100644 index dc56c82e4..000000000 --- a/archive/releng.builder/tools/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/ErrorTracker.java +++ /dev/null @@ -1,224 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wtp.releng.tools; - -import java.io.IOException; -import java.util.Enumeration; -import java.util.Hashtable; -import java.io.File; - -import java.util.Vector; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.ParserConfigurationException; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * @version 1.0 - * @author - */ -public class ErrorTracker { - - // List of test logs expected at end of build - private Vector testLogs = new Vector(); - - - // Platforms keyed on - private Hashtable platforms = new Hashtable(); - private Hashtable logFiles = new Hashtable(); - private Hashtable typesMap = new Hashtable(); - private Vector typesList = new Vector(); - - public static void main(String[] args) { - - // For testing only. Should not be invoked - - ErrorTracker anInstance = new ErrorTracker(); - anInstance.loadFile("C:\\junk\\testManifest.xml"); - String[] theTypes = anInstance.getTypes(); - for (int i=0; i < theTypes.length; i++) { - // System.out.println("Type: " + theTypes[i]); - PlatformStatus[] thePlatforms = anInstance.getPlatforms(theTypes[i]); - for (int j=0; j < thePlatforms.length; j++) { - // System.out.println("Out ID: " + thePlatforms[j].getId()); - } - } - } - - public void loadFile(String fileName) { - DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder parser=null; - try { - parser = docBuilderFactory.newDocumentBuilder(); - } catch (ParserConfigurationException e1) { - e1.printStackTrace(); - } - try { - if (parser != null) { - Document document = parser.parse(fileName); - NodeList elements = document.getElementsByTagName("platform"); - int elementCount = elements.getLength(); - for (int i = 0; i < elementCount; i++) { - PlatformStatus aPlatform = new PlatformStatus((Element) elements.item(i)); - //System.out.println("ID: " + aPlatform.getId()); - platforms.put(aPlatform.getId(), aPlatform); - - Node zipType = elements.item(i).getParentNode(); - String zipTypeName = (String) zipType.getAttributes().getNamedItem("name").getNodeValue(); - - Vector aVector = (Vector) typesMap.get(zipTypeName); - if (aVector == null) { - typesList.add(zipTypeName); - aVector = new Vector(); - typesMap.put(zipTypeName, aVector); - } - aVector.add(aPlatform.getId()); - - } - - NodeList effectedFiles = document.getElementsByTagName("effectedFile"); - int effectedFilesCount = effectedFiles.getLength(); - for (int i = 0; i < effectedFilesCount; i++) { - Node anEffectedFile = effectedFiles.item(i); - Node logFile = anEffectedFile.getParentNode(); - String logFileName = (String) logFile.getAttributes().getNamedItem("name").getNodeValue(); - logFileName=convertPathDelimiters(logFileName); - String effectedFileID = (String) anEffectedFile.getAttributes().getNamedItem("id").getNodeValue(); - //System.out.println(logFileName); - Vector aVector = (Vector) logFiles.get(logFileName); - if (aVector == null) { - aVector = new Vector(); - logFiles.put(logFileName, aVector); - - } - PlatformStatus ps=(PlatformStatus) platforms.get(effectedFileID); - if (ps!=null) - aVector.addElement(ps); - } - - // store a list of the test logs expected after testing - NodeList testLogList = document.getElementsByTagName("logFile"); - int testLogCount = testLogList.getLength(); - for (int i = 0; i < testLogCount; i++) { - - Node testLog = testLogList.item(i); - String testLogName = (String) testLog.getAttributes().getNamedItem("name").getNodeValue(); - Node typeNode=testLog.getAttributes().getNamedItem("type"); - String type="test"; - if (typeNode!=null){ - type = typeNode.getNodeValue(); - } - if (testLogName.endsWith(".xml")&&type.equals("test")){ - testLogs.add(testLogName); - //System.out.println(testLogName); - } - - } - - -// // Test this mess. -// Object[] results = platforms.values().toArray(); -// for (int i=0; i < results.length; i++) { -// PlatformStatus ap = (PlatformStatus) results[i]; -// System.out.println("ID: " + ap.getId() + " passed: " + ap.getPassed()); -// } -// -// Enumeration anEnumeration = logFiles.keys(); -// while (anEnumeration.hasMoreElements()) { -// String aKey = (String) anEnumeration.nextElement(); -// System.out.println("Whack a key: " + aKey); -// ((PlatformStatus) logFiles.get(aKey)).setPassed(false); -// } -// -// results = platforms.values().toArray(); -// for (int i=0; i < results.length; i++) { -// PlatformStatus ap = (PlatformStatus) results[i]; -// System.out.println("ID: " + ap.getId() + " passed: " + ap.getPassed()); -// } - - } - - - - } catch (IOException e) { - System.out.println("IOException: " + fileName); - // e.printStackTrace(); - - } catch (SAXException e) { - System.out.println("SAXException: " + fileName); - e.printStackTrace(); - - } - } - - public void registerError(String fileName) { - // System.out.println("Found an error in: " + fileName); - if (logFiles.containsKey(fileName)) { - Vector aVector = (Vector) logFiles.get(fileName); - for (int i = 0; i < aVector.size(); i++) { - ((PlatformStatus) aVector.elementAt(i)).registerError(); - } - } else { - - // If a log file is not specified explicitly it effects - // all "platforms" except JDT - - Enumeration values = platforms.elements(); - while (values.hasMoreElements()) { - PlatformStatus aValue = (PlatformStatus) values.nextElement(); - if (!aValue.getId().equals("JA") && - !aValue.getId().equals("EW") && - !aValue.getId().equals("EA")) { - aValue.registerError(); - } - } - } - } - - public boolean hasErrors(String id) { - return ((PlatformStatus) platforms.get(id)).hasErrors(); - } - - // Answer a string array of the zip type names in the order they appear in - // the .xml file. - public String[] getTypes() { - return (String[]) typesList.toArray(new String[typesList.size()]); - } - - // Answer an array of PlatformStatus objects for a given type. - - public PlatformStatus[] getPlatforms(String type) { - Vector platformIDs = (Vector) typesMap.get(type); - PlatformStatus[] result = new PlatformStatus[platformIDs.size()]; - for (int i = 0; i < platformIDs.size(); i++) { - result[i] = (PlatformStatus) platforms.get((String) platformIDs.elementAt(i)); - } - return result; - } - - /** - * Returns the testLogs. - * @return Vector - */ - public Vector getTestLogs() { - return testLogs; - } - - private String convertPathDelimiters(String path){ - return new File(path).getPath(); - } - -} diff --git a/archive/releng.builder/tools/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/PlatformStatus.java b/archive/releng.builder/tools/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/PlatformStatus.java deleted file mode 100644 index 5da345143..000000000 --- a/archive/releng.builder/tools/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/PlatformStatus.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wtp.releng.tools; - -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; - -/** - * @version 1.0 - * @author - */ -public class PlatformStatus { - - private String id; - private String name; - private String fileName; - private boolean hasErrors = false; - - PlatformStatus(Element anElement) { - super(); - NamedNodeMap attributes = anElement.getAttributes(); - this.id = (String) attributes.getNamedItem("id").getNodeValue(); - this.name = (String) attributes.getNamedItem("name").getNodeValue(); - this.fileName = (String) attributes.getNamedItem("fileName").getNodeValue(); - - } - - /** - * Gets the id. - * @return Returns a String - */ - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getFileName() { - return fileName; - } - - public void registerError() { - this.hasErrors = true; - } - - public boolean hasErrors() { - return this.hasErrors; - } -} diff --git a/archive/releng.builder/tools/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/ResultsSummaryGenerator.java b/archive/releng.builder/tools/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/ResultsSummaryGenerator.java index 9a171fb76..723175907 100644 --- a/archive/releng.builder/tools/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/ResultsSummaryGenerator.java +++ b/archive/releng.builder/tools/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/ResultsSummaryGenerator.java @@ -10,7 +10,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.Writer; import java.util.Arrays; -import java.util.Enumeration; import java.util.StringTokenizer; import java.util.Vector; @@ -62,7 +61,6 @@ public class ResultsSummaryGenerator extends Task { public String testResultsWithProblems = EOL; private DocumentBuilder parser = null; - public ErrorTracker anErrorTracker; public String testResultsTemplateString = ""; public String dropTemplateString = ""; @@ -194,11 +192,7 @@ public class ResultsSummaryGenerator extends Task { public void execute() { try { - anErrorTracker = new ErrorTracker(); - // platformDescription = new Vector(); - // platformTemplateString = new Vector(); - // platformDropFileName = new Vector(); - anErrorTracker.loadFile(testManifestFileName); + getDropTokensFromList(dropTokenList); testResultsTemplateString = readFile(testResultsTemplateFileName); dropTemplateString = readFile(dropTemplateFileName); @@ -309,12 +303,13 @@ public class ResultsSummaryGenerator extends Task { serializer.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount", "4"); //$NON-NLS-1$ //$NON-NLS-2$ } catch (IllegalArgumentException e) { - // unsupported properties, so we'll just ignore + System.out.println("Serializer Exception: " + e.getMessage()); } Writer outputWriter = null; try { outputWriter = new FileWriter(outputFile); - serializer.transform(domSource, new StreamResult(outputWriter)); + StreamResult streamResult = new StreamResult(outputWriter); + serializer.transform(domSource, streamResult); } finally { if (outputWriter != null) { outputWriter.close(); @@ -405,9 +400,6 @@ public class ResultsSummaryGenerator extends Task { rowtype = "extraWarningTable"; } } - // - // System.out.println("totalErrors: " + totalErrors); // , - // log("totalErrors: " + totalErrors, Project.MSG_INFO); buffer.append( "<tr CLASS=\"" + rowtype + " " + "bold" + "\">" + EOL + "<td>" @@ -437,7 +429,6 @@ public class ResultsSummaryGenerator extends Task { File.separator, logName.indexOf("_") + 1), "*"); logName = new String(stringBuffer); - anErrorTracker.registerError(logName); } formatCompileErrorRow(log, errorCount, warningCount, forbiddenWarningCount, discouragedWarningCount, buffer); @@ -517,7 +508,6 @@ public class ResultsSummaryGenerator extends Task { File.separator, logName.indexOf("_") + 1), "*"); logName = new String(buffer); - anErrorTracker.registerError(logName); } formatCompileErrorRow(log.replaceAll(".xml", ".html"), errorCount, warningCount, forbiddenWarningCount, discouragedWarningCount, @@ -653,7 +643,6 @@ public class ResultsSummaryGenerator extends Task { } - private int missingCount; public boolean includeAll; private int totalErrors; private int totalAccess; @@ -662,35 +651,6 @@ public class ResultsSummaryGenerator extends Task { private int totaldiscouragedAccessWarningCount; private int totalforbiddenAccessWarningCount; - private String verifyAllTestsRan(String directory) { - Enumeration enumeration = (anErrorTracker.getTestLogs()).elements(); - - String replaceString = ""; - while (enumeration.hasMoreElements()) { - String testLogName = enumeration.nextElement().toString(); - - if (new File(directory + File.separator + testLogName).exists()) - continue; - - anErrorTracker.registerError(testLogName); - - String tmp = formatRow(testLogName, -1, -1, false); - // if (missingCount == 0) { - // replaceString = replaceString + "</table></br>" + EOL + "<table - // width=\"65%\" border=\"1\" bgcolor=\"#EEEEEE\" rules=\"groups\" - // align=\"center\">" + "<tr bgcolor=\"#9999CC\"> <th - // width=\"80%\" align=\"center\"> Missing Files </th><th - // align=\"center\"> Status </th></tr>"; - // } - replaceString = replaceString + tmp; - testResultsWithProblems = testResultsWithProblems.concat(EOL - + testLogName.substring(0, testLogName.length() - 4) - + " (file missing)"); - missingCount++; - } - return replaceString; - } - private void parseXml() throws IOException, TransformerFactoryConfigurationError, TransformerException { @@ -717,12 +677,10 @@ public class ResultsSummaryGenerator extends Task { 0, xmlFileNames[i].getName().length() - 4); testResultsWithProblems = testResultsWithProblems .concat(EOL + testName); - anErrorTracker.registerError(fullName - .substring(getXmlDirectoryName().length() + 1)); } - String tmp = formatRow(xmlFileNames[i].getPath(), - errorCount, unitTestResults.getTotalTests(), true); + String tmp = formatTestRow(xmlFileNames[i].getPath(), + errorCount, unitTestResults.getTotalTests()); replaceString = replaceString + tmp; if (errorCount > 0) { @@ -739,8 +697,9 @@ public class ResultsSummaryGenerator extends Task { } } - // check for missing test logs - //replaceString = replaceString + verifyAllTestsRan(xmlDirectoryName); + String tmp = formatTestRow("TOTALS", grandTotalErrors, + grandTotalTests); + replaceString = replaceString + tmp; testResultsTemplateString = replace(testResultsTemplateString, testResultsToken, replaceString); @@ -775,7 +734,6 @@ public class ResultsSummaryGenerator extends Task { addSummaryNodeTo(rootNode, "grandTotalErrors", grandTotalErrors); addSummaryNodeTo(rootNode, "grandTotalTests", grandTotalTests); serialize(rootNode, file); - } private String replace(String source, String original, String replacement) { @@ -796,47 +754,12 @@ public class ResultsSummaryGenerator extends Task { private void writeDropIndexFile() { - String[] types = anErrorTracker.getTypes(); - for (int i = 0; i < types.length; i++) { - PlatformStatus[] platforms = anErrorTracker.getPlatforms(types[i]); - String replaceString = processDropRows(platforms); - // System.out.println("replaceString: " + replaceString); - // System.out.println("dropTemplateString: " + - // dropTemplateString); - // System.out.println("dropToken: " + - // dropTokens.get(i).toString()); - dropTemplateString = replace(dropTemplateString, dropTokens.get(i) - .toString(), replaceString); - } // Replace the token %testsStatus% with the status of the test results - // dropTemplateString = replace(dropTemplateString, "%testsStatus%", - // testResultsStatus); String outputFileName = dropDirectoryName + File.separator + dropHtmlFileName; writeFile(outputFileName, dropTemplateString); } - private String processDropRows(PlatformStatus[] platforms) { - - String result = ""; - for (int i = 0; i < platforms.length; i++) { - result = result + processDropRow(platforms[i]); - } - - return result; - } - - private String processDropRow(PlatformStatus aPlatform) { - - String result = "<tr>"; - result = result + aPlatform.getFileName(); - - result = result + "</tr>" + EOL; - // System.out.println("aPlatform: " + aPlatform.getFileName()); - // System.out.println("dropRow: " + result); - return result; - } - private void writeTestResultsFile() { String outputFileName = dropDirectoryName + File.separator @@ -1010,23 +933,20 @@ public class ResultsSummaryGenerator extends Task { return result; } - private String formatRow(String fileName, int errorCount, int totalTests, - boolean link) { + private String formatTestRow(String fileName, int errorCount, int totalTests) { // replace .xml with .html String aString = ""; - if (!link) { - return "<tr><td>" + fileName + " (missing)" + "</td><td>" + "DNF"; - } if (fileName.endsWith(".xml")) { int begin = fileName.lastIndexOf(File.separatorChar); int end = fileName.lastIndexOf(".xml"); - String shortName = fileName.substring(begin + 1, end); - String displayName = shortName.substring(0, shortName.length() - 1); + String shortName = fileName.substring(begin + 1, end + 1); + String displayName = shortName; + // shortName.substring(0, shortName.length() - 1); String rowtype = "normaltable"; if (errorCount > 0 || errorCount < 0) { @@ -1042,8 +962,10 @@ public class ResultsSummaryGenerator extends Task { if (errorCount < 0) { aString = aString + "<td>" + displayName + "</td>" + EOL; - aString = aString + "<td>DNF</td>" + EOL; - aString = aString + "<td> " + " </td>" + EOL; + aString = aString + "<td CLASS=\"" + "numeric" + "\">" + "DNF" + + "</td>" + EOL; + aString = aString + "<td CLASS=\"" + "numeric" + "\">" + "0" + + " </td>" + EOL; } else { aString = aString + "<td>" + "<a href=" + "\"" + hrefTestResultsTargetPath + "/" + shortName + ".html" @@ -1058,6 +980,22 @@ public class ResultsSummaryGenerator extends Task { aString = aString + "</tr>" + EOL; } + else { + // not really file name (but "TOTALS") + String displayName = fileName; + String rowtype = "bold"; + if (errorCount > 0) { + rowtype = "errortable" + " " + rowtype; + } + aString = aString + "<tr CLASS=\"" + rowtype + "\">" + EOL; + aString = aString + "<td>" + displayName + "</td>" + EOL; + aString = aString + "<td CLASS=\"" + "numeric" + "\">" + + String.valueOf(errorCount) + "</td>" + EOL; + aString = aString + "<td CLASS=\"" + "numeric" + "\">" + + String.valueOf(totalTests) + "</td>" + EOL; + + } + return aString; } -- GitLab