Skip to content

Solution based merging for data collector #1676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adaptions
  • Loading branch information
DavidMuellerGetinge committed Feb 9, 2025
commit 5b2925304605b73845f2e04cfa5cfd5b163adbe0
Original file line number Diff line number Diff line change
@@ -45,6 +45,8 @@ public Task<ICollection<AttachmentSet>> ProcessAttachmentSetsAsync(XmlElement co
bool useSourceLink = _reportFormatParser.ParseUseSourceLink(configurationElement);
bool reportMerging = _reportFormatParser.ParseReportMerging(configurationElement);

AttachDebugger();

if (!reportMerging) return Task.FromResult(attachments);

IList<IReporter> reporters = CreateReporters(formats).ToList();
@@ -54,11 +56,13 @@ public Task<ICollection<AttachmentSet>> ProcessAttachmentSetsAsync(XmlElement co
_coverageResult.Parameters = new CoverageParameters() {DeterministicReport = deterministic, UseSourceLink = useSourceLink };

var fileAttachments = attachments.SelectMany(x => x.Attachments.Where(IsFileWithJsonExt)).ToList();
string mergeFilePath = fileAttachments.First().Uri.LocalPath;
string mergeFilePath = Path.GetDirectoryName(fileAttachments.First().Uri.LocalPath);

// does merge only work for json extensions, how are they created now if isn't specified in runsettings
MergeExistingJsonReports(attachments);
WriteCoverageReports(reporters, mergeFilePath, _coverageResult);
// check if we can remove more than just the json extension files
// maybe don't remove the merged json file as it is printed to the console
RemoveObsoleteReports(fileAttachments);

attachments = new List<AttachmentSet> { attachments.First() };
@@ -90,6 +94,7 @@ private void WriteCoverageReports(IEnumerable<IReporter> reporters, string direc
foreach (IReporter reporter in reporters)
{
string report = GetCoverageReport(coverageResult, reporter);
//throws exceptions -- check what the problem is
string filePath = Path.Combine(directory, Path.ChangeExtension(CoverletConstants.DefaultFileName, reporter.Extension));
File.WriteAllText(filePath, report);
}
@@ -108,8 +113,6 @@ private void MergeWithCoverageResult(string filePath, CoverageResult coverageRes

private string GetCoverageReport(CoverageResult coverageResult, IReporter reporter)
{
AttachDebugger();

try
{
// check if we need the sourceRootTranslator here