diff options
author | Sven Gothel <[email protected]> | 2014-05-14 00:21:08 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-05-14 00:21:08 +0200 |
commit | 761667cd9bdf325431bb083d1e3178ff7b681309 (patch) | |
tree | 534f017b55d7c5c31548e6c872d1cf96a58317f1 /src/junit/com/jogamp | |
parent | 044a71481b42eef02e296c92394cbdac756dede6 (diff) |
VersionSemanticsUtil: Produce diff stat per-class w/ diff-type-count and dump diffs per diff-type
Diffstat (limited to 'src/junit/com/jogamp')
-rw-r--r-- | src/junit/com/jogamp/junit/util/VersionSemanticsUtil.java | 95 |
1 files changed, 90 insertions, 5 deletions
diff --git a/src/junit/com/jogamp/junit/util/VersionSemanticsUtil.java b/src/junit/com/jogamp/junit/util/VersionSemanticsUtil.java index 2c1aaf5..786164e 100644 --- a/src/junit/com/jogamp/junit/util/VersionSemanticsUtil.java +++ b/src/junit/com/jogamp/junit/util/VersionSemanticsUtil.java @@ -31,8 +31,13 @@ import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.Set; import org.junit.Assert; @@ -103,15 +108,82 @@ public class VersionSemanticsUtil { resS = "Current version "+curVersionNumber+" is not "+expectedCompatibilityType+" to previous version "+preVersionNumber+", but "+detectedCompatibilityType; } System.err.println(resS); + System.err.println("--------------------------------------------------------------------------------------------------------------"); final Set<Difference> diffs = delta.getDifferences(); - System.err.println(diffs.size()+" differences!"); - int diffI = 0; - for(final Iterator<Difference> iter = diffs.iterator(); iter.hasNext(); diffI++) { + + final List<Difference> diffsAdd = new ArrayList<Difference>(); + final List<Difference> diffsChange = new ArrayList<Difference>(); + final List<Difference> diffsDeprecate = new ArrayList<Difference>(); + final List<Difference> diffsRemove = new ArrayList<Difference>(); + final Map<String, DiffCount> className2DiffCount = new HashMap<String, DiffCount>(); + + int maxClassNameLen = 0; + + for(final Iterator<Difference> iter = diffs.iterator(); iter.hasNext(); ) { final Difference diff = iter.next(); - System.err.printf("Diff %4d: %-11s in class %s%n", diffI, diff.getClass().getSimpleName(), diff.getClassName()); + final String className = diff.getClassName(); + maxClassNameLen = Math.max(maxClassNameLen, className.length()); + + DiffCount dc = className2DiffCount.get(className); + if( null == dc ) { + dc = new DiffCount(className); + className2DiffCount.put(className, dc); + } + + if( diff instanceof Delta.Add ) { + diffsAdd.add(diff); + dc.additions++; + } else if( diff instanceof Delta.Change ) { + diffsChange.add(diff); + dc.changes++; + } else if( diff instanceof Delta.Deprecate ) { + diffsDeprecate.add(diff); + dc.deprecates++; + } else if( diff instanceof Delta.Remove ) { + diffsRemove.add(diff); + dc.removes++; + } + } + Collections.sort(diffsAdd); + Collections.sort(diffsChange); + Collections.sort(diffsDeprecate); + Collections.sort(diffsRemove); + + final List<String> classNames = new ArrayList<String>(className2DiffCount.keySet()); + Collections.sort(classNames); + + System.err.println("Summary: "+diffs.size()+" differences in "+classNames.size()+" classes:"); + System.err.println(" Remove "+diffsRemove.size()+ + ", Change "+diffsChange.size()+ + ", Deprecate "+diffsDeprecate.size()+ + ", Add "+diffsAdd.size()); + System.err.println("--------------------------------------------------------------------------------------------------------------"); + + int iterI = 0; + for(final Iterator<String> iter = classNames.iterator(); iter.hasNext(); iterI++) { + final String className = iter.next(); + final DiffCount dc = className2DiffCount.get(className); + System.err.printf("%4d/%4d: %-"+maxClassNameLen+"s: %s%n", iterI, classNames.size(), className, dc.format(4)); } - Dumper.dump(delta, System.err); + + System.err.println("--------------------------------------------------------------------------------------------------------------"); + System.err.println("Removes"); + System.err.println("--------------------------------------------------------------------------------------------------------------"); + Dumper.dump(diffsRemove, System.err); + System.err.println("--------------------------------------------------------------------------------------------------------------"); + System.err.println("Changes"); + System.err.println("--------------------------------------------------------------------------------------------------------------"); + Dumper.dump(diffsChange, System.err); + System.err.println("--------------------------------------------------------------------------------------------------------------"); + System.err.println("Deprecates"); + System.err.println("--------------------------------------------------------------------------------------------------------------"); + Dumper.dump(diffsDeprecate, System.err); + System.err.println("--------------------------------------------------------------------------------------------------------------"); + System.err.println("Additions"); + System.err.println("--------------------------------------------------------------------------------------------------------------"); + Dumper.dump(diffsAdd, System.err); + System.err.println("=============================================================================================================="); Assert.assertTrue(resS, compOK); @@ -124,4 +196,17 @@ public class VersionSemanticsUtil { final boolean compatible = delta.validate(previous, current); */ } + static class DiffCount { + public DiffCount(String name) { this.name = name; } + public final String name; + public int removes; + public int changes; + public int deprecates; + public int additions; + public String toString() { return name+": Remove "+removes+", Change "+changes+", Deprecate "+deprecates+", Add "+additions; } + public String format(final int digits) { + return String.format("Remove %"+digits+"d, Change %"+digits+"d, Deprecate %"+digits+"d, Add %"+digits+"d", + removes, changes, deprecates, additions); + } + } } |