Skip to content

Commit 749f017

Browse files
committed
fix unresponsive Test Explorer problem (RetryHelper.Do AggregateException)
- Changed task in `publish-coverage-results.yml` from `PublishCodeCoverageResults@1` to `PublishCodeCoverageResults@2` and added `reportDirectory` parameter for coverage report location. - Added overloaded `BackupOriginalModule` methods in `InstrumentationHelper.cs` to improve backup flexibility, including a new `withBackupList` parameter. - Updated `InstrumentationHelperTests.cs` to align tests with the new method signature for backing up original modules.
1 parent 2767744 commit 749f017

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

eng/publish-coverage-results.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ steps:
2626
artifact: CoverageResults_$(Agent.Os)_$(BuildConfiguration)
2727
condition: ${{parameters.condition}}
2828

29-
- task: PublishCodeCoverageResults@2
29+
- task: PublishCodeCoverageResults@1
3030
displayName: 'Publish code coverage'
3131
condition: ${{parameters.condition}}
3232
inputs:
3333
codeCoverageTool: Cobertura
3434
summaryFileLocation: '$(Build.SourcesDirectory)/artifacts/CoverageReport/Cobertura.xml'
35+
reportDirectory: '$(Build.SourcesDirectory)/artifacts/CoverageReport'
3536
failIfCoverageEmpty: ${{parameters.breakBuild}}

src/coverlet.core/Helpers/InstrumentationHelper.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,28 @@ private bool MatchDocumentsWithSourcesMissingAll(MetadataReader metadataReader)
236236
return (true, string.Empty);
237237
}
238238

239+
/// <summary>
240+
/// Backs up the original module to a specified location.
241+
/// </summary>
242+
/// <param name="module">The path to the module to be backed up.</param>
243+
/// <param name="identifier">A unique identifier to distinguish the backup file.</param>
239244
public void BackupOriginalModule(string module, string identifier)
245+
{
246+
BackupOriginalModule(module, identifier, true);
247+
}
248+
249+
/// <summary>
250+
/// Backs up the original module to a specified location.
251+
/// </summary>
252+
/// <param name="module">The path to the module to be backed up.</param>
253+
/// <param name="identifier">A unique identifier to distinguish the backup file.</param>
254+
/// <param name="withBackupList">Indicates whether to add the backup to the backup list. Required for test TestBackupOriginalModule</param>
255+
public void BackupOriginalModule(string module, string identifier, bool withBackupList)
240256
{
241257
string backupPath = GetBackupPath(module, identifier);
242258
string backupSymbolPath = Path.ChangeExtension(backupPath, ".pdb");
243259
_fileSystem.Copy(module, backupPath, true);
244-
if (!_backupList.TryAdd(module, backupPath))
260+
if (withBackupList && !_backupList.TryAdd(module, backupPath))
245261
{
246262
throw new ArgumentException($"Key already added '{module}'");
247263
}
@@ -250,13 +266,18 @@ public void BackupOriginalModule(string module, string identifier)
250266
if (_fileSystem.Exists(symbolFile))
251267
{
252268
_fileSystem.Copy(symbolFile, backupSymbolPath, true);
253-
if (!_backupList.TryAdd(symbolFile, backupSymbolPath))
269+
if (withBackupList && !_backupList.TryAdd(symbolFile, backupSymbolPath))
254270
{
255271
throw new ArgumentException($"Key already added '{module}'");
256272
}
257273
}
258274
}
259275

276+
/// <summary>
277+
/// Restores the original module from a backup.
278+
/// </summary>
279+
/// <param name="module">The path to the module to be restored.</param>
280+
/// <param name="identifier">A unique identifier to distinguish the backup file.</param>
260281
public virtual void RestoreOriginalModule(string module, string identifier)
261282
{
262283
string backupPath = GetBackupPath(module, identifier);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void TestBackupOriginalModule()
102102
string module = typeof(InstrumentationHelperTests).Assembly.Location;
103103
string identifier = Guid.NewGuid().ToString();
104104

105-
_instrumentationHelper.BackupOriginalModule(module, identifier);
105+
_instrumentationHelper.BackupOriginalModule(module, identifier, false);
106106

107107
string backupPath = Path.Combine(
108108
Path.GetTempPath(),

0 commit comments

Comments
 (0)