Skip to content

Commit

Permalink
Fix filename update for activated UseSourceFile option (#1681)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertk authored Nov 19, 2024
1 parent 973200c commit 302886a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion eng/azure-pipelines-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ steps:
- task: UseDotNet@2
inputs:
useGlobalJson: true
displayName: Install .NET Core SDK 8.0.100
displayName: Install .NET Core SDK 8.0.111

- task: NuGetAuthenticate@1
displayName: Authenticate with NuGet feeds
Expand Down
5 changes: 2 additions & 3 deletions src/coverlet.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static int Main(string[] args)
var verbosity = new Option<LogLevel>(new[] { "--verbosity", "-v" }, () => LogLevel.Normal, "Sets the verbosity level of the command. Allowed values are quiet, minimal, normal, detailed.") { Arity = ArgumentArity.ZeroOrOne };
var formats = new Option<string[]>(new[] { "--format", "-f" }, () => new[] { "json" }, "Format of the generated coverage report.") { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
var threshold = new Option<string>("--threshold", "Exits with error if the coverage % is below value.") { Arity = ArgumentArity.ZeroOrOne };
var thresholdTypes = new Option<List<string>>("--threshold-type", () => new List<string>(new string[] { "line", "branch", "method" }), "Coverage type to apply the threshold to.").FromAmong("line", "branch", "method");
Option<List<string>> thresholdTypes = new Option<List<string>>("--threshold-type", () => new List<string>(new string[] { "line", "branch", "method" }), "Coverage type to apply the threshold to.").FromAmong("line", "branch", "method");
var thresholdStat = new Option<ThresholdStatistic>("--threshold-stat", () => ThresholdStatistic.Minimum, "Coverage statistic used to enforce the threshold value.") { Arity = ArgumentArity.ZeroOrOne };
var excludeFilters = new Option<string[]>("--exclude", "Filter expressions to exclude specific modules and types.") { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
var includeFilters = new Option<string[]>("--include", "Filter expressions to include only specific modules and types.") { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
Expand Down Expand Up @@ -106,7 +106,7 @@ static int Main(string[] args)
if (string.IsNullOrEmpty(moduleOrAppDirectoryValue) || string.IsNullOrWhiteSpace(moduleOrAppDirectoryValue))
throw new ArgumentException("No test assembly or application directory specified.");

var taskStatus = await HandleCommand(moduleOrAppDirectoryValue,
int taskStatus = await HandleCommand(moduleOrAppDirectoryValue,
targetValue,
targsValue,
outputValue,
Expand Down Expand Up @@ -385,7 +385,6 @@ string sourceMappingFile

return Task.FromResult(exitCode);


}

catch (Win32Exception we) when (we.Source == "System.Diagnostics.Process")
Expand Down
22 changes: 11 additions & 11 deletions src/coverlet.core/Coverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public CoveragePrepareResult PrepareModules()
_parameters.IncludeFilters = _parameters.IncludeFilters?.Where(f => _instrumentationHelper.IsValidFilterExpression(f)).ToArray();

IReadOnlyList<string> validModules = _instrumentationHelper.SelectModules(modules, _parameters.IncludeFilters, _parameters.ExcludeFilters).ToList();
foreach (var excludedModule in modules.Except(validModules))
foreach (string excludedModule in modules.Except(validModules))
{
_logger.LogVerbose($"Excluded module: '{excludedModule}'");
}
Expand Down Expand Up @@ -365,16 +365,6 @@ private void CalculateCoverage()
{
foreach (InstrumenterResult result in _results)
{
if (!_fileSystem.Exists(result.HitsFilePath))
{
// Hits file could be missed mainly for two reason
// 1) Issue during module Unload()
// 2) Instrumented module is never loaded or used so we don't have any hit to register and
// module tracker is never used
_logger.LogVerbose($"Hits file:'{result.HitsFilePath}' not found for module: '{result.Module}'");
continue;
}

var documents = result.Documents.Values.ToList();
if (_parameters.UseSourceLink && result.SourceLink != null)
{
Expand All @@ -386,6 +376,16 @@ private void CalculateCoverage()
}
}

if (!_fileSystem.Exists(result.HitsFilePath))
{
// Hits file could be missed mainly for two reason
// 1) Issue during module Unload()
// 2) Instrumented module is never loaded or used so we don't have any hit to register and
// module tracker is never used
_logger.LogVerbose($"Hits file:'{result.HitsFilePath}' not found for module: '{result.Module}'");
continue;
}

// Calculate lines to skip for every hits start/end candidate
// Nested ranges win on outermost one
foreach (HitCandidate hitCandidate in result.HitCandidates)
Expand Down
4 changes: 2 additions & 2 deletions test/coverlet.tests.projectsample.aspmvcrazor/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) Toni Solarin-Sodara
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

var builder = WebApplication.CreateBuilder(args);
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorPages();

var app = builder.Build();
WebApplication app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
Expand Down

0 comments on commit 302886a

Please sign in to comment.