Skip to content

Commit

Permalink
add DefaultCoverageOutputFolder
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyhallett committed Nov 18, 2021
1 parent 1596799 commit 53c5327
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CoverageToolOutputManager_Tests
private Mock<ICoverageProject> mockProject2;
private List<ICoverageProject> coverageProjects;
private List<int> callOrder;
private const string DefaultCoverageFolder = "defaultFolder";

[SetUp]
public void SetUp()
Expand All @@ -26,9 +27,11 @@ public void SetUp()
mockProject1.Setup(p => p.FCCOutputFolder).Returns("p1output");
mockProject1.Setup(p => p.ProjectName).Returns("project1");
mockProject1.SetupProperty(p => p.CoverageOutputFolder);
mockProject1.Setup(p => p.DefaultCoverageOutputFolder).Returns(DefaultCoverageFolder);
mockProject2 = new Mock<ICoverageProject>();
mockProject2.Setup(p => p.FCCOutputFolder).Returns("p2output");
mockProject2.Setup(p => p.ProjectName).Returns("project2");
mockProject2.Setup(p => p.DefaultCoverageOutputFolder).Returns(DefaultCoverageFolder);
coverageProjects = new List<ICoverageProject> { mockProject1.Object, mockProject2.Object };
}

Expand Down Expand Up @@ -105,16 +108,15 @@ public void Should_Set_CoverageOutputFolder_To_ProjectName_Sub_Folder_Of_Provide
}

[Test]
public void Should_Set_CoverageOutputFolder_To_Sub_Folder_Of_CoverageProject_FCCOutputFolder_For_All_When_Not_Provided()
public void Should_Set_CoverageOutputFolder_To_Default_For_All_When_Not_Provided()
{
SetUpProviders(true, null, null);
var coverageToolOutputManager = mocker.Create<CoverageToolOutputManager>();
coverageToolOutputManager.SetProjectCoverageOutputFolder(coverageProjects);

var expectedProject1OutputFolder = Path.Combine(mockProject1.Object.FCCOutputFolder, "coverage-tool-output");
var expectedProject2OutputFolder = Path.Combine(mockProject2.Object.FCCOutputFolder, "coverage-tool-output");
mockProject1.VerifySet(p => p.CoverageOutputFolder = expectedProject1OutputFolder);
mockProject2.VerifySet(p => p.CoverageOutputFolder = expectedProject2OutputFolder);

mockProject1.VerifySet(p => p.CoverageOutputFolder = DefaultCoverageFolder);
mockProject2.VerifySet(p => p.CoverageOutputFolder = DefaultCoverageFolder);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ internal class CoverageToolOutputManager : ICoverageToolOutputManager
{
private readonly ILogger logger;
private readonly IFileUtil fileUtil;
private const string projectCoverageToolOutputFolderName = "coverage-tool-output";
private string outputFolderForAllProjects;
private List<ICoverageProject> coverageProjects;
private readonly IOrderedEnumerable<Lazy<ICoverageToolOutputFolderProvider, IOrderMetadata>> outputFolderProviders;
Expand All @@ -29,12 +28,12 @@ public CoverageToolOutputManager(IFileUtil fileUtil, ILogger logger,[ImportMany]
public void SetProjectCoverageOutputFolder(List<ICoverageProject> coverageProjects)
{
this.coverageProjects = coverageProjects;
DetermineOutputFolder();
DetermineOutputFolderForAllProjects();
if (outputFolderForAllProjects == null)
{
foreach(var coverageProject in coverageProjects)
{
coverageProject.CoverageOutputFolder = Path.Combine(coverageProject.FCCOutputFolder, projectCoverageToolOutputFolderName);
coverageProject.CoverageOutputFolder = coverageProject.DefaultCoverageOutputFolder;
}
}
else
Expand All @@ -49,7 +48,7 @@ public void SetProjectCoverageOutputFolder(List<ICoverageProject> coverageProjec



private void DetermineOutputFolder()
private void DetermineOutputFolderForAllProjects()
{
outputFolderForAllProjects = outputFolderProviders.SelectFirstNonNull(p => p.Value.Provide(coverageProjects));
if(outputFolderForAllProjects != null)
Expand Down
6 changes: 3 additions & 3 deletions SharedProject/Core/Model/CoverageProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ Process PropertyGroup settings
}
}
public string CoverageOutputFolder { get; set; }

public string DefaultCoverageOutputFolder => Path.Combine(FCCOutputFolder, coverageToolOutputFolderName);

public XElement ProjectFileXElement
{
Expand Down Expand Up @@ -382,7 +382,7 @@ public async System.Threading.Tasks.Task StepAsync(string stepName, Func<ICovera
public async System.Threading.Tasks.Task PrepareForCoverageAsync()
{
EnsureDirectories();
CleanDirectory();
CleanFCCDirectory();
SynchronizeBuildOutput();
await SetExcludedReferencedProjectsAsync();
}
Expand Down Expand Up @@ -560,7 +560,7 @@ private void EnsureEmptyOutputFolder()
Directory.CreateDirectory(CoverageOutputFolder);
}
}
private void CleanDirectory()
private void CleanFCCDirectory()
{
var exclusions = new List<string> { buildOutputFolderName, coverageToolOutputFolderName };
var fccDirectory = new DirectoryInfo(FCCOutputFolder);
Expand Down
1 change: 1 addition & 0 deletions SharedProject/Core/Model/ICoverageProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ internal interface ICoverageProject
string FCCOutputFolder { get; }
string CoverageOutputFile { get; }
string CoverageOutputFolder { get; set; }
string DefaultCoverageOutputFolder { get; }
List<string> ExcludedReferencedProjects { get; }
string FailureDescription { get; set; }
string FailureStage { get; set; }
Expand Down

0 comments on commit 53c5327

Please sign in to comment.