Skip to content

Commit 5217033

Browse files
authored
Merge pull request #128 from MarcoRossignoli/exeext
Add exe modules to coverage
2 parents 85df126 + 271a1e6 commit 5217033

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/coverlet.core/Helpers/InstrumentationHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal static class InstrumentationHelper
1515
{
1616
public static string[] GetCoverableModules(string module)
1717
{
18-
IEnumerable<string> modules = Directory.GetFiles(Path.GetDirectoryName(module), "*.dll");
18+
IEnumerable<string> modules = Directory.EnumerateFiles(Path.GetDirectoryName(module)).Where(f => f.EndsWith(".exe") || f.EndsWith(".dll"));
1919
modules = modules.Where(m => IsAssembly(m) && Path.GetFileName(m) != Path.GetFileName(module));
2020
return modules.ToArray();
2121
}

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.IO;
3-
43
using Xunit;
54
using System.Collections.Generic;
65
using System.Linq;
@@ -17,6 +16,21 @@ public void TestGetDependencies()
1716
Assert.False(Array.Exists(modules, m => m == module));
1817
}
1918

19+
[Fact]
20+
public void TestExeModulesCoverage()
21+
{
22+
string module = typeof(InstrumentationHelperTests).Assembly.Location;
23+
string exeModule = Path.ChangeExtension(module, ".exe");
24+
string noExtModule = Path.ChangeExtension(module, "").TrimEnd('.');
25+
File.Delete(exeModule);
26+
File.Copy(module, exeModule);
27+
File.Delete(noExtModule);
28+
File.Copy(module, noExtModule);
29+
var modules = InstrumentationHelper.GetCoverableModules(module);
30+
Assert.True(Array.Exists(modules, m => m == exeModule));
31+
Assert.False(Array.Exists(modules, m => m == noExtModule));
32+
}
33+
2034
[Fact]
2135
public void TestHasPdb()
2236
{

0 commit comments

Comments
 (0)