Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion GoogleTestAdapter/Core/GoogleTestConstants.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file has been modified by Microsoft on 5/2018.
// This file has been modified by Microsoft on 4/2020.

using System;

Expand Down Expand Up @@ -32,6 +32,9 @@ public static class GoogleTestConstants
public const string TypedTestMarker = ". # TypeParam = ";

public const string GoogleTestDllMarker = "gtest.dll";
public const string GoogleTestDllMarkerDebug = "gtestd.dll";
public const string GoogleTestMainDllMarker = "gtest_main.dll";
public const string GoogleTestMainDllMarkerDebug = "gtest_maind.dll";

public static readonly string[] GoogleTestExecutableMarkers =
{
Expand Down
7 changes: 5 additions & 2 deletions GoogleTestAdapter/Core/GoogleTestDiscoverer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file has been modified by Microsoft on 9/2017.
// This file has been modified by Microsoft on 4/2020.

using GoogleTestAdapter.Common;
using GoogleTestAdapter.DiaResolver;
Expand Down Expand Up @@ -104,7 +104,10 @@ public static bool IsGoogleTestExecutable(string executable, string customRegex,

if (string.IsNullOrWhiteSpace(customRegex))
{
if (PeParser.FindImport(executable, GoogleTestConstants.GoogleTestDllMarker, StringComparison.OrdinalIgnoreCase, logger)
List<string> gtestImports = new List<string>() { GoogleTestConstants.GoogleTestDllMarker, GoogleTestConstants.GoogleTestDllMarkerDebug,
GoogleTestConstants.GoogleTestMainDllMarker, GoogleTestConstants.GoogleTestMainDllMarkerDebug };

if (PeParser.FindImport(executable, gtestImports, StringComparison.OrdinalIgnoreCase, logger)
|| Utils.BinaryFileContainsStrings(executable, Encoding.ASCII, GoogleTestConstants.GoogleTestExecutableMarkers))
{
return true;
Expand Down
8 changes: 5 additions & 3 deletions GoogleTestAdapter/DiaResolver/PeParser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file has been modified by Microsoft on 11/2017.
// This file has been modified by Microsoft on 4/2020.

using GoogleTestAdapter.Common;
using Microsoft.Win32.SafeHandles;
Expand Down Expand Up @@ -277,12 +277,14 @@ public static List<string> ParseImports(string executable, ILogger logger)
return imports;
}

public static bool FindImport(string executable, string import, StringComparison comparisonType, ILogger logger)
public static bool FindImport(string executable, List<string> imports, StringComparison comparisonType, ILogger logger)
{
var found = false;
ProcessImports(executable, logger, (currentImport) =>
{
found = String.Compare(import, currentImport, comparisonType) == 0;
foreach (var import in imports)
found = found || String.Compare(import, currentImport, comparisonType) == 0;

return !found; // Continue only if not found yet.
});
return found;
Expand Down