internal void InsertBaseline(Stats stats) { if (stats.BaselineVersion == stats.AnalyzedVersion) { this.BL0 = stats; return; } // earlier if (BL1.BaselineVersion == null) { BL1 = stats; return; } if (string.Compare(stats.BaselineVersion, BL1.BaselineVersion) < 0) { BL2 = stats; } else { // swap BL2 = BL1; BL1 = stats; } }
static void RunOne(string dir, Results results) { if (!Directory.Exists(dir)) { Console.WriteLine("Directory {0} does not exist", dir); } string analyzedVersion = "<dummy>"; MatchOneValue(ref analyzedVersion, dir, @"(^|[\\/])(\d+)", groupNo: 2); Dictionary<string,Result> localResults = new Dictionary<string,Result>(); foreach (var file in Directory.EnumerateFiles(dir, "*.txt")) { var original = file.Contains("save"); var vmatch = Regex.Match(file, @"buildlog.(\d+)"); if (!vmatch.Success) continue; var version = vmatch.Groups[1].Value; var stats = OneFileStats(file); foreach (var projPair in stats) { var current = GetProjectResult(localResults, projPair.Key); Contract.Assume(current != null); var stat = new Stats { ProjectName = projPair.Key, AnalyzedVersion = analyzedVersion, BaselineVersion = version, Checked = projPair.Value.Checked, Correct = projPair.Value.Correct, MethodsAnalyzed = projPair.Value.MethodsAnalyzed, MethodsWith0Warnings = projPair.Value.MethodsWith0Warnings, Unknown = projPair.Value.Unknown, Unreached = projPair.Value.Unreached }; if (original) { current.Original = stat; } else { current.InsertBaseline(stat); } } } foreach (var pair in localResults) { var list = GetProjectResults(results, pair.Key); list.Add(pair.Value); } }
private static Stats Minimum(Stats stats1, Stats stats2) { if (stats1.Warnings == null || stats2.Warnings == null) return stats1; int w1, w2; if (!Int32.TryParse(stats1.Warnings, out w1) || !Int32.TryParse(stats2.Warnings, out w2)) return stats1; if (w1 < w2) return stats1; return stats2; }