Skip to content

Commit 16e8543

Browse files
Merge branch 'coverlet-coverage:master' into development
2 parents d466ae1 + b36b671 commit 16e8543

File tree

8 files changed

+50
-25
lines changed

8 files changed

+50
-25
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,4 @@ coverage.*.cobertura.xml
315315
coverage.*.opencover.xml
316316

317317
FolderProfile.pubxml
318+
/NuGet.config

Directory.Build.props

+8-3
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,16 @@
3838
<VSTestLogger Include="html%3BLogFileName=TestResults-$(TargetFramework)-$(MSBuildProjectName).html" />
3939
</ItemGroup>
4040

41-
<PropertyGroup>
41+
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
4242
<VSTestResultsDirectory>$(RepoRoot)artifacts/testresults/$(Configuration.ToLowerInvariant())</VSTestResultsDirectory>
4343
<VSTestLogger>@(VSTestLogger)</VSTestLogger>
4444
</PropertyGroup>
4545

46+
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
47+
<VSTestResultsDirectory>$(RepoRoot)artifacts\testresults\$(Configuration.ToLowerInvariant())</VSTestResultsDirectory>
48+
<VSTestLogger>@(VSTestLogger)</VSTestLogger>
49+
</PropertyGroup>
50+
4651
<PropertyGroup>
4752
<!--
4853
Do not change versions since we need to support VSTest DataCollectors. We need to load assembly version 1.6.0 to properly work
@@ -69,9 +74,9 @@
6974
<MicrosoftBuildTaskVersion>15.7.179</MicrosoftBuildTaskVersion>
7075
<MicrosoftBuildTaskUtilitiesCoreVersion>15.7.179</MicrosoftBuildTaskUtilitiesCoreVersion>
7176
<NuGetBuildTasksPackageVersion>6.9.0-rc.86</NuGetBuildTasksPackageVersion>
72-
<MicrosoftBuildTaskSystemReflectionMetaData>1.4.2</MicrosoftBuildTaskSystemReflectionMetaData>
77+
<MicrosoftBuildTaskSystemReflectionMetaData>1.4.2</MicrosoftBuildTaskSystemReflectionMetaData>
7378
<MicrosoftBuildTaskSystemCollectionImmutable>1.5.0</MicrosoftBuildTaskSystemCollectionImmutable> >= 1.3.1
74-
-->
79+
-->
7580
</PropertyGroup>
7681

7782
</Project>

Documentation/GlobalTool.md

+3
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ coverlet <ASSEMBLY> --target <TARGET> --targetargs <TARGETARGS> --output "/custo
114114

115115
The above command will write the results to the supplied path, if no file extension is specified it'll use the standard extension of the selected output format. To specify a directory instead, simply append a `/` to the end of the value.
116116

117+
>[!TIP]
118+
>Use only folder name whenever multiple coverage output formats are used.
119+
117120
```bash
118121
coverlet <ASSEMBLY> --target <TARGET> --targetargs <TARGETARGS> --output "/custom/directory/" -f json -f lcov
119122
```

Documentation/VSTestIntegration.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,17 @@ You can change the output directory using the standard `dotnet test` switch `--r
7070

7171
:warning:At the moment VSTest integration **doesn't support all features** of msbuild and .NET tool, for instance show result on console, report merging and threshold validation.
7272
We're working to fill the gaps.
73-
>*PS: if you don't have any other way to merge reports(for instance your report generator doesn't support multi coverage file) you can for the moment exploit a trick reported by one of our contributor Daniel Paz(@p4p3) <https://github.com/tonerdo/coverlet/pull/225#issuecomment-573896446>*
73+
74+
> [!TIP]
75+
> *Some alternative solutions to merge coverage files*
76+
>
77+
> * use _dotnet-coverage_ tool and merge multiple coverage files
78+
>
79+
> `dotnet-coverage merge artifacts/coverage/**/coverage.cobertura.xml -f cobertura -o artifacts/coverage/coverage.xml`*
80+
>
81+
> * use _dotnet-reportgenerator-globaltool_ to create a HTML report and a merged coverage file
82+
>
83+
> `reportgenerator -reports:"**/*.cobertura.xml" -targetdir:"artifacts\reports.cobertura" -reporttypes:"HtmlInline_AzurePipelines_Dark;Cobertura"`
7484
7585
### Default option (if you don't specify a runsettings file)
7686

eng/publish-coverage-results.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ steps:
2626
artifact: CoverageResults_$(Agent.Os)_$(BuildConfiguration)
2727
condition: ${{parameters.condition}}
2828

29-
- task: PublishCodeCoverageResults@1
29+
- task: PublishCodeCoverageResults@2
3030
displayName: 'Publish code coverage'
3131
condition: ${{parameters.condition}}
3232
inputs:

src/coverlet.core/Helpers/InstrumentationHelper.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal class InstrumentationHelper : IInstrumentationHelper
2525
private readonly ISourceRootTranslator _sourceRootTranslator;
2626
private ILogger _logger;
2727
private static readonly RegexOptions s_regexOptions =
28-
RegexOptions.Multiline | RegexOptions.Compiled | RegexOptions.IgnoreCase;
28+
RegexOptions.Multiline | RegexOptions.Compiled;
2929

3030
public InstrumentationHelper(IProcessExitHandler processExitHandler, IRetryHelper retryHelper, IFileSystem fileSystem, ILogger logger, ISourceRootTranslator sourceRootTranslator)
3131
{
@@ -420,7 +420,7 @@ public bool IsTypeIncluded(string module, string type, string[] includeFilters)
420420
}
421421

422422
public bool IsLocalMethod(string method)
423-
=> new Regex(WildcardToRegex("<*>*__*|*"), s_regexOptions, TimeSpan.FromSeconds(10)).IsMatch(method);
423+
=> Regex.IsMatch(method, WildcardToRegex("<*>*__*|*"));
424424

425425
public void SetLogger(ILogger logger)
426426
{
@@ -442,7 +442,7 @@ private static bool IsTypeFilterMatch(string module, string type, string[] filte
442442
typePattern = WildcardToRegex(typePattern);
443443
modulePattern = WildcardToRegex(modulePattern);
444444

445-
if (new Regex(typePattern, s_regexOptions, TimeSpan.FromSeconds(10)).IsMatch(type) && new Regex(modulePattern, s_regexOptions, TimeSpan.FromSeconds(10)).IsMatch(module))
445+
if (Regex.IsMatch(type, typePattern) && Regex.IsMatch(module, modulePattern))
446446
return true;
447447
}
448448

test/Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
44
<PropertyGroup>
55
<IsTestProject>true</IsTestProject>
6-
<NoWarn>$(NoWarn);NU1301</NoWarn>
6+
<NoWarn>$(NoWarn);NU1301;IDE0007</NoWarn>
77
</PropertyGroup>
88
</Project>

test/coverlet.core.tests/Helpers/InstrumentationHelperTests.cs

+22-16
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,29 @@ public void TestBackupOriginalModule()
112112
Assert.True(File.Exists(backupPath));
113113
}
114114

115-
[Fact]
116-
public void TestIsValidFilterExpression()
115+
[Theory]
116+
[InlineData("[*]*")]
117+
[InlineData("[*]*core")]
118+
[InlineData("[assembly]*")]
119+
[InlineData("[*]type")]
120+
[InlineData("[assembly]type")]
121+
[InlineData("[coverlet.*.tests?]*")]
122+
[InlineData("[*]Coverlet.Core*")]
123+
[InlineData("[coverlet.*]*")]
124+
public void TestIsValidFilterExpression(string pattern)
125+
{
126+
Assert.True(_instrumentationHelper.IsValidFilterExpression(pattern));
127+
}
128+
129+
[Theory]
130+
[InlineData("[*]")]
131+
[InlineData("[-]*")]
132+
[InlineData("*")]
133+
[InlineData("][")]
134+
[InlineData(null)]
135+
public void TestInValidFilterExpression(string pattern)
117136
{
118-
Assert.True(_instrumentationHelper.IsValidFilterExpression("[*]*"));
119-
Assert.True(_instrumentationHelper.IsValidFilterExpression("[*]*core"));
120-
Assert.True(_instrumentationHelper.IsValidFilterExpression("[assembly]*"));
121-
Assert.True(_instrumentationHelper.IsValidFilterExpression("[*]type"));
122-
Assert.True(_instrumentationHelper.IsValidFilterExpression("[assembly]type"));
123-
Assert.False(_instrumentationHelper.IsValidFilterExpression("[*]"));
124-
Assert.False(_instrumentationHelper.IsValidFilterExpression("[-]*"));
125-
Assert.False(_instrumentationHelper.IsValidFilterExpression("*"));
126-
Assert.False(_instrumentationHelper.IsValidFilterExpression("]["));
127-
Assert.False(_instrumentationHelper.IsValidFilterExpression("["));
128-
Assert.False(_instrumentationHelper.IsValidFilterExpression("[assembly][*"));
129-
Assert.False(_instrumentationHelper.IsValidFilterExpression("[assembly]*]"));
130-
Assert.False(_instrumentationHelper.IsValidFilterExpression("[]"));
131-
Assert.False(_instrumentationHelper.IsValidFilterExpression(null));
137+
Assert.False(_instrumentationHelper.IsValidFilterExpression(pattern));
132138
}
133139

134140
[Fact]

0 commit comments

Comments
 (0)