Skip to content
This repository was archived by the owner on Nov 15, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
633f404
add visited class/method to summary #283
sawilde Apr 3, 2015
8182da7
Merge branch 'master' of https://github.com/OpenCover/opencover
sawilde Apr 3, 2015
97aa049
Merge pull request #286 from sawilde/master
sawilde Apr 4, 2015
2c780de
build and tools folders are considered vendored by Github Linguist
molnargab Apr 18, 2015
c3aa0a2
Merge pull request #294 from molnargab/github_linguist_fix
sawilde Apr 19, 2015
903445f
get release notes up to date - I have been slack
sawilde Apr 25, 2015
b75c59c
#295 detect if assembly should be filtered
sawilde Apr 25, 2015
437877a
#295 mark assembly as skipped if excluded by attribute
sawilde Apr 25, 2015
e79adb3
#288 wrap getting method body - report if exception thrown
sawilde Apr 25, 2015
7e927d4
#287 handle vector subscript issue - though [] is supposed to grow dy…
sawilde Apr 25, 2015
fd74c6e
update release notes
sawilde Apr 25, 2015
2d1b3d0
Merge pull request #296 from sawilde/master
sawilde Apr 25, 2015
ea110c5
#288 skip methods for which we cannot decode the body using mono.cecil
sawilde Apr 26, 2015
b0b2fb5
Merge pull request #297 from sawilde/master
sawilde Apr 27, 2015
d2975cf
#298 upgrade to latest mono cecil - passes dogfood tests
sawilde Apr 27, 2015
aefd5ad
update packages
sawilde Apr 28, 2015
e6b3c9f
update reportgenerator
sawilde Apr 28, 2015
6fccfd2
update nunit
sawilde Apr 28, 2015
6eca966
Merge pull request #299 from sawilde/cecil_upg_298
sawilde Apr 28, 2015
fd4418a
Sync CorClr_Profiler_Path with Cor_Profiler_Path
May 20, 2015
78619cf
Adjusting unit tests for CorClr_Profiler_Path
May 20, 2015
560e4dd
Merge pull request #305 from istanishev/fix_corclr_path
sawilde May 20, 2015
34773d2
fixed hyperlink in usage
molnargab May 1, 2015
deba570
extracted performance counter creation from Main
molnargab May 1, 2015
30a74a9
created version command-line switch
molnargab May 1, 2015
bf1a613
extracted logger into a field, extracted a new method
molnargab May 23, 2015
66c6681
added a warning for unmanaged application case
molnargab May 23, 2015
72fd51b
Merge pull request #307 from molnargab/master
sawilde May 24, 2015
6fc8352
fixed hyperlink to repository, added -version to arguments
molnargab May 25, 2015
82ccb69
Merge pull request #308 from molnargab/master
sawilde May 25, 2015
4310e0d
Added support for more NUnit test attributes #303
molnargab May 30, 2015
e948046
refactored TrackedMethodStrategies to use base
molnargab May 30, 2015
f3a4861
Merge pull request #309 from molnargab/nunit_attributes
sawilde May 30, 2015
fce924c
Merge branch 'vector_287'
sawilde Jun 6, 2015
3f177a1
update release notes
sawilde Jun 6, 2015
5db269b
Merge pull request #313 from sawilde/master
sawilde Jun 6, 2015
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/* linguist-vendored
tools/* linguist-vendored
16 changes: 13 additions & 3 deletions ReleaseNotes.tmp
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
Version [[version]]
#244 support ApplicationUnderTest.Launch to propagate required OPENCOVER environment variables
#256 support Microsoft Fakes (feature) - beta support until we bed feature in
#248 address issue with Mono.Cecil and latest PDB (.NET 4.6) version
#307 add -version to args
#305 add corclr_profiler_path support
#303 support for test cases and theories during track by test
#295 exclude assembly by attribute (feature)
#288 report (to console) if can't ready body of method (diag)
#287 fix crash
#283 Add visited class/method to summary entity (feature)
#274 Use thread based buffers for performance improvement (fix)

Version 4.5.3723
#244 support ApplicationUnderTest.Launch to propagate required OPENCOVER environment variables (feature)
#256 support Microsoft Fakes (feature) - beta support until we bed feature in (feature)
#248 address issue with Mono.Cecil and latest PDB (.NET 4.6) version (fix)
#252 use AppVeyor for building code and pull requests (prj-mgmt)

Version 4.5.3522
Expand Down
4 changes: 2 additions & 2 deletions build/opencover.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

<property name="configuration" value="debug" unless="${property::exists('configuration')}" />
<property name="platform" value="x86" unless="${property::exists('platform')}" />
<property name="nunit.path" value="${solution.folder}/packages/NUnit.Runners.2.6.3/tools"/>
<property name="nunit.path" value="${solution.folder}/packages/NUnit.Runners.2.6.4/tools"/>
<property name="windows-path" value="${string::to-lower(environment::get-variable('PATH'))}"/>
<property name="nunit-in-path" value="${string::contains(windows-path, 'nunit')}"/>
<property name="open-cover-test-console" value="${solution.folder}/bin/${configuration}/OpenCover.Test.Profiler.exe"/>
<property name="curl.exe" value="${solution.folder}/packages/curl.7.30.0.2/tools/native/v110/Win32/Release/static/curl.exe" />
<property name="coveralls.exe" value="${solution.folder}/packages/coveralls.io.1.1.86/tools/coveralls.net.exe"/>
<property name="coveralls.exe" value="${solution.folder}/packages/coveralls.io.1.3.4/tools/coveralls.net.exe"/>

<property name="msbuild.exe" value="${program.files.x86}/MSBuild/12.0/Bin/MSBuild.exe" if="${directory::exists(program.files.x86 + '/MSBuild/12.0/Bin')}" />
<property name="msbuild.exe" value="${netfx4.folder}/MSBuild.exe" unless="${property::exists('msbuild.exe')}"/>
Expand Down
6 changes: 3 additions & 3 deletions main/.nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="coveralls.io" version="1.1.86" />
<package id="coveralls.io" version="1.3.4" />
<package id="curl" version="7.30.0.2" />
<package id="Mono.Gendarme" version="2.11.0.20121120" />
<package id="Mono.pdb2mdb" version="0.1.0.20130128" />
<package id="NUnit.Runners" version="2.6.3" />
<package id="ReportGenerator" version="2.0.0.0" />
<package id="NUnit.Runners" version="2.6.4" />
<package id="ReportGenerator" version="2.1.4.0" />
<package id="xunit.runners" version="1.9.2" />
</packages>
175 changes: 98 additions & 77 deletions main/OpenCover.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ namespace OpenCover.Console
{
class Program
{
private static readonly ILog Logger = LogManager.GetLogger(typeof(Bootstrapper));

/// <summary>
/// This is the initial console harness - it may become the full thing
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
static int Main(string[] args)
{

var returnCode = 0;
int returnCode;
var returnCodeOffset = 0;
var logger = LogManager.GetLogger(typeof (Bootstrapper));

try
{
CommandLineParser parser;
Expand All @@ -43,86 +44,80 @@ static int Main(string[] args)

returnCodeOffset = parser.ReturnCodeOffset;
var filter = BuildFilter(parser);
var perfCounter = CreatePerformanceCounter(parser);

string outputFile;
if (!GetFullOutputFile(parser, out outputFile)) return returnCodeOffset + 1;

IPerfCounters perfCounter = new NullPerfCounter();
if (parser.EnablePerformanceCounters)
using (var container = new Bootstrapper(Logger))
{
if (new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator))
{
perfCounter = new PerfCounters();
}
else
{
throw new InvalidCredentialException("You must be running as an Administrator to enable performance counters.");
}
var persistance = new FilePersistance(parser, Logger);
container.Initialise(filter, parser, persistance, perfCounter);
persistance.Initialise(outputFile, parser.MergeExistingOutputFile);
returnCode = RunWithContainer(parser, container, persistance);
}

using (var container = new Bootstrapper(logger))
perfCounter.ResetCounters();
}
catch (Exception ex)
{
if (Logger.IsFatalEnabled)
{
var persistance = new FilePersistance(parser, logger);
container.Initialise(filter, parser, persistance, perfCounter);
persistance.Initialise(outputFile, parser.MergeExistingOutputFile);
var registered = false;
Logger.FatalFormat("An exception occured: {0}", ex.Message);
Logger.FatalFormat("stack: {0}", ex.StackTrace);
}

try
{
if (parser.Register)
{
ProfilerRegistration.Register(parser.Registration);
registered = true;
}
returnCode = returnCodeOffset + 1;
}

var harness = container.Resolve<IProfilerManager>();
return returnCode;
}

private static int RunWithContainer(CommandLineParser parser, Bootstrapper container, IPersistance persistance)
{
var returnCode = 0;
var registered = false;

var servicePrincipal =
(parser.Service
? new[] { ServiceEnvironmentManagement.MachineQualifiedServiceAccountName(parser.Target) }
: new string[0]).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
try
{
if (parser.Register)
{
ProfilerRegistration.Register(parser.Registration);
registered = true;
}

harness.RunProcess(environment =>
{
returnCode = 0;
if (parser.Service)
{
RunService(parser, environment, logger);
}
else
{
returnCode = RunProcess(parser, environment);
}
}, servicePrincipal);
var harness = container.Resolve<IProfilerManager>();

DisplayResults(persistance, parser, logger);
var servicePrincipal =
(parser.Service
? new[] {ServiceEnvironmentManagement.MachineQualifiedServiceAccountName(parser.Target)}
: new string[0]).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();

}
catch (Exception ex)
harness.RunProcess(environment =>
{
if (parser.Service)
{
Trace.WriteLine(string.Format("Exception: {0}\n{1}", ex.Message, ex.InnerException));
throw;
RunService(parser, environment, Logger);
returnCode = 0;
}
finally
else
{
if (parser.Register && registered)
ProfilerRegistration.Unregister(parser.Registration);
returnCode = RunProcess(parser, environment);
}
}
}, servicePrincipal);

perfCounter.ResetCounters();
DisplayResults(persistance, parser, Logger);
}
catch (Exception ex)
{
if (logger.IsFatalEnabled)
{
logger.FatalFormat("An exception occured: {0}", ex.Message);
logger.FatalFormat("stack: {0}", ex.StackTrace);
}

returnCode = returnCodeOffset + 1;
Trace.WriteLine(string.Format("Exception: {0}\n{1}", ex.Message, ex.InnerException));
throw;
}
finally
{
if (parser.Register && registered)
ProfilerRegistration.Unregister(parser.Registration);
}

return returnCode;
}

Expand Down Expand Up @@ -323,15 +318,10 @@ private static void DisplayResults(IPersistance persistance, ICommandLine parser

var coverageSession = persistance.CoverageSession;

var totalClasses = 0;
var visitedClasses = 0;

var altTotalClasses = 0;
var altVisitedClasses = 0;

var totalMethods = 0;
var visitedMethods = 0;

var altTotalMethods = 0;
var altVisitedMethods = 0;

Expand All @@ -349,12 +339,9 @@ from @class in module.Classes.Where(c => !c.ShouldSerializeSkippedDueTo())

if ((@class.Methods.Any(x => !x.ShouldSerializeSkippedDueTo() && x.SequencePoints.Any(y => y.VisitCount > 0))))
{
visitedClasses += 1;
totalClasses += 1;
}
else if ((@class.Methods.Any(x => x.FileRef != null)))
{
totalClasses += 1;
unvisitedClasses.Add(@class.FullName);
}

Expand All @@ -372,12 +359,9 @@ from @class in module.Classes.Where(c => !c.ShouldSerializeSkippedDueTo())
{
if ((method.SequencePoints.Any(x => x.VisitCount > 0)))
{
visitedMethods += 1;
totalMethods += 1;
}
else if (method.FileRef != null)
{
totalMethods += 1;
unvisitedMethods.Add(string.Format("{0}", method.Name));
}

Expand All @@ -390,12 +374,12 @@ from @class in module.Classes.Where(c => !c.ShouldSerializeSkippedDueTo())
}
}

if (totalClasses > 0)
{
logger.InfoFormat("Visited Classes {0} of {1} ({2})", visitedClasses,
totalClasses, Math.Round(visitedClasses * 100.0 / totalClasses, 2));
logger.InfoFormat("Visited Methods {0} of {1} ({2})", visitedMethods,
totalMethods, Math.Round(visitedMethods * 100.0 / totalMethods, 2));
if (coverageSession.Summary.NumClasses > 0)
{
logger.InfoFormat("Visited Classes {0} of {1} ({2})", coverageSession.Summary.VisitedClasses,
coverageSession.Summary.NumClasses, Math.Round(coverageSession.Summary.VisitedClasses * 100.0 / coverageSession.Summary.NumClasses, 2));
logger.InfoFormat("Visited Methods {0} of {1} ({2})", coverageSession.Summary.VisitedMethods,
coverageSession.Summary.NumMethods, Math.Round(coverageSession.Summary.VisitedMethods * 100.0 / coverageSession.Summary.NumMethods, 2));
logger.InfoFormat("Visited Points {0} of {1} ({2})", coverageSession.Summary.VisitedSequencePoints,
coverageSession.Summary.NumSequencePoints, coverageSession.Summary.SequenceCoverage);
logger.InfoFormat("Visited Branches {0} of {1} ({2})", coverageSession.Summary.VisitedBranchPoints,
Expand Down Expand Up @@ -469,6 +453,27 @@ private static IFilter BuildFilter(CommandLineParser parser)
return filter;
}

private static IPerfCounters CreatePerformanceCounter(CommandLineParser parser)
{
if (parser.EnablePerformanceCounters)
{
if (new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator))
{
return new PerfCounters();
}
else
{
throw new InvalidCredentialException(
"You must be running as an Administrator to enable performance counters.");
}
}
else
{
return new NullPerfCounter();
}
}


private static bool ParseCommandLine(string[] args, out CommandLineParser parser)
{
try
Expand All @@ -491,6 +496,22 @@ private static bool ParseCommandLine(string[] args, out CommandLineParser parser
return false;
}


if (parser.PrintVersion)
{
var entryAssembly = System.Reflection.Assembly.GetEntryAssembly();
if (entryAssembly == null)
{
Logger.Warn("No entry assembly, running from unmanaged application");
}
else
{
var version = entryAssembly.GetName().Version;
System.Console.WriteLine("OpenCover version {0}", version);
return false;
}
}

if (!string.IsNullOrWhiteSpace(parser.TargetDir) && !Directory.Exists(parser.TargetDir))
{
System.Console.WriteLine("TargetDir '{0}' cannot be found - have you specified your arguments correctly?", parser.TargetDir);
Expand Down
2 changes: 1 addition & 1 deletion main/OpenCover.Console/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Mono.Cecil" publicKeyToken="0738eb9f132ed756" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-0.9.5.0" newVersion="0.9.5.0" />
<bindingRedirect oldVersion="0.0.0.0-0.9.6.0" newVersion="0.9.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
Expand Down
Binary file modified main/OpenCover.Documentation/Usage.pdf
Binary file not shown.
Loading