Skip to content

Branch Enhancements #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 142 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
e2c5083
Update README.md
laurentkempe Mar 21, 2018
3356733
Merge pull request #2 from laurentkempe/patch-1
tonerdo Mar 21, 2018
b9e166b
upload coverage result only when in release mode
tonerdo Mar 21, 2018
2615589
ensure instrumentation code becomes the new target
tonerdo Mar 22, 2018
2975716
Merge pull request #10 from tonerdo/improve-coverage-accuracy
tonerdo Mar 22, 2018
8932833
update README.md, update coveralls badge
tonerdo Mar 23, 2018
e0e11fd
CalculateCoverage: Fix file not foundexception
Mar 23, 2018
3d99e04
update README.md, improve documentation
tonerdo Mar 23, 2018
b60dee1
Add global coverage row
Mar 23, 2018
d102a2a
fix errors when using multiple referenced libraries
Mar 23, 2018
8fce371
remove File.Exists check in Coverage.CalculateCoverage
wlmiller Mar 24, 2018
7bb68ff
Merge pull request #14 from wlmiller/master
tonerdo Mar 24, 2018
7d4ccd2
instrument temp module instead in TestCoverage test function
tonerdo Mar 24, 2018
4e61369
Merge pull request #11 from sbalant/master
tonerdo Mar 24, 2018
44a847a
Merge branch 'master' of github.com:tonerdo/coverlet
tonerdo Mar 24, 2018
cfdbf70
make MarkExecuted method thread safe
tonerdo Mar 24, 2018
fbdbae9
remove total module coverage from summary
tonerdo Mar 24, 2018
a05accb
cleanup hits file
tonerdo Mar 24, 2018
04e223d
switch to stable mono.cecil version
tonerdo Mar 25, 2018
e8f7f78
update README.md, add formats to roadmap section
tonerdo Mar 25, 2018
af021bc
update version numbers
tonerdo Mar 26, 2018
30b94f1
update README.md
tonerdo Mar 26, 2018
27bf3b7
Check for totalLines to be 0 in CoverageSummary.
jeankedotcom Mar 26, 2018
b8dc0bf
Merge pull request #17 from jeankedotcom/summary-error
tonerdo Mar 26, 2018
d3942d2
fix open cover reporter so that it uses unique ids over multiple modules
BlaikiC Mar 27, 2018
5a0f224
Merge pull request #20 from corinblaikie/master
tonerdo Mar 27, 2018
6dde3b0
use official coveralls badge
tonerdo Mar 28, 2018
8810821
bump version numbers
tonerdo Apr 2, 2018
d21c65d
Fixes assembly resolution so it scans the module directory as well.
pms1969 Apr 3, 2018
118cf20
Merge pull request #23 from finbourne/fix/assembly-resolution
tonerdo Apr 3, 2018
f43d730
periodically write to hits count file
tonerdo Apr 6, 2018
ea46174
Merge pull request #27 from tonerdo/ensure-complete-hits-file
tonerdo Apr 6, 2018
667de2c
include branch info in hits file and instrumenter result
tonerdo Mar 31, 2018
eac189e
add branch point information to json format
tonerdo Apr 8, 2018
2b5baa0
specify master branch in appveyor branch
tonerdo Apr 8, 2018
cbce2a1
fix visit count attribute in SequencePoint opencover xml tag
tonerdo Apr 8, 2018
cc35e8e
add branch point info to opencover output format
tonerdo Apr 8, 2018
8ce728a
Merge pull request #31 from tonerdo/branch-coverage
tonerdo Apr 8, 2018
7a974dd
Adds retry functionality to copy back the original assembly.
pms1969 Apr 9, 2018
399305f
Adds retry to file delete.
pms1969 Apr 9, 2018
67b838c
add functionality to fail build if coverage is below a certain threshold
tonerdo Apr 9, 2018
dbd143d
Moves retries into InstrumentationHelper.
pms1969 Apr 10, 2018
19fb576
Merge pull request #35 from finbourne/feature/retry
tonerdo Apr 10, 2018
f356baa
add preliminary support for cobertura output format
tonerdo Apr 12, 2018
17c790b
rename IReporter Format method to Report
tonerdo Apr 12, 2018
1f369ed
restructure coverage reporting classes
tonerdo Apr 12, 2018
9636f8d
add tests for ReporterFactory class
tonerdo Apr 12, 2018
3958eb1
add tests for Cobertura reporter
tonerdo Apr 13, 2018
c4e1209
stop caching nuget packages in appveyor
tonerdo Apr 13, 2018
47d4fba
Merge pull request #41 from tonerdo/corbetura-support
tonerdo Apr 13, 2018
475de54
add coverage calculators to CoverageSummary class
tonerdo Apr 14, 2018
2efa7bc
round coverages to 3 decimal places
tonerdo Apr 14, 2018
6f23831
remove unneeded constructor and field
tonerdo Apr 14, 2018
1d0d71d
remove unneeded CoverageSummaryResult class
tonerdo Apr 14, 2018
8af2df5
fix branch coverage calculation
tonerdo Apr 14, 2018
79fdbb3
add tests for newly added coverage summary methods
tonerdo Apr 14, 2018
4e4b8ec
test delete hits file helper method
tonerdo Apr 14, 2018
27034bc
restructure tests concerning coverage result output
tonerdo Apr 14, 2018
aca3f96
update signatures of calculate coverage methods
tonerdo Apr 14, 2018
983a122
add line and branch coverage info to cobertura report
tonerdo Apr 14, 2018
f03f8ec
add timestamp to cobertura output
tonerdo Apr 14, 2018
1c25313
add line and branch coverage info to opencover report
tonerdo Apr 14, 2018
dcc59e5
retry reading from hits file
tonerdo Apr 15, 2018
a9f77f4
add CODE_OF_CONDUCT.md
tonerdo Apr 15, 2018
3f52ed5
update README.md
tonerdo Apr 15, 2018
499d36e
bump version numbers
tonerdo Apr 16, 2018
8a9fc60
Merge remote-tracking branch 'origin/readme-changes'
tonerdo Apr 16, 2018
02f7d75
fix lcov reporter output
tonerdo Apr 17, 2018
4f2bab8
remove need for overriding StringWriter class
tonerdo Apr 17, 2018
4c7f06f
remove invalid characters from opencover output
tonerdo Apr 17, 2018
55cbea2
fix encoding of cobertura output
tonerdo Apr 17, 2018
4fd9328
fix opencover reportgenerator error
tonerdo Apr 17, 2018
c46d3f7
fix cobertura report generator output
tonerdo Apr 17, 2018
637e241
Merge pull request #50 from tonerdo/output-format-fixes
tonerdo Apr 17, 2018
d1de820
make threshold failure more obvious
tonerdo Apr 17, 2018
92b06b3
Merge pull request #51 from tonerdo/obvious-threshold
tonerdo Apr 17, 2018
dddda6f
bump version number
tonerdo Apr 17, 2018
c5c7352
update package description
tonerdo Apr 17, 2018
df0cfe2
memory optimization for file reading
Apr 20, 2018
76a0f27
Merge pull request #58 from OneCyrus/feat_memoryOptimization
tonerdo Apr 20, 2018
bead19a
feat(msbuild): allow customized output name
Apr 22, 2018
be863bc
fix typo -- O.o
Apr 22, 2018
1f8ab98
include function and branch coverage info lcov output
tonerdo Apr 22, 2018
c02df8e
Merge pull request #61 from automotiveMastermind/set-coverlet-output
tonerdo Apr 23, 2018
29b058d
Implementation exclusion of files according to source file paths (inc…
ido-namely Apr 26, 2018
e99fa0f
Ensure disposables are wrapped in using statements.
sjp Apr 26, 2018
17defb4
addressing first comments
ido-namely Apr 27, 2018
c3d09ed
return full path if base path is empty
tonerdo Apr 28, 2018
0d270b8
Merge pull request #65 from sjp/fix-file-locking
tonerdo Apr 28, 2018
3ae7913
addressing further comments
ido-namely Apr 28, 2018
77b8e37
Implementation exclusion of files according to source file paths (inc…
ido-namely Apr 26, 2018
5fbdb27
addressing first comments
ido-namely Apr 27, 2018
df12ddc
addressing further comments
ido-namely Apr 28, 2018
2be9594
Merge branch 'exclude-files-by-path' of github.com:ido-namely/coverle…
ido-namely Apr 29, 2018
1e8c740
fixing name spaces
ido-namely Apr 29, 2018
c7f47f9
enhance multiple exclustion rules options and add test
ido-namely Apr 29, 2018
c3cfff1
adding support for absolute paths, updating readme files
ido-namely Apr 29, 2018
32e008e
invoke ci
ido-namely Apr 29, 2018
0d3b757
Add tests; modify readme
ido-namely Apr 29, 2018
679ecaa
Merge pull request #64 from ido-namely/exclude-files-by-path
tonerdo Apr 29, 2018
2045d0c
Initial commit of branch enhancements
hunterjm Apr 29, 2018
5da7a49
Initial commit of branch enhancements
Apr 29, 2018
fd35969
move branch lookup logic to helper
hunterjm Apr 29, 2018
e5234d5
move branch lookup logic to helper
Apr 29, 2018
6e942c3
initial breakup of coverage result to lines and branches
hunterjm Apr 30, 2018
8b3a0b8
initial breakup of coverage result to lines and branches
Apr 30, 2018
91f2fd1
remove branches with no sequence point reference
hunterjm Apr 30, 2018
30ad321
remove branches with no sequence point reference
Apr 30, 2018
c9ba521
remove unneeded dependencies
hunterjm Apr 30, 2018
9ed1b14
remove unneeded dependencies
Apr 30, 2018
f980a9c
ignore lcov.info
hunterjm Apr 30, 2018
4726408
ignore lcov.info
Apr 30, 2018
c824132
add EndOffset to branch and OpenCover reporter
hunterjm Apr 30, 2018
1330084
add EndOffset to branch and OpenCover reporter
Apr 30, 2018
3002423
update coverage reporters fixing branch coverage and adding tests
hunterjm Apr 30, 2018
b8360a4
update coverage reporters fixing branch coverage and adding tests
Apr 30, 2018
e904b71
simplify marker and add CecilSymbolHelper tests
hunterjm Apr 30, 2018
e887e63
simplify marker and add CecilSymbolHelper tests
Apr 30, 2018
f613434
remove unused samples
hunterjm Apr 30, 2018
db0b8f5
remove unused samples
Apr 30, 2018
4ea98b9
move extensions, handle overflow for branch count, fix some tests
hunterjm Apr 30, 2018
36e79e2
move extensions, handle overflow for branch count, fix some tests
Apr 30, 2018
c6fa2cf
fix coverage calculations to not be an average of averages
hunterjm Apr 30, 2018
0e41dd1
fix coverage calculations to not be an average of averages
Apr 30, 2018
b3e9471
Add coverage for properties and nested types.
sjp Apr 30, 2018
f360e19
Ensure dependencies are valid .NET assemblies.
sjp Apr 30, 2018
796bbc1
Add namespace to RetryHelper.
sjp Apr 30, 2018
4478f89
use coverage summary in all report generation, final bug fixes in out…
hunterjm May 1, 2018
90b12ab
use coverage summary in all report generation, final bug fixes in out…
May 1, 2018
abec8f8
Fix typo where last brace was removed.
sjp May 1, 2018
d99ab52
Specify what project to add the NuGet
nopara73 May 1, 2018
451c0ee
Change `to` to `in`
nopara73 May 1, 2018
fe86681
Merge pull request #71 from nopara73/patch-1
tonerdo May 1, 2018
67ccdc8
Use Mono.Cecil's IsHidden property instead of checking ourselves.
sjp May 1, 2018
69f095f
Extract method for creating a retry strategy.
sjp May 1, 2018
7412113
Remove unnecessary type and property instrumentation.
sjp May 1, 2018
2be8c81
Merge pull request #68 from sjp/extra-coverage
tonerdo May 1, 2018
59b44af
fix merge conflicts from #68
hunterjm May 1, 2018
a2b616e
fix merge conflicts from #68
May 1, 2018
c4a3ff0
fix import reference for branch instrumentation
hunterjm May 1, 2018
2cb4fc8
fix import reference for branch instrumentation
hunterjm May 1, 2018
4a9e7e1
Merge branch 'feature/branchEnhancements' of github.com:hunterjm/cove…
hunterjm May 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ _TeamCity*
# Visual Studio code coverage results
*.coverage
*.coveragexml
lcov.info

# NCrunch
_NCrunch_*
Expand Down
104 changes: 84 additions & 20 deletions src/coverlet.core/Coverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,90 @@ public CoverageResult GetCoverageResult()
Documents documents = new Documents();
foreach (var doc in result.Documents)
{
// Construct Line Results
foreach (var line in doc.Lines)
{
if (documents.TryGetValue(doc.Path, out Classes classes))
{
if (classes.TryGetValue(line.Class, out Methods methods))
{
if (methods.TryGetValue(line.Method, out Lines lines))
if (methods.TryGetValue(line.Method, out Method method))
{
documents[doc.Path][line.Class][line.Method].Add(line.Number, new LineInfo { Hits = line.Hits, IsBranchPoint = line.IsBranchTarget });
documents[doc.Path][line.Class][line.Method].Lines.Add(line.Number, new LineInfo { Hits = line.Hits });
}
else
{
documents[doc.Path][line.Class].Add(line.Method, new Lines());
documents[doc.Path][line.Class][line.Method].Add(line.Number, new LineInfo { Hits = line.Hits, IsBranchPoint = line.IsBranchTarget });
documents[doc.Path][line.Class].Add(line.Method, new Method());
documents[doc.Path][line.Class][line.Method].Lines.Add(line.Number, new LineInfo { Hits = line.Hits });
}
}
else
{
documents[doc.Path].Add(line.Class, new Methods());
documents[doc.Path][line.Class].Add(line.Method, new Lines());
documents[doc.Path][line.Class][line.Method].Add(line.Number, new LineInfo { Hits = line.Hits, IsBranchPoint = line.IsBranchTarget });
documents[doc.Path][line.Class].Add(line.Method, new Method());
documents[doc.Path][line.Class][line.Method].Lines.Add(line.Number, new LineInfo { Hits = line.Hits });
}
}
else
{
documents.Add(doc.Path, new Classes());
documents[doc.Path].Add(line.Class, new Methods());
documents[doc.Path][line.Class].Add(line.Method, new Lines());
documents[doc.Path][line.Class][line.Method].Add(line.Number, new LineInfo { Hits = line.Hits, IsBranchPoint = line.IsBranchTarget });
documents[doc.Path][line.Class].Add(line.Method, new Method());
documents[doc.Path][line.Class][line.Method].Lines.Add(line.Number, new LineInfo { Hits = line.Hits });
}
}

// Construct Branch Results
foreach (var branch in doc.Branches)
{
if (documents.TryGetValue(doc.Path, out Classes classes))
{
if (classes.TryGetValue(branch.Class, out Methods methods))
{
if (methods.TryGetValue(branch.Method, out Method method))
{
if (method.Branches.TryGetValue(branch.Number, out List<BranchInfo> branchInfo))
{
documents[doc.Path][branch.Class][branch.Method].Branches[branch.Number].Add(new BranchInfo
{ Hits = branch.Hits, Offset = branch.Offset, EndOffset = branch.EndOffset, Path = branch.Path, Ordinal = branch.Ordinal }
);
}
else
{
documents[doc.Path][branch.Class][branch.Method].Branches.Add(branch.Number, new List<BranchInfo>());
documents[doc.Path][branch.Class][branch.Method].Branches[branch.Number].Add(new BranchInfo
{ Hits = branch.Hits, Offset = branch.Offset, EndOffset = branch.EndOffset, Path = branch.Path, Ordinal = branch.Ordinal }
);
}
}
else
{
documents[doc.Path][branch.Class].Add(branch.Method, new Method());
documents[doc.Path][branch.Class][branch.Method].Branches.Add(branch.Number, new List<BranchInfo>());
documents[doc.Path][branch.Class][branch.Method].Branches[branch.Number].Add(new BranchInfo
{ Hits = branch.Hits, Offset = branch.Offset, EndOffset = branch.EndOffset, Path = branch.Path, Ordinal = branch.Ordinal }
);
}
}
else
{
documents[doc.Path].Add(branch.Class, new Methods());
documents[doc.Path][branch.Class].Add(branch.Method, new Method());
documents[doc.Path][branch.Class][branch.Method].Branches.Add(branch.Number, new List<BranchInfo>());
documents[doc.Path][branch.Class][branch.Method].Branches[branch.Number].Add(new BranchInfo
{ Hits = branch.Hits, Offset = branch.Offset, EndOffset = branch.EndOffset, Path = branch.Path, Ordinal = branch.Ordinal }
);
}
}
else
{
documents.Add(doc.Path, new Classes());
documents[doc.Path].Add(branch.Class, new Methods());
documents[doc.Path][branch.Class].Add(branch.Method, new Method());
documents[doc.Path][branch.Class][branch.Method].Branches.Add(branch.Number, new List<BranchInfo>());
documents[doc.Path][branch.Class][branch.Method].Branches[branch.Number].Add(new BranchInfo
{ Hits = branch.Hits, Offset = branch.Offset, EndOffset = branch.EndOffset, Path = branch.Path, Ordinal = branch.Ordinal }
);
}
}
}
Expand All @@ -99,28 +154,37 @@ private void CalculateCoverage()
{
if (!File.Exists(result.HitsFilePath)) { continue; }
var lines = InstrumentationHelper.ReadHitsFile(result.HitsFilePath);
foreach (var line in lines)
foreach (var row in lines)
{
var info = line.Split(',');
var info = row.Split(',');
// Ignore malformed lines
if (info.Length != 4)
continue;

var document = result.Documents.FirstOrDefault(d => d.Path == info[0]);
bool isBranch = info[0] == "B";

var document = result.Documents.FirstOrDefault(d => d.Path == info[1]);
if (document == null)
continue;

int start = int.Parse(info[1]);
int end = int.Parse(info[2]);
bool target = info[3] == "B";
int start = int.Parse(info[2]);

for (int j = start; j <= end; j++)
if (isBranch)
{
var subLine = document.Lines.First(l => l.Number == j);
subLine.Hits = subLine.Hits + 1;

if (j == start)
subLine.IsBranchTarget = target;
uint ordinal = uint.Parse(info[3]);
var branch = document.Branches.First(b => b.Number == start && b.Ordinal == ordinal);
if (branch.Hits != int.MaxValue)
branch.Hits += branch.Hits + 1;
}
else
{
int end = int.Parse(info[3]);
for (int j = start; j <= end; j++)
{
var line = document.Lines.First(l => l.Number == j);
if (line.Hits != int.MaxValue)
line.Hits = line.Hits + 1;
}
}
}

Expand Down
22 changes: 20 additions & 2 deletions src/coverlet.core/CoverageResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,29 @@ namespace Coverlet.Core
public class LineInfo
{
public int Hits { get; set; }
public bool IsBranchPoint { get; set; }
}

public class BranchInfo : LineInfo
{
public int Offset { get; set; }
public int EndOffset { get; set; }
public int Path { get; set; }
public uint Ordinal { get; set; }
}

public class Lines : SortedDictionary<int, LineInfo> { }
public class Methods : Dictionary<string, Lines> { }
public class Branches : SortedDictionary<int, List<BranchInfo>> { }
public class Method
{
internal Method()
{
Lines = new Lines();
Branches = new Branches();
}
public Lines Lines;
public Branches Branches;
}
public class Methods : Dictionary<string, Method> { }
public class Classes : Dictionary<string, Methods> { }
public class Documents : Dictionary<string, Classes> { }
public class Modules : Dictionary<string, Documents> { }
Expand Down
Loading