mirror of
https://github.com/irongut/CodeCoverageSummary.git
synced 2026-06-09 14:40:45 +00:00
use glob pattern matching #31
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using CommandLine;
|
||||
using Microsoft.Extensions.FileSystemGlobbing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -19,8 +21,13 @@ namespace CodeCoverageSummary
|
||||
{
|
||||
try
|
||||
{
|
||||
// use glob patterns to match files
|
||||
Matcher matcher = new();
|
||||
matcher.AddIncludePatterns(o.Files.ToArray());
|
||||
IEnumerable<string> matchingFiles = matcher.GetResultsInFullPath(".");
|
||||
|
||||
// check files exist
|
||||
foreach (var file in o.Files)
|
||||
foreach (var file in matchingFiles)
|
||||
{
|
||||
if (!File.Exists(file))
|
||||
{
|
||||
@@ -31,13 +38,13 @@ namespace CodeCoverageSummary
|
||||
|
||||
// parse code coverage file
|
||||
CodeSummary summary = new();
|
||||
foreach (var file in o.Files)
|
||||
foreach (var file in matchingFiles)
|
||||
{
|
||||
Console.WriteLine($"Code Coverage File: {file}");
|
||||
summary = ParseTestResults(file, summary);
|
||||
}
|
||||
summary.LineRate /= o.Files.Count();
|
||||
summary.BranchRate /= o.Files.Count();
|
||||
summary.LineRate /= matchingFiles.Count();
|
||||
summary.BranchRate /= matchingFiles.Count();
|
||||
|
||||
if (summary.Packages.Count == 0)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"profiles": {
|
||||
"CodeCoverageSummary": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "--files ../../../../coverage.cobertura.xml,../../../../coverage.cobertura.xml --format=text --badge true --thresholds=\"85 90\" --fail true"
|
||||
"commandLineArgs": "--files **/coverage.*.xml --format=text --badge true --thresholds=\"85 90\" --fail true"
|
||||
},
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
|
||||
Reference in New Issue
Block a user