Skip to content

Commit

Permalink
Adds /LogFile parameter to DotCoverSettings
Browse files Browse the repository at this point in the history
Solves #1151
  • Loading branch information
bjorkstromm committed Aug 12, 2016
1 parent 02c29d2 commit 402fac1
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,23 @@ public void Should_Append_DisableDefaultFilters()
"/DisableDefaultFilters", result.Args);
}

[Fact]
public void Should_Append_LogFile()
{
// Given
var fixture = new DotCoverAnalyserFixture();
fixture.Settings.LogFile = "./logfile.log";

// When
var result = fixture.Run();

// Then
Assert.Equal("Analyse /TargetExecutable=\"/Working/tools/Test.exe\" " +
"/TargetArguments=\"-argument\" " +
"/Output=\"/Working/result.xml\" " +
"/LogFile=\"/Working/logfile.log\"", result.Args);
}

[Fact]
public void Should_Capture_XUnit()
{
Expand Down
34 changes: 2 additions & 32 deletions src/Cake.Common/Tools/DotCover/Analyse/DotCoverAnalyser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,38 +114,8 @@ private ProcessArgumentBuilder GetArguments(
builder.AppendSwitch("/ReportType", "=", settings.ReportType.ToString());
}

// TargetWorkingDir
if (settings.TargetWorkingDir != null)
{
builder.AppendSwitch("/TargetWorkingDir", "=", settings.TargetWorkingDir.MakeAbsolute(_environment).FullPath.Quote());
}

// Scope
if (settings.Scope.Count > 0)
{
var scope = string.Join(";", settings.Scope);
builder.AppendSwitch("/Scope", "=", scope.Quote());
}

// Filters
if (settings.Filters.Count > 0)
{
var filters = string.Join(";", settings.Filters);
builder.AppendSwitch("/Filters", "=", filters.Quote());
}

// Filters
if (settings.AttributeFilters.Count > 0)
{
var attributeFilters = string.Join(";", settings.AttributeFilters);
builder.AppendSwitch("/AttributeFilters", "=", attributeFilters.Quote());
}

// DisableDefaultFilters
if (settings.DisableDefaultFilters)
{
builder.Append("/DisableDefaultFilters");
}
// Set common Coverage settings
settings.ToArguments(_environment).CopyTo(builder);

return builder;
}
Expand Down
34 changes: 2 additions & 32 deletions src/Cake.Common/Tools/DotCover/Cover/DotCoverCoverer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,38 +108,8 @@ private ProcessArgumentBuilder GetArguments(
outputPath = outputPath.MakeAbsolute(_environment);
builder.AppendSwitch("/Output", "=", outputPath.FullPath.Quote());

// TargetWorkingDir
if (settings.TargetWorkingDir != null)
{
builder.AppendSwitch("/TargetWorkingDir", "=", settings.TargetWorkingDir.MakeAbsolute(_environment).FullPath.Quote());
}

// Scope
if (settings.Scope.Count > 0)
{
var scope = string.Join(";", settings.Scope);
builder.AppendSwitch("/Scope", "=", scope.Quote());
}

// Filters
if (settings.Filters.Count > 0)
{
var filters = string.Join(";", settings.Filters);
builder.AppendSwitch("/Filters", "=", filters.Quote());
}

// Filters
if (settings.AttributeFilters.Count > 0)
{
var attributeFilters = string.Join(";", settings.AttributeFilters);
builder.AppendSwitch("/AttributeFilters", "=", attributeFilters.Quote());
}

// DisableDefaultFilters
if (settings.DisableDefaultFilters)
{
builder.Append("/DisableDefaultFilters");
}
// Set common Coverage settings
settings.ToArguments(_environment).CopyTo(builder);

return builder;
}
Expand Down
6 changes: 6 additions & 0 deletions src/Cake.Common/Tools/DotCover/DotCoverSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public abstract class DotCoverSettings : ToolSettings
/// </summary>
public bool DisableDefaultFilters { get; set; }

/// <summary>
/// Gets or sets a value that enables logging and specifies log file name
/// This represents the <c>/LogFile</c> option.
/// </summary>
public FilePath LogFile { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="DotCoverSettings"/> class.
/// </summary>
Expand Down
49 changes: 49 additions & 0 deletions src/Cake.Common/Tools/DotCover/DotCoverSettingsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// See the LICENSE file in the project root for more information.

using System;
using Cake.Core;
using Cake.Core.IO;

namespace Cake.Common.Tools.DotCover
{
Expand Down Expand Up @@ -61,5 +63,52 @@ public static T WithAttributeFilter<T>(this T settings, string attributeFilter)
settings.AttributeFilters.Add(attributeFilter);
return settings;
}

internal static ProcessArgumentBuilder ToArguments(this DotCoverSettings settings, ICakeEnvironment environment)
{
var builder = new ProcessArgumentBuilder();

// TargetWorkingDir
if (settings.TargetWorkingDir != null)
{
builder.AppendSwitch("/TargetWorkingDir", "=", settings.TargetWorkingDir.MakeAbsolute(environment).FullPath.Quote());
}

// Scope
if (settings.Scope.Count > 0)
{
var scope = string.Join(";", settings.Scope);
builder.AppendSwitch("/Scope", "=", scope.Quote());
}

// Filters
if (settings.Filters.Count > 0)
{
var filters = string.Join(";", settings.Filters);
builder.AppendSwitch("/Filters", "=", filters.Quote());
}

// Filters
if (settings.AttributeFilters.Count > 0)
{
var attributeFilters = string.Join(";", settings.AttributeFilters);
builder.AppendSwitch("/AttributeFilters", "=", attributeFilters.Quote());
}

// DisableDefaultFilters
if (settings.DisableDefaultFilters)
{
builder.Append("/DisableDefaultFilters");
}

// LogFile
if (settings.LogFile != null)
{
var logFilePath = settings.LogFile.MakeAbsolute(environment);
builder.AppendSwitch("/LogFile", "=", logFilePath.FullPath.Quote());
}

return builder;
}
}
}

0 comments on commit 402fac1

Please sign in to comment.