Skip to content

Commit

Permalink
Merge pull request #28 from csMACnz/release-0.5.0
Browse files Browse the repository at this point in the history
Merge Release 0.5.0 to Master
  • Loading branch information
csMACnz committed Feb 17, 2015
2 parents c19b8f4 + 0603ae8 commit 3adf973
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 36 deletions.
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
version: 0.{build}
skip_tags: true
os: Windows Server 2012 R2
environment:
COVERALLS_REPO_TOKEN:
Expand Down
26 changes: 10 additions & 16 deletions build.tasks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ properties {
# build variables
$framework = "4.5.1" # .net framework version
$configuration = "Release" # build configuration
$script:version = "0.3.0.0"
$script:nugetVersion = "0.3.0.0"
$script:version = "0.5.0.0"
$script:nugetVersion = "0.5.0.0"

# directories
$base_dir = . resolve-path .\
Expand Down Expand Up @@ -33,11 +33,7 @@ task LocalTestSettings {
}

task AppVeyorEnvironmentSettings {

if($env:APPVEYOR) {
Update-AppveyorBuild -Version $env:GitVersion_FullSemVer
}


if(Test-Path Env:\GitVersion_ClassicVersion) {
$script:version = $env:GitVersion_ClassicVersion
echo "version set to $script:version"
Expand All @@ -54,7 +50,7 @@ task AppVeyorEnvironmentSettings {
$script:nugetVersion = $env:APPVEYOR_BUILD_VERSION
echo "nuget version set to $script:nugetVersion"
}

$script:xunit = "xunit.console.clr4.exe"
$script:testOptions = "/appveyor"
}
Expand Down Expand Up @@ -123,13 +119,16 @@ task dupfinder {
Write-Host "Text: $($fragment.Text)"
}

$anyDuplicates = $TRUE;
$anyDuplicates = $TRUE;

if(Get-Command "Add-AppveyorTest" -errorAction SilentlyContinue) {
Add-AppveyorTest "Duplicate Found with a cost of $($duplicate.Cost), across $($duplicate.Fragment.Count) Fragments" -Outcome Failed -ErrorMessage "See duplicateReport.xml for details of duplicates" -FileName "$($fragment.FileName)"
Add-AppveyorMessage "Duplicate Found in the file $($fragment.FileName) with a cost of $($duplicate.Cost), across $($duplicate.Fragment.Count) Fragments" -Category Warning -Details "See duplicateReport.xml for details of duplicates"
if ([convert]::ToInt32($duplicate.Cost,10) -gt 100){
Add-AppveyorTest "Duplicate Found with a cost of $($duplicate.Cost), across $($duplicate.Fragment.Count) Fragments" -Outcome Failed -ErrorMessage "See duplicateReport.xml for details of duplicates" -FileName "$($fragment.FileName)"
}
}
}

$xslt = New-Object System.Xml.Xsl.XslCompiledTransform
$xslt.Load("BuildTools\dupfinder.xslt")
$xslt.Transform("duplicateReport.xml", "duplicateReport.html")
Expand All @@ -138,11 +137,6 @@ task dupfinder {
Push-AppveyorArtifact .\duplicateReport.xml
Push-AppveyorArtifact .\duplicateReport.html
}

if ($anyDuplicates -eq $TRUE){
Write-Host "Failing build as there are duplicates in the code-base"
throw "Duplicates found in code base"
}
}

task inspect {
Expand Down
4 changes: 2 additions & 2 deletions coveralls.net.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<licenseUrl>https://github.com/csmacnz/coveralls.net/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/csmacnz/coveralls.net</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Coveralls.io uploader for .NET Code Coverage.</description>
<summary>Coveralls.io uploader for .NET Code Coverage.</summary>
<description>Coveralls.io uploader for .NET Code Coverage. Supports opencover and visual studio's codecoverage.exe on windows, and monocov for mono</description>
<language>en-US</language>
<tags>Code-Coverage Reporting Coveralls Runner</tags>
<tags>Code-Coverage Coveralls opencover monocov codecoverage.exe coveralls.io Reporting Runner</tags>
</metadata>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3.0.0")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: AssemblyInformationalVersion("0.3.0.0")]
[assembly: AssemblyVersion("0.5.0.0")]
[assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: AssemblyInformationalVersion("0.5.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
6 changes: 3 additions & 3 deletions src/csmacnz.Coveralls.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3.0.0")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: AssemblyInformationalVersion("0.3.0.0")]
[assembly: AssemblyVersion("0.5.0.0")]
[assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: AssemblyInformationalVersion("0.5.0.0")]
3 changes: 2 additions & 1 deletion src/csmacnz.Coveralls/Main.usage.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
csmac.Coveralls - a coveralls.io coverage publisher for .Net

Usage:
csmacnz.Coveralls (--opencover | --monocov) -i ./opencovertests.xml --repoToken <repoToken> [-o ./opencovertests.json] [--dryrun] [--useRelativePaths --basePath <path>] [--commitId <commitId> --commitBranch <commitBranch> [--commitAuthor <commitAuthor> --commitEmail <commitEmail> --commitMessage <commitMessage>] ] [--jobId <jobId>] [--serviceName <Name>]
csmacnz.Coveralls (--opencover | --dynamiccodecoverage | --monocov) -i ./opencovertests.xml --repoToken <repoToken> [-o ./opencovertests.json] [--dryrun] [--useRelativePaths [--basePath <path>] ] [--commitId <commitId> --commitBranch <commitBranch> [--commitAuthor <commitAuthor> --commitEmail <commitEmail> --commitMessage <commitMessage>] ] [--jobId <jobId>] [--serviceName <Name>]
csmacnz.Coveralls --version
csmacnz.Coveralls --help

Expand All @@ -14,6 +14,7 @@ Options:
--useRelativePaths This flag, when provided, will attempt to strip the current working directory from the beginning of the source file path.
--basePath <path> When useRelativePaths and a basePath is provided, this path is used instead of the current working directory.
--opencover Reads input as OpenCover data.
--dynamiccodecoverage Reads input as the CodeCoverage.exe xml format.
--monocov Reads input as monocov results folder.
--repoToken <repoToken> The coveralls.io repository token.
--commitId <commitId> The git commit hash for the coverage report.
Expand Down
4 changes: 2 additions & 2 deletions src/csmacnz.Coveralls/PathStripper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public PathProcessor(string basePath)

public string ConvertPath(string path)
{
var currentWorkingDirectory = _basePath;
var currentWorkingDirectory = _basePath.ToLower();

if (path.StartsWith(currentWorkingDirectory))
if (path.ToLower().StartsWith(currentWorkingDirectory))
{
return path.Substring(currentWorkingDirectory.Length);
}
Expand Down
17 changes: 15 additions & 2 deletions src/csmacnz.Coveralls/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Reflection;
using System.Xml.Linq;
using Newtonsoft.Json;
using BCLExtensions;

namespace csmacnz.Coveralls
{
Expand Down Expand Up @@ -43,9 +44,21 @@ public static void Main(string[] argv)

files = new MonoCoverParser(pathProcessor).GenerateSourceFiles(documents, args.OptUserelativepaths);
}
else
else if (args.IsProvided("--dynamiccodecoverage") && args.OptDynamiccodecoverage)
{
var fileName = args.OptInput;
if (!File.Exists(fileName))
{
Console.Error.WriteLine("Input file '" + fileName + "' cannot be found");
Environment.Exit(1);
}

var document = XDocument.Load(fileName);

files = new DynamicCodeCoverageParser(new FileSystem(), pathProcessor).GenerateSourceFiles(document, args.OptUserelativepaths);
}
else
{
var fileName = args.OptInput;
if (!File.Exists(fileName))
{
Expand All @@ -60,7 +73,7 @@ public static void Main(string[] argv)

GitData gitData = null;
var commitId = args.IsProvided("--commitId") ? args.OptCommitid : string.Empty;
if (!string.IsNullOrWhiteSpace(commitId))
if (commitId.IsNotNullOrWhitespace())
{
var committerName = args.OptCommitauthor ?? string.Empty;
var comitterEmail = args.OptCommitemail ?? string.Empty;
Expand Down
6 changes: 3 additions & 3 deletions src/csmacnz.Coveralls/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3.0.0")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: AssemblyInformationalVersion("0.3.0.0")]
[assembly: AssemblyVersion("0.5.0.0")]
[assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: AssemblyInformationalVersion("0.5.0.0")]
4 changes: 3 additions & 1 deletion src/csmacnz.Coveralls/T4DocoptNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class MainArgs
public const string Usage = @"csmac.Coveralls - a coveralls.io coverage publisher for .Net
Usage:
csmacnz.Coveralls (--opencover | --monocov) -i ./opencovertests.xml --repoToken <repoToken> [-o ./opencovertests.json] [--dryrun] [--useRelativePaths --basePath <path>] [--commitId <commitId> --commitBranch <commitBranch> [--commitAuthor <commitAuthor> --commitEmail <commitEmail> --commitMessage <commitMessage>] ] [--jobId <jobId>] [--serviceName <Name>]
csmacnz.Coveralls (--opencover | --dynamiccodecoverage | --monocov) -i ./opencovertests.xml --repoToken <repoToken> [-o ./opencovertests.json] [--dryrun] [--useRelativePaths [--basePath <path>] ] [--commitId <commitId> --commitBranch <commitBranch> [--commitAuthor <commitAuthor> --commitEmail <commitEmail> --commitMessage <commitMessage>] ] [--jobId <jobId>] [--serviceName <Name>]
csmacnz.Coveralls --version
csmacnz.Coveralls --help
Expand All @@ -22,6 +22,7 @@ public class MainArgs
--useRelativePaths This flag, when provided, will attempt to strip the current working directory from the beginning of the source file path.
--basePath <path> When useRelativePaths and a basePath is provided, this path is used instead of the current working directory.
--opencover Reads input as OpenCover data.
--dynamiccodecoverage Reads input as the CodeCoverage.exe xml format.
--monocov Reads input as monocov results folder.
--repoToken <repoToken> The coveralls.io repository token.
--commitId <commitId> The git commit hash for the coverage report.
Expand Down Expand Up @@ -59,6 +60,7 @@ public bool IsProvided(string parameter)
}

public bool OptOpencover { get { return _args["--opencover"].IsTrue; } }
public bool OptDynamiccodecoverage { get { return _args["--dynamiccodecoverage"].IsTrue; } }
public bool OptMonocov { get { return _args["--monocov"].IsTrue; } }
public string OptInput { get { return _args["--input"].ToString(); } }
public string OptRepotoken { get { return _args["--repoToken"].ToString(); } }
Expand Down
86 changes: 86 additions & 0 deletions src/csmacnz.Coveralls/VSCodeCoverageParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;

namespace csmacnz.Coveralls
{
public class DynamicCodeCoverageParser
{
private readonly FileSystem _fileSystem;
private readonly PathProcessor _pathProcessor;

public DynamicCodeCoverageParser(FileSystem fileSystem, PathProcessor pathProcessor)
{
_fileSystem = fileSystem;
_pathProcessor = pathProcessor;
}

public List<CoverageFile> GenerateSourceFiles(XDocument document, bool useRelativePaths)
{
var files = new List<CoverageFile>();
if (document.Root != null)
{
var xElement = document.Root.Element("modules");
if (xElement != null)
foreach (var module in xElement.Elements("module"))
{
var filesElement = module.Element("source_files");
if (filesElement != null)
{
foreach (var file in filesElement.Elements("source_file"))
{
var fileid = file.Attribute("id").Value;
var fullPath = file.Attribute("path").Value;
var path = fullPath;
if (useRelativePaths)
{
path = _pathProcessor.ConvertPath(fullPath);
}
path = _pathProcessor.UnixifyPath(path);
var coverageBuilder = new CoverageFileBuilder(path);

var classesElement = module.Element("functions");
if (classesElement != null)
{
foreach (var @class in classesElement.Elements("function"))
{
var ranges = @class.Element("ranges");
if (ranges != null)
{
foreach (var range in ranges.Elements("range"))
{
var rangeFileId = range.Attribute("source_id").Value;
if (fileid == rangeFileId)
{
var sourceStartLine = int.Parse(range.Attribute("start_line").Value);
var sourceEndLine = int.Parse(range.Attribute("end_line").Value);
var covered = range.Attribute("covered").Value == "yes";

foreach (
var lineNumber in
Enumerable.Range(sourceStartLine,
sourceEndLine - sourceStartLine + 1))
{
coverageBuilder.RecordCoverage(lineNumber, covered ? 1 : 0);
}
}
}
}
}
}

var readAllText = _fileSystem.TryLoadFile(fullPath);
if (readAllText != null)
{
coverageBuilder.AddSource(readAllText);
}
var coverageFile = coverageBuilder.CreateFile();
files.Add(coverageFile);
}
}
}
}
return files;
}
}
}
6 changes: 5 additions & 1 deletion src/csmacnz.Coveralls/csmacnz.Coveralls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BCLExtensions">
<HintPath>..\packages\BCLExtensions.1.0.0\lib\BCLExtensions.dll</HintPath>
</Reference>
<Reference Include="DocoptNet">
<HintPath>..\packages\docopt.net.0.6.1.6\lib\net40\DocoptNet.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -72,6 +75,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>T4DocoptNet.tt</DependentUpon>
</Compile>
<Compile Include="VSCodeCoverageParser.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down Expand Up @@ -102,4 +106,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
3 changes: 2 additions & 1 deletion src/csmacnz.Coveralls/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BCLExtensions" version="1.0.0" targetFramework="net451" />
<package id="docopt.net" version="0.6.1.6" targetFramework="net451" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net451" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net451" />
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net451" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net451" />
</packages>
</packages>

0 comments on commit 3adf973

Please sign in to comment.