Skip to content

Commit 1596799

Browse files
committed
allow for adjacent build output for relative paths in tests
1 parent 600a483 commit 1596799

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ or download from [releases](https://github.com/FortuneN/FineCodeCoverage/release
99
Prerequisites
1010

1111
Only that the test adapters are nuget packages. For instance, the NUnit Test Adapter extension is not sufficient.
12-
FCC will copy your test dll and dependencies to a sub folder this may affect your tests.
12+
FCC will copy your test dll and dependencies to a sub folder this may affect your tests. The alternative is to set the option AdjacentBuildOutput to true.
1313
---------------------------------------
1414

1515
Introduction
@@ -139,7 +139,8 @@ CoverletConsoleLocal Specify true to use your own dotnet tools local instal
139139
CoverletConsoleCustomPath Specify path to coverlet console exe if you need functionality that the FCC version does not provide.
140140
CoverletConsoleGlobal Specify true to use your own dotnet tools global install of coverlet console.
141141
142-
FCCSolutionOutputDirectoryName To have fcc output visible in a sub folder of your solution provide this name
142+
FCCSolutionOutputDirectoryName To have fcc output visible in a sub folder of your solution provide this name
143+
AdjacentBuildOutput If your tests are dependent upon their path set this to true.
143144
144145
The "CoverletConsole" settings have precedence Local / CustomPath / Global.
145146

SharedProject/Core/Model/CoverageProject.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,32 @@ internal class CoverageProject : ICoverageProject
2626
private IAppOptions settings;
2727
private readonly string fccFolderName = "fine-code-coverage";
2828
private readonly string buildOutputFolderName = "build-output";
29-
private string BuildOutputPath => Path.Combine(FCCOutputFolder, buildOutputFolderName);
29+
private string buildOutputPath;
30+
private string BuildOutputPath
31+
{
32+
get
33+
{
34+
if(buildOutputPath == null)
35+
{
36+
var adjacentBuildOutput = appOptionsProvider.Get().AdjacentBuildOutput;
37+
if (adjacentBuildOutput)
38+
{
39+
// Net framework - Debug | Debug-NET45
40+
// SDK style - Debug/netcoreapp3.1 etc
41+
var projectOutputDirectory = new DirectoryInfo(ProjectOutputFolder);
42+
var projectOutputDirectoryName = projectOutputDirectory.Name;
43+
var containingDirectoryPath = projectOutputDirectory.Parent.FullName;
44+
buildOutputPath = Path.Combine(containingDirectoryPath, $"{fccFolderName}-{projectOutputDirectoryName}");
45+
}
46+
else
47+
{
48+
buildOutputPath = Path.Combine(FCCOutputFolder, buildOutputFolderName);
49+
}
50+
}
51+
return buildOutputPath;
52+
53+
}
54+
}
3055
private readonly string coverageToolOutputFolderName = "coverage-tool-output";
3156

3257
public CoverageProject(IAppOptionsProvider appOptionsProvider, IFileSynchronizationUtil fileSynchronizationUtil, ILogger logger, DTE dte, bool canUseMsBuildWorkspace)

SharedProject/Options/AppOptions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ You can also ignore additional attributes by adding to this list (short name or
139139
[Category(outputCategory)]
140140
public string FCCSolutionOutputDirectoryName { get; set; }
141141

142+
[Description("If your tests are dependent upon their path set this to true.")]
143+
[Category(outputCategory)]
144+
public bool AdjacentBuildOutput { get; set; }
145+
142146
[Category(reportCategory)]
143147
[Description("When cyclomatic complexity exceeds this value for a method then the method will be present in the risk hotspots tab.")]
144148
public int ThresholdForCyclomaticComplexity { get; set; } = 30;

SharedProject/Options/IAppOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ public interface IAppOptions
2525
bool StickyCoverageTable { get; }
2626
bool NamespacedClasses { get; }
2727
bool HideFullyCovered { get; }
28+
bool AdjacentBuildOutput { get; }
2829
}
2930
}

0 commit comments

Comments
 (0)