Skip to content
Snippets Groups Projects
Commit fa28a0e4 authored by david_williams's avatar david_williams
Browse files

fixes for improved download page processing

parent 50681483
No related branches found
No related tags found
No related merge requests found
/*******************************************************************************
* 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 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);
}
}
}
} 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();
}
}
/*******************************************************************************
* 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;
}
}
......@@ -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 = "";
......@@ -110,8 +108,6 @@ public class ResultsSummaryGenerator extends Task {
// <descriptor, ie. OS name>,path to template file, path to output file
// public String platformSpecificTemplateList = "";
// Location and name of the template drop index.php file.
public String dropTemplateFileName;
// Name of the generated index php file.
public String testResultsHtmlFileName;
......@@ -176,7 +172,6 @@ public class ResultsSummaryGenerator extends Task {
test.setTestResultsTemplateFileName("C:\\junk\\templateFiles\\testResults.php.template");
// test.setPlatformSpecificTemplateList("Windows,C:\\junk\\templateFiles\\platform.php.template,winPlatform.php;Linux,C:\\junk\\templateFiles\\platform.php.template,linPlatform.php;Solaris,C:\\junk\\templateFiles\\platform.php.template,solPlatform.php;AIX,C:\\junk\\templateFiles\\platform.php.template,aixPlatform.php;Macintosh,C:\\junk\\templateFiles\\platform.php.template,macPlatform.php;Source
// Build,C:\\junk\\templateFiles\\sourceBuilds.php.template,sourceBuilds.php");
test.setDropTemplateFileName("C:\\junk\\templateFiles\\index.php.template");
test.setTestResultsHtmlFileName("testResults.php");
// test.setDropHtmlFileName("index.php");
test.setDropHtmlFileName("index.html");
......@@ -191,14 +186,9 @@ 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);
//dropTemplateString = readFile(dropTemplateFileName);
// Specific to the platform build-page
/*
......@@ -232,7 +222,6 @@ public class ResultsSummaryGenerator extends Task {
// writeDropFiles();
// }
// else {
writeDropIndexFile();
// }
}
catch (Exception e) {
......@@ -433,7 +422,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);
......@@ -513,7 +501,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,
......@@ -649,7 +636,6 @@ public class ResultsSummaryGenerator extends Task {
}
private int missingCount;
public boolean includeAll;
private int totalErrors;
private int totalAccess;
......@@ -658,34 +644,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 = formatTestRow(testLogName, -1, -1);
// 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 parseUnitTestXml() throws IOException,
TransformerFactoryConfigurationError, TransformerException {
......@@ -713,8 +671,6 @@ 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 = formatTestRow(xmlFileNames[i].getPath(),
......@@ -734,8 +690,6 @@ public class ResultsSummaryGenerator extends Task {
}
}
// check for missing test logs
replaceString = replaceString + verifyAllTestsRan(xmlDirectoryName);
String tmp = formatTestRow("TOTALS", grandTotalErrors,
grandTotalTests);
......@@ -792,47 +746,6 @@ 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() {
......@@ -1222,24 +1135,7 @@ public class ResultsSummaryGenerator extends Task {
this.dropHtmlFileName = dropHtmlFileName;
}
/**
* Gets the dropTemplateFileName.
*
* @return Returns a String
*/
public String getDropTemplateFileName() {
return dropTemplateFileName;
}
/**
* Sets the dropTemplateFileName.
*
* @param dropTemplateFileName
* The dropTemplateFileName to set
*/
public void setDropTemplateFileName(String dropTemplateFileName) {
this.dropTemplateFileName = dropTemplateFileName;
}
private void getDropTokensFromList(String list) {
StringTokenizer tokenizer = new StringTokenizer(list, ",");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment