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 #517 from OpenCover/master
Browse files Browse the repository at this point in the history
create a release-candidate
  • Loading branch information
sawilde committed Jan 26, 2016
2 parents e5ee1c6 + aaf0870 commit 196a957
Show file tree
Hide file tree
Showing 56 changed files with 1,319 additions and 928 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ coverity.zip

#SharpDevelop
/**/OpenCover/coverage.xml

#sonarqube
/.sonarqube
!tools/sonarqube/**/*
/main/OpenCover.SonarQube.sdf
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ OpenCover is a code coverage tool for .NET 2 and above (Windows OSs only - no MO

The latest releases can be downloaded from [releases](https://github.com/opencover/opencover/releases) or from the OpenCover mirror site on [bitbucket](https://bitbucket.org/shaunwilde/opencover/downloads). **Alternatively** why not try the [nuget](http://nuget.org/packages/opencover) package (this is the most popular).

[![Build status](https://img.shields.io/appveyor/ci/sawilde/opencover.svg)](https://ci.appveyor.com/project/sawilde/opencover)
[![Coverage](https://img.shields.io/coveralls/OpenCover/opencover/master.svg)](https://coveralls.io/r/OpenCover/opencover)
[![Coverity](https://scan.coverity.com/projects/3921/badge.svg)](https://scan.coverity.com/projects/opencover-opencover)
[![Nuget](https://img.shields.io/nuget/dt/opencover.svg)](http://nuget.org/packages/opencover)
[![Nuget](https://img.shields.io/nuget/v/opencover.svg)](http://nuget.org/packages/opencover)
[![Nuget](https://img.shields.io/nuget/vpre/opencover.svg)](http://nuget.org/packages/opencover)
| Build | [![Build status](https://img.shields.io/appveyor/ci/sawilde/opencover.svg)](https://ci.appveyor.com/project/sawilde/opencover) |
| --- | --- |
| **Coverage** | [![Coverage](https://img.shields.io/coveralls/OpenCover/opencover/master.svg)](https://coveralls.io/r/OpenCover/opencover) [![Coverity](https://scan.coverity.com/projects/3921/badge.svg)](https://scan.coverity.com/projects/opencover-opencover) |
| **Nuget** | [![Nuget](https://img.shields.io/nuget/dt/opencover.svg)](http://nuget.org/packages/opencover) [![Nuget](https://img.shields.io/nuget/v/opencover.svg)](http://nuget.org/packages/opencover) [![Nuget](https://img.shields.io/nuget/vpre/opencover.svg)](http://nuget.org/packages/opencover) |
| **Lead Times** | [![Issue Stats](http://issuestats.com/github/opencover/opencover/badge/pr)](http://issuestats.com/github/opencover/opencover) [![Issue Stats](http://issuestats.com/github/opencover/opencover/badge/issue)](http://issuestats.com/github/opencover/opencover) |

### Master
The primary repo for the project is [on GitHub](https://github.com/opencover/opencover/) and is also where the [wiki](https://github.com/OpenCover/opencover/wiki) and [issues](https://github.com/OpenCover/opencover/wiki) are managed from.
Expand Down
11 changes: 9 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ environment:
secure: rw3Pk+YPWTG7xG7AaJx8wpxnYAOXM1/7HTRahQGuCHc=
COVERITY_EMAIL:
secure: lgy4M/uQ9jMlxmPzTIYWVE2GggvPntq6kfpO6Z0pjAs=
SONARQUBE_USER:
secure: +9YfPnwJzGsvdyto85pHwg==
SONARQUBE_PASSWORD:
secure: bGKR0fiOKZo/cNuigVxuUw==
cache:
- build/Version/opencover.snk
- build/Version/opencover.public.snk
Expand All @@ -21,6 +25,7 @@ build_script:
} else {
& .\build.bat create-release
}
test: off
artifacts:
- path: main/bin/installer/*.msi
Expand Down Expand Up @@ -71,6 +76,8 @@ notifications:
on_build_status_changed: true
on_success:
- ps: >-
if ($env:APPVEYOR_SCHEDULED_BUILD -ne "True" -and $env:APPVEYOR_REPO_BRANCH -ne "coverity") {
if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_SCHEDULED_BUILD -ne "True" -and $env:APPVEYOR_REPO_BRANCH -ne "coverity") {
& .\build.bat sonarqube-build
} else {
& .\build.bat dogfood-release
}
}
36 changes: 33 additions & 3 deletions default.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<property name="netfx4.folder" value="${netfx.framework.folder}/v4.0.30319" />
<property name="ci.buildNumber" value="${environment::get-variable('APPVEYOR_BUILD_NUMBER')}" if="${environment::variable-exists('APPVEYOR_BUILD_NUMBER')}"/>
<property name="ci.buildNumber" value="0" unless="${property::exists('ci.buildNumber')}" />
<property name="ci.fullBuildNumber" value="${environment::get-variable('APPVEYOR_BUILD_VERSION')}" if="${environment::variable-exists('APPVEYOR_BUILD_VERSION')}"/>
<property name="ci.fullBuildNumber" value="0" unless="${property::exists('ci.fullBuildNumber')}" />
<property name="coverity.folder" value="C:\Projects\cov-analysis-win64-7.7.0.4\cov-analysis-win64-7.7.0.4\bin" if="${directory::exists('C:\Projects\cov-analysis-win64-7.7.0.4\cov-analysis-win64-7.7.0.4\bin')}" />

<property name="coverity.exe" value="${coverity.folder}/cov-build.exe" if="${property::exists('coverity.folder')}" />
Expand Down Expand Up @@ -78,13 +80,41 @@
</exec>

<exec program="${curl.exe}"
commandline='--form token=${coverity.token} --insecure --form email=${coverity.email} --form [email protected] --form version="${ci.buildNumber}" --form description="${ci.buildNumber}" https://scan.coverity.com/builds?project=OpenCover%2Fopencover' />
commandline='--form token=${coverity.token} --insecure --form email=${coverity.email} --form [email protected] --form version="${ci.fullBuildNumber}" --form description="${ci.fullBuildNumber}" https://scan.coverity.com/builds?project=OpenCover%2Fopencover' />

</target>

<target name="sonarqube-build-release" depends="clean-all, build-environment, build-release-platforms" />
<target name="sonarqube-build" if="${environment::variable-exists('SONARQUBE_USER')}">

<call target="dogfood-release" />

<property name="sonarqube.user" value="${environment::get-variable('SONARQUBE_USER')}" />
<property name="sonarqube.pwd" value="${environment::get-variable('SONARQUBE_PASSWORD')}" />

<xmlpoke file="tools\sonarqube\SonarQube.Analysis.xml" xpath="//m:Property[@Name='sonar.login']" value="${sonarqube.user}">
<namespaces>
<namespace prefix="m" uri="http://www.sonarsource.com/msbuild/integration/2015/1" />
</namespaces>
</xmlpoke>

<xmlpoke file="tools\sonarqube\SonarQube.Analysis.xml" xpath="//m:Property[@Name='sonar.password']" value="${sonarqube.pwd}">
<namespaces>
<namespace prefix="m" uri="http://www.sonarsource.com/msbuild/integration/2015/1" />
</namespaces>
</xmlpoke>

<!-- assumes coverage file has been created -->
<exec program="tools\sonarqube\MSBuild.SonarQube.Runner.exe" commandline='begin /k:"opencover" /n:"opencover" /v:"${ci.fullBuildNumber}" /d:sonar.cs.opencover.reportsPaths="${root.folder}\main\bin\release\opencovertests.xml"' />

<target name="sonarqube-build-debug" depends="clean-all, build-environment, build-debug-platforms" />
<exec program="${msbuild.exe}">
<arg value="${solution.folder}/opencover.sonarqube.sln" />
<arg value="/t:Rebuild" />
<arg value="/p:Configuration=release,Platform=x86" />
</exec>

<exec program="tools\sonarqube\MSBuild.SonarQube.Runner.exe" commandline='end' />

</target>

<target name="quick-build-release" depends="clean, build-environment, build-release-platforms, test, test-cpp" />

Expand Down
1 change: 1 addition & 0 deletions main/OpenCover.3rdParty.Signer/CrashReporterSigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static bool AlreadySigned(string baseFolder)
}
catch
{
return false;
}
}
return false;
Expand Down
1 change: 1 addition & 0 deletions main/OpenCover.3rdParty.Signer/GendarmeSigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static bool AlreadySigned(string baseFolder)
}
catch
{
return false;
}
}
return false;
Expand Down
5 changes: 4 additions & 1 deletion main/OpenCover.3rdParty.Signer/SigningExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ public static void SignFile(this AssemblyDefinition definition, string outputPat
using (var stream = new FileStream(key, FileMode.Open, FileAccess.Read))
{
var keyPair = new StrongNameKeyPair(stream);
definition.Write(outputPath, new WriterParameters() { StrongNameKeyPair = keyPair });
definition.Write(outputPath, new WriterParameters
{
StrongNameKeyPair = keyPair
});
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions main/OpenCover.Console/OpenCover.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>..\bin\Release\</OutputPath>
Expand All @@ -73,6 +74,7 @@
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>..\Icons\Icon.ico</ApplicationIcon>
Expand Down
35 changes: 15 additions & 20 deletions main/OpenCover.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ static int Main(string[] args)

try
{
//throw new NullReferenceException();

CommandLineParser parser;
if (!ParseCommandLine(args, out parser)) return parser.ReturnCodeOffset + 1;
if (!ParseCommandLine(args, out parser))
return parser.ReturnCodeOffset + 1;


LogManager.GetRepository().Threshold = parser.LogLevel;
Expand All @@ -58,7 +57,8 @@ static int Main(string[] args)
var perfCounter = CreatePerformanceCounter(parser);

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

using (var container = new Bootstrapper(Logger))
{
Expand Down Expand Up @@ -385,7 +385,8 @@ private static int RunProcess(CommandLineParser parser, Action<StringDictionary>

private static void DisplayResults(CoverageSession coverageSession, ICommandLine parser, ILog logger)
{
if (!logger.IsInfoEnabled) return;
if (!logger.IsInfoEnabled)
return;

var altTotalClasses = 0;
var altVisitedClasses = 0;
Expand All @@ -403,15 +404,12 @@ from module in coverageSession.Modules.Where(x=>x.Classes != null)
from @class in module.Classes.Where(c => !c.ShouldSerializeSkippedDueTo())
select @class)
{
if (@class.Methods == null) continue;
if (@class.Methods == null)
continue;

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

if (@class.Methods.Any(x => x.Visited))
{
Expand All @@ -425,13 +423,9 @@ from @class in module.Classes.Where(c => !c.ShouldSerializeSkippedDueTo())

foreach (var method in @class.Methods.Where(x=> !x.ShouldSerializeSkippedDueTo()))
{
if ((method.SequencePoints.Any(x => x.VisitCount > 0)))
{
}
else if (method.FileRef != null)
{
unvisitedMethods.Add(string.Format("{0}", method.FullName));
}
if (!(method.SequencePoints.Any(x => x.VisitCount > 0)))
if (method.FileRef != null)
unvisitedMethods.Add(string.Format("{0}", method.FullName));

altTotalMethods += 1;
if (method.Visited)
Expand Down Expand Up @@ -587,6 +581,7 @@ private static bool ParseCommandLine(string[] args, out CommandLineParser parser
using (var service = new ServiceController(parser.Target))
{
var name = service.DisplayName;
System.Console.WriteLine("Service '{0}' found", name);
}
}
catch (Exception)
Expand Down
10 changes: 3 additions & 7 deletions main/OpenCover.Console/ServiceEnvironmentManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@
*/

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

using OpenCover.Framework;
using System.ServiceProcess;
using System.ComponentModel;

namespace OpenCover.Console
{
Expand Down Expand Up @@ -58,7 +55,7 @@ public void PrepareServiceEnvironment(string serviceName, ServiceEnvironment env
// variables in the registry for the service, otherwise it's better to temporarily set it for the account,
// assuming we can find out the account SID
// Network Service works better with environments is better on the service too
var serviceAccountName = MachineQualifiedServiceAccountName(this._serviceName);
var serviceAccountName = MachineQualifiedServiceAccountName(_serviceName);
if (serviceAccountName != "LocalSystem")
{
_serviceAccountSid = LookupAccountSid(serviceAccountName);
Expand All @@ -83,7 +80,7 @@ public static string MachineQualifiedServiceAccountName(string serviceName)
{
serviceAccountName = Environment.MachineName + serviceAccountName.Substring(1);
}
else if (serviceAccountName.ToLower().Contains("localsystem"))
else if (serviceAccountName.ToLowerInvariant().Contains("localsystem"))
{
serviceAccountName = "NT Authority\\SYSTEM";
}
Expand Down Expand Up @@ -202,8 +199,7 @@ private string[] GetServicesEnvironment()
private static unsafe int wcslen(char* s)
{
char* e;
for (e = s; *e != '\0'; e++)
;
for (e = s; *e != '\0'; e++){/* intentionally do nothing */}
return (int)(e - s);
}

Expand Down
3 changes: 2 additions & 1 deletion main/OpenCover.Framework/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public void Initialise(IFilter filter,
/// <filterpriority>2</filterpriority>
public void Dispose()
{
if (_container == null) return;
if (_container == null)
return;
_container.Dispose();
_container = null;
}
Expand Down
10 changes: 6 additions & 4 deletions main/OpenCover.Framework/CommandLineParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ private static List<string> ExtractFilters(string rawFilters)
return (from Match myMatch in myRegex.Matches(rawFilters) where myMatch.Success select myMatch.Value.Trim()).ToList();
}

private static List<SkippedMethod> ExtractSkipped(string skipped)
private static List<SkippedMethod> ExtractSkipped(string skippedArg)
{
if (string.IsNullOrWhiteSpace(skipped)) skipped = "All";
var skipped = string.IsNullOrWhiteSpace(skippedArg) ? "All" : skippedArg;
var options = skipped.Split(';');
var list = new List<SkippedMethod>();
foreach (var option in options)
Expand Down Expand Up @@ -334,7 +334,8 @@ private TimeSpan ParseTimeoutValue(string timeoutValue)
var match = Regex.Match(timeoutValue, @"((?<minutes>\d+)m)?((?<seconds>\d+)s)?");
if (match.Success)
{
int minutes = 0, seconds = 0;
int minutes = 0;
int seconds = 0;

var minutesMatch = match.Groups["minutes"];
if (minutesMatch.Success)
Expand Down Expand Up @@ -368,7 +369,8 @@ private static Exception ExceptionForInvalidArgumentValue(string argumentName, s

private void ValidateArguments()
{
if (PrintUsage || PrintVersion) return;
if (PrintUsage || PrintVersion)
return;

if (string.IsNullOrWhiteSpace(Target))
{
Expand Down
65 changes: 40 additions & 25 deletions main/OpenCover.Framework/CommandLineParserBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,51 @@ protected CommandLineParserBase(string[] arguments)
/// </summary>
protected void ParseArguments()
{
if (_arguments == null) return;
if (ParsedArguments.Count > 0) return;
if (_arguments == null)
return;
if (ParsedArguments.Count > 0)
return;

foreach (var argument in _arguments)
{
var trimmed = argument.Trim();
if (string.IsNullOrEmpty(trimmed)) continue;

if (!trimmed.StartsWith("-"))
throw new InvalidOperationException(string.Format("The argument '{0}' is not recognised", argument));

trimmed = trimmed.Substring(1);
if (string.IsNullOrEmpty(trimmed)) continue;

var colonidx = trimmed.IndexOf(':');
if (colonidx>0)
{
var arg = trimmed.Substring(0, colonidx);
var val = trimmed.Substring(colonidx + 1);
if (!ParsedArguments.ContainsKey(arg))
ParsedArguments.Add(arg, val);
else
ParsedArguments[arg] = (ParsedArguments[arg] + " " + val).Trim();
}
string trimmed;
if (ExtractTrimmedArgument(argument, out trimmed))
continue;

ExtractArgumentValue(trimmed);
}
}

private void ExtractArgumentValue(string trimmed)
{
var colonidx = trimmed.IndexOf(':');
if (colonidx > 0)
{
var arg = trimmed.Substring(0, colonidx);
var val = trimmed.Substring(colonidx + 1);
if (!ParsedArguments.ContainsKey(arg))
ParsedArguments.Add(arg, val);
else
{
if (!ParsedArguments.ContainsKey(trimmed))
ParsedArguments.Add(trimmed, String.Empty);
}
ParsedArguments[arg] = (ParsedArguments[arg] + " " + val).Trim();
}
else
{
if (!ParsedArguments.ContainsKey(trimmed))
ParsedArguments.Add(trimmed, String.Empty);
}
}

private static bool ExtractTrimmedArgument(string argument, out string trimmed)
{
trimmed = argument.Trim();
if (string.IsNullOrEmpty(trimmed))
return true;

if (!trimmed.StartsWith("-"))
throw new InvalidOperationException(string.Format("The argument '{0}' is not recognised", argument));

trimmed = trimmed.Substring(1);
return string.IsNullOrEmpty(trimmed);
}

/// <summary>
Expand Down
Loading

0 comments on commit 196a957

Please sign in to comment.