Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #490 from OpenCover/master
Browse files Browse the repository at this point in the history
create a release-candidate
  • Loading branch information
sawilde committed Jan 18, 2016
2 parents 7c36a1e + 2458590 commit cfe5959
Show file tree
Hide file tree
Showing 17 changed files with 346 additions and 203 deletions.
45 changes: 28 additions & 17 deletions main/OpenCover.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Program
/// <returns></returns>
static int Main(string[] args)
{
int returnCode;
var returnCode = 0;
var returnCodeOffset = 0;

AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
Expand Down Expand Up @@ -66,18 +66,26 @@ static int Main(string[] args)
container.Initialise(filter, parser, persistance, perfCounter);
if (!persistance.Initialise(outputFile, parser.MergeExistingOutputFile))
return returnCodeOffset + 1;

returnCode = RunWithContainer(parser, container, persistance);
}

perfCounter.ResetCounters();
}
catch (ExitApplicationWithoutReportingException eex)
{
Logger.ErrorFormat("If you are unable to resolve the issue please contact the OpenCover development team");
Logger.ErrorFormat("see https://www.github.com/opencover/opencover/issues");
returnCode = returnCodeOffset + 1;
}
catch (Exception ex)
{
Logger.Fatal("At: Program.Main");
Logger.FatalFormat("An {0} occured: {1}", ex.GetType(), ex.Message);
Logger.FatalFormat("stack: {0}", ex.StackTrace);
Logger.FatalFormat("A report has been sent to the OpenCover development team...");
Logger.FatalFormat("A report has been sent to the OpenCover development team.");
Logger.ErrorFormat("If you are unable to resolve the issue please contact the OpenCover development team");
Logger.ErrorFormat("see https://www.github.com/opencover/opencover/issues");

ReportCrash(ex);

Expand Down Expand Up @@ -356,12 +364,21 @@ private static int RunProcess(CommandLineParser parser, Action<StringDictionary>
startInfo.UseShellExecute = false;
startInfo.WorkingDirectory = parser.TargetDir;

var process = Process.Start(startInfo);
process.WaitForExit();
try
{
var process = Process.Start(startInfo);
process.WaitForExit();

if (parser.ReturnTargetCode)
returnCode = process.ExitCode;
return returnCode;
if (parser.ReturnTargetCode)
returnCode = process.ExitCode;
return returnCode;
}
catch (Exception ex)
{
ex.InformUser();
Logger.ErrorFormat("Failed to execute the following command '{0} {1}'", startInfo.FileName, startInfo.Arguments);
throw new ExitApplicationWithoutReportingException();
}
}

private static void DisplayResults(CoverageSession coverageSession, ICommandLine parser, ILog logger)
Expand Down Expand Up @@ -510,16 +527,10 @@ private static IPerfCounters CreatePerformanceCounter(CommandLineParser parser)
{
return new PerfCounters();
}
else
{
throw new InvalidCredentialException(
"You must be running as an Administrator to enable performance counters.");
}
}
else
{
return new NullPerfCounter();
Logger.Error("You must be running as an Administrator to enable performance counters.");
throw new ExitApplicationWithoutReportingException();
}
return new NullPerfCounter();
}


Expand Down
6 changes: 3 additions & 3 deletions main/OpenCover.Framework/Communication/MessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private int HandleGetSequencePointsMessage(IntPtr pinnedMemory, IManagedCommunic
{
var request = _marshalWrapper.PtrToStructure<MSG_GetSequencePoints_Request>(pinnedMemory);
InstrumentationPoint[] origPoints;
_profilerCommunication.GetSequencePoints(request.processName, request.modulePath, request.assemblyName,
_profilerCommunication.GetSequencePoints(request.processPath, request.modulePath, request.assemblyName,
request.functionToken, out origPoints);
var num = origPoints.Maybe(o => o.Length);

Expand Down Expand Up @@ -169,7 +169,7 @@ private int HandleGetBranchPointsMessage(IntPtr pinnedMemory, IManagedCommunicat
{
var request = _marshalWrapper.PtrToStructure<MSG_GetBranchPoints_Request>(pinnedMemory);
BranchPoint[] origPoints;
_profilerCommunication.GetBranchPoints(request.processName, request.modulePath, request.assemblyName,
_profilerCommunication.GetBranchPoints(request.processPath, request.modulePath, request.assemblyName,
request.functionToken, out origPoints);
var num = origPoints.Maybe(o => o.Length);

Expand Down Expand Up @@ -290,7 +290,7 @@ private int HandleTrackAssemblyMessage(IntPtr pinnedMemory)
try
{
var request = _marshalWrapper.PtrToStructure<MSG_TrackAssembly_Request>(pinnedMemory);
response.track = _profilerCommunication.TrackAssembly(request.processName, request.modulePath, request.assemblyName);
response.track = _profilerCommunication.TrackAssembly(request.processPath, request.modulePath, request.assemblyName);
}
catch (Exception ex)
{
Expand Down
6 changes: 3 additions & 3 deletions main/OpenCover.Framework/Communication/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public struct MSG_TrackAssembly_Request
/// The path to the process
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)]
public string processName;
public string processPath;

/// <summary>
/// The path to the module/assembly
Expand Down Expand Up @@ -144,7 +144,7 @@ public struct MSG_GetSequencePoints_Request
/// The path to the process
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)]
public string processName;
public string processPath;

/// <summary>
/// The path to the module hosting the emthod
Expand Down Expand Up @@ -214,7 +214,7 @@ public struct MSG_GetBranchPoints_Request
/// The path to the process
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)]
public string processName;
public string processPath;

/// <summary>
/// The path to the module hosting the emthod
Expand Down
Loading

0 comments on commit cfe5959

Please sign in to comment.