Singular argument name, code cleanup, cwd change

This commit is contained in:
Viktor Hofer
2018-11-28 16:36:52 +01:00
parent a7a27e7abe
commit d6e008fba9
7 changed files with 37 additions and 36 deletions
+13 -13
View File
@@ -56,19 +56,19 @@ Arguments:
<ASSEMBLY> Path to the test assembly.
Options:
-h|--help Show help information
-v|--version Show version information
-t|--target Path to the test runner application.
-a|--targetargs Arguments to be passed to the test runner.
-o|--output Output of the generated coverage report
-f|--format Format of the generated coverage report.
--threshold Exits with error if the coverage % is below value.
--threshold-type Coverage type to apply the threshold to.
--exclude Filter expressions to exclude specific modules and types.
--include Filter expressions to include specific modules and types.
--include-directories Include directories containing additional assemblies to be instrumented.
--exclude-by-file Glob patterns specifying source files to exclude.
--merge-with Path to existing coverage result to merge.
-h|--help Show help information
-v|--version Show version information
-t|--target Path to the test runner application.
-a|--targetargs Arguments to be passed to the test runner.
-o|--output Output of the generated coverage report
-f|--format Format of the generated coverage report.
--threshold Exits with error if the coverage % is below value.
--threshold-type Coverage type to apply the threshold to.
--exclude Filter expressions to exclude specific modules and types.
--include Filter expressions to include specific modules and types.
--include-directory Include directories containing additional assemblies to be instrumented.
--exclude-by-file Glob patterns specifying source files to exclude.
--merge-with Path to existing coverage result to merge.
```
#### Code Coverage
+1 -1
View File
@@ -32,7 +32,7 @@ namespace Coverlet.Console
CommandOption thresholdTypes = app.Option("--threshold-type", "Coverage type to apply the threshold to.", CommandOptionType.MultipleValue);
CommandOption excludeFilters = app.Option("--exclude", "Filter expressions to exclude specific modules and types.", CommandOptionType.MultipleValue);
CommandOption includeFilters = app.Option("--include", "Filter expressions to include only specific modules and types.", CommandOptionType.MultipleValue);
CommandOption includeDirectories = app.Option("--include-directories", "Include directories containing additional assemblies to be instrumented.", CommandOptionType.MultipleValue);
CommandOption includeDirectories = app.Option("--include-directory", "Include directories containing additional assemblies to be instrumented.", CommandOptionType.MultipleValue);
CommandOption excludedSourceFiles = app.Option("--exclude-by-file", "Glob patterns specifying source files to exclude.", CommandOptionType.MultipleValue);
CommandOption mergeWith = app.Option("--merge-with", "Path to existing coverage result to merge.", CommandOptionType.SingleValue);
+1 -1
View File
@@ -66,8 +66,8 @@ namespace Coverlet.Core
}
catch (Exception)
{
// TODO: With verbose logging we should note that instrumentation failed.
InstrumentationHelper.RestoreOriginalModule(module, _identifier);
throw;
}
}
}
@@ -14,10 +14,9 @@ namespace Coverlet.Core.Helpers
{
internal static class InstrumentationHelper
{
public static string[] GetCoverableModules(string module, string[] includeDirectories)
public static string[] GetCoverableModules(string module, string[] directories)
{
Debug.Assert(includeDirectories != null, "Parameter " + nameof(includeDirectories) + " in method " +
nameof(InstrumentationHelper) + "." + nameof(GetCoverableModules) + " must not be null");
Debug.Assert(directories != null);
string moduleDirectory = Path.GetDirectoryName(module);
if (moduleDirectory == string.Empty)
@@ -25,28 +24,31 @@ namespace Coverlet.Core.Helpers
moduleDirectory = Directory.GetCurrentDirectory();
}
var dirs = new List<string>(1 + includeDirectories.Length)
var dirs = new List<string>()
{
// Add the test assembly's directory.
moduleDirectory
};
// Prepare all the directories in which we probe for modules.
foreach (var includeDirectory in includeDirectories.Where(d => d != null))
// Prepare all the directories we probe for modules.
foreach (string directory in directories)
{
var fullPath = (!Path.IsPathRooted(includeDirectory)
? Path.GetFullPath(Path.Combine(moduleDirectory, includeDirectory))
: includeDirectory).TrimEnd('*');
if (string.IsNullOrWhiteSpace(directory)) continue;
string fullPath = (!Path.IsPathRooted(directory)
? Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), directory))
: directory).TrimEnd('*');
if (!Directory.Exists(fullPath)) continue;
if (includeDirectory.EndsWith("*", StringComparison.Ordinal))
if (directory.EndsWith("*", StringComparison.Ordinal))
dirs.AddRange(Directory.GetDirectories(fullPath));
else
dirs.Add(fullPath);
}
// The test module's name must be unique.
// The module's name must be unique.
// Add the test module itself to exclude it from the files enumeration.
var uniqueModules = new HashSet<string>
{
Path.GetFileName(module)
@@ -309,8 +311,7 @@ namespace Coverlet.Core.Helpers
private static bool IsAssembly(string filePath)
{
Debug.Assert(filePath != null, "Parameter " + nameof(filePath) + " in " + nameof(InstrumentationHelper) +
"." + nameof(IsAssembly) + " must not be null.");
Debug.Assert(filePath != null);
if (!(filePath.EndsWith(".exe") || filePath.EndsWith(".dll")))
return false;
@@ -11,7 +11,7 @@ namespace Coverlet.MSbuild.Tasks
private string _path;
private string _exclude;
private string _include;
private string _includeDirectories;
private string _includeDirectory;
private string _excludeByFile;
private string _mergeWith;
@@ -39,10 +39,10 @@ namespace Coverlet.MSbuild.Tasks
set { _include = value; }
}
public string IncludeDirectories
public string IncludeDirectory
{
get { return _includeDirectories; }
set { _includeDirectories = value; }
get { return _includeDirectory; }
set { _includeDirectory = value; }
}
public string ExcludeByFile
@@ -64,7 +64,7 @@ namespace Coverlet.MSbuild.Tasks
var excludedSourceFiles = _excludeByFile?.Split(',');
var excludeFilters = _exclude?.Split(',');
var includeFilters = _include?.Split(',');
var includeDirectories = _includeDirectories?.Split(',');
var includeDirectories = _includeDirectory?.Split(',');
_coverage = new Coverage(_path, excludeFilters, includeFilters, includeDirectories, excludedSourceFiles, _mergeWith);
_coverage.PrepareModules();
+1 -1
View File
@@ -9,6 +9,6 @@
<MergeWith Condition="$(MergeWith) == ''"></MergeWith>
<Threshold Condition="$(Threshold) == ''">0</Threshold>
<ThresholdType Condition="$(ThresholdType) == ''">line,branch,method</ThresholdType>
<IncludeDirectories Condition="$(IncludeDirectories) == ''"></IncludeDirectories>
<IncludeDirectory Condition="$(IncludeDirectory) == ''"></IncludeDirectory>
</PropertyGroup>
</Project>
@@ -7,7 +7,7 @@
<Coverlet.MSbuild.Tasks.InstrumentationTask
Condition="'$(VSTestNoBuild)' == 'true' and $(CollectCoverage) == 'true'"
Include="$(Include)"
IncludeDirectories="$(IncludeDirectories)"
IncludeDirectory="$(IncludeDirectory)"
Exclude="$(Exclude)"
ExcludeByFile="$(ExcludeByFile)"
MergeWith="$(MergeWith)"
@@ -18,7 +18,7 @@
<Coverlet.MSbuild.Tasks.InstrumentationTask
Condition="'$(VSTestNoBuild)' != 'true' and $(CollectCoverage) == 'true'"
Include="$(Include)"
IncludeDirectories="$(IncludeDirectories)"
IncludeDirectory="$(IncludeDirectory)"
Exclude="$(Exclude)"
ExcludeByFile="$(ExcludeByFile)"
MergeWith="$(MergeWith)"