public static bool IsGoogleTestExecutable(string executable, string customRegex, ILogger logger) { string googleTestIndicatorFile = $"{executable}{GoogleTestIndicator}"; if (File.Exists(googleTestIndicatorFile)) { logger.DebugInfo(String.Format(Resources.FileFound, executable)); return(true); } if (string.IsNullOrWhiteSpace(customRegex)) { if (PeParser.FindImport(executable, GoogleTestConstants.GoogleTestDllMarker, StringComparison.OrdinalIgnoreCase, logger) || Utils.BinaryFileContainsStrings(executable, Encoding.ASCII, GoogleTestConstants.GoogleTestExecutableMarkers)) { logger.DebugInfo($"Google Test indicators found in executable {executable}"); return(true); } } else { if (SafeMatches(executable, customRegex, logger)) { logger.DebugInfo(String.Format(Resources.MatchesCustom, executable, customRegex)); return(true); } } logger.DebugInfo(String.Format(Resources.FileNotFound, executable)); return(false); }
public static bool IsGoogleTestExecutable(string executable, string customRegex, ILogger logger) { string googleTestIndicatorFile = $"{executable}{GoogleTestIndicator}"; if (File.Exists(googleTestIndicatorFile)) { logger.DebugInfo($"Google Test indicator file found for executable {executable} ({googleTestIndicatorFile})"); return(true); } if (string.IsNullOrWhiteSpace(customRegex)) { if (PeParser.FindImport(executable, GoogleTestConstants.GoogleTestDllMarker, StringComparison.OrdinalIgnoreCase, logger) || Utils.BinaryFileContainsStrings(executable, Encoding.ASCII, GoogleTestConstants.GoogleTestExecutableMarkers)) { logger.DebugInfo($"Google Test indicators found in executable {executable}"); return(true); } } else { if (SafeMatches(executable, customRegex, logger)) { logger.DebugInfo($"Custom regex '{customRegex}' matches executable '{executable}'"); return(true); } } logger.DebugInfo($"File does not seem to be Google Test executable: '{executable}'"); return(false); }