-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for an intermediate result.
This commits adds the option `IntermediateResult`, which will write the raw coverage result to an intermediate file, and merge the result of the next run with that file. This is useful in multi-project solutions. Eventually, the last coverage run will produce a report with the combined results of all the runs.
- Loading branch information
Showing
14 changed files
with
496 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
using Jil; | ||
|
||
namespace Coverlet.Core | ||
{ | ||
|
108 changes: 108 additions & 0 deletions
108
src/coverlet.core/Extensions/CoverageResultExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using Coverlet.Core; | ||
|
||
namespace coverlet.core.Extensions | ||
{ | ||
public static class CoverageResultHelper | ||
{ | ||
public static void Merge(this CoverageResult result, CoverageResult other) | ||
{ | ||
MergeModules(result.Modules, other.Modules); | ||
} | ||
|
||
private static void MergeModules(Modules result, Modules other) | ||
{ | ||
foreach (var keyValuePair in other) | ||
{ | ||
if (!result.ContainsKey(keyValuePair.Key)) | ||
{ | ||
result[keyValuePair.Key] = keyValuePair.Value; | ||
} | ||
else | ||
{ | ||
MergeDocuments(result[keyValuePair.Key], keyValuePair.Value); | ||
} | ||
} | ||
} | ||
|
||
private static void MergeDocuments(Documents result, Documents other) | ||
{ | ||
foreach (var keyValuePair in other) | ||
{ | ||
if (!result.ContainsKey(keyValuePair.Key)) | ||
{ | ||
result[keyValuePair.Key] = keyValuePair.Value; | ||
} | ||
else | ||
{ | ||
MergeClasses(result[keyValuePair.Key], keyValuePair.Value); | ||
} | ||
} | ||
} | ||
|
||
private static void MergeClasses(Classes result, Classes other) | ||
{ | ||
foreach (var keyValuePair in other) | ||
{ | ||
if (!result.ContainsKey(keyValuePair.Key)) | ||
{ | ||
result[keyValuePair.Key] = keyValuePair.Value; | ||
} | ||
else | ||
{ | ||
MergeMethods(result[keyValuePair.Key], keyValuePair.Value); | ||
} | ||
} | ||
} | ||
|
||
private static void MergeMethods(Methods result, Methods other) | ||
{ | ||
foreach (var keyValuePair in other) | ||
{ | ||
if (!result.ContainsKey(keyValuePair.Key)) | ||
{ | ||
result[keyValuePair.Key] = keyValuePair.Value; | ||
} | ||
else | ||
{ | ||
MergeMethod(result[keyValuePair.Key], keyValuePair.Value); | ||
} | ||
} | ||
} | ||
|
||
private static void MergeMethod(Method result, Method other) | ||
{ | ||
MergeLines(result.Lines, other.Lines); | ||
MergeBranches(result.Branches, other.Branches); | ||
} | ||
|
||
private static void MergeBranches(Branches result, Branches other) | ||
{ | ||
foreach (var keyValuePair in other) | ||
{ | ||
if (!result.ContainsKey(keyValuePair.Key)) | ||
{ | ||
result[keyValuePair.Key] = keyValuePair.Value; | ||
} | ||
else | ||
{ | ||
result[keyValuePair.Key].Hits += keyValuePair.Value.Hits; | ||
} | ||
} | ||
} | ||
|
||
private static void MergeLines(Lines result, Lines other) | ||
{ | ||
foreach (var keyValuePair in other) | ||
{ | ||
if (!result.ContainsKey(keyValuePair.Key)) | ||
{ | ||
result[keyValuePair.Key] = keyValuePair.Value; | ||
} | ||
else | ||
{ | ||
result[keyValuePair.Key].Hits += keyValuePair.Value.Hits; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.