Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH1151: Adds /LogFile parameter to DotCoverSettings #1152

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
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;
}
}
}