removeIds(child);
}
}
public void compareTestResults(RuleSet rs) throws Exception {
XMLPrinter report = new XMLPrinter(compareTestResultsReport(rs));
ostream.println();
report.opentag("results");
File outputs = new File(getOutputDirectory(rs));
if(outputs == null || !outputs.isDirectory()){
ostream.println("'"+getOutputDirectory(rs)+"' does not exist or is not a directory");
}
boolean changes = false;
boolean missingResults = false;
File files[] = outputs.listFiles();
for(File file : files){
if(file.getName().endsWith("_results.xml")){
Node result1=null, result2=null;
try{
result1 = XMLTree.BuildTree(new FileInputStream(file),false,false);
result2 = XMLTree.BuildTree(new FileInputStream(getResultDirectory(rs)+file.getName()),false, false);
if(result1 != null && result2 != null){
removeIds(result1);
removeIds(result2);
String msg = compareNodes(result1,result2);
if(msg == null){
report.printdata("match","file",file.getName(),"");
}else{
changes = true;
ostream.flush();
estream.println(file.getName()+"--> "+msg);
estream.flush();
report.printdata("resultChanged","file",file.getName(),msg);
}
}else{
ostream.flush();
estream.println(file.getName()+" has no result file; No compare done.");
estream.flush();
report.printdata("error","file",file.getName(),"");
}
}catch (Exception e){
missingResults = true;
report.printdata("unknown","file",file.getName(),"Missing Files to do the compare");
}
}
}
report.closetag();
if(changes){
estream.println("\nSome results have changed. Check the TestResults.xml for all results.");
}else{
ostream.println("\nALL PASS: No changes found when compared to results files.");