Skip to content

Commit

Permalink
Merge pull request #128 from MarcoRossignoli/exeext
Browse files Browse the repository at this point in the history
Add exe modules to coverage
  • Loading branch information
tonerdo committed Jun 27, 2018
2 parents 85df126 + 271a1e6 commit 5217033
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/coverlet.core/Helpers/InstrumentationHelper.cs
Expand Up @@ -15,7 +15,7 @@ internal static class InstrumentationHelper
{
public static string[] GetCoverableModules(string module)
{
IEnumerable<string> modules = Directory.GetFiles(Path.GetDirectoryName(module), "*.dll");
IEnumerable<string> modules = Directory.EnumerateFiles(Path.GetDirectoryName(module)).Where(f => f.EndsWith(".exe") || f.EndsWith(".dll"));
modules = modules.Where(m => IsAssembly(m) && Path.GetFileName(m) != Path.GetFileName(module));
return modules.ToArray();
}
Expand Down
16 changes: 15 additions & 1 deletion test/coverlet.core.tests/Helpers/InstrumentationHelperTests.cs
@@ -1,6 +1,5 @@
using System;
using System.IO;

using Xunit;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -17,6 +16,21 @@ public void TestGetDependencies()
Assert.False(Array.Exists(modules, m => m == module));
}

[Fact]
public void TestExeModulesCoverage()
{
string module = typeof(InstrumentationHelperTests).Assembly.Location;
string exeModule = Path.ChangeExtension(module, ".exe");
string noExtModule = Path.ChangeExtension(module, "").TrimEnd('.');
File.Delete(exeModule);
File.Copy(module, exeModule);
File.Delete(noExtModule);
File.Copy(module, noExtModule);
var modules = InstrumentationHelper.GetCoverableModules(module);
Assert.True(Array.Exists(modules, m => m == exeModule));
Assert.False(Array.Exists(modules, m => m == noExtModule));
}

[Fact]
public void TestHasPdb()
{
Expand Down

0 comments on commit 5217033

Please sign in to comment.