From 667d2fe2f0964a0648130efe2018ae7ed15c2343 Mon Sep 17 00:00:00 2001 From: Jonas Gefele Date: Wed, 6 Jan 2016 23:50:19 +0100 Subject: [PATCH] Several small bits: better logging in some places, better handle issues when DIA can't be loaded, better cleanup of VS experimental instance --- GoogleTestExtension/DiaAdapter/DiaResolver.cs | 7 ++----- .../GoogleTestAdapter.VS/TestDiscoverer.cs | 13 +++++++++++-- .../GoogleTestAdapter/GoogleTestDiscoverer.cs | 2 +- .../GoogleTestAdapter/Helpers/TestCaseFactory.cs | 1 + .../VsExperimentalInstance.cs | 7 +++++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/GoogleTestExtension/DiaAdapter/DiaResolver.cs b/GoogleTestExtension/DiaAdapter/DiaResolver.cs index a2034cfac..221a39624 100644 --- a/GoogleTestExtension/DiaAdapter/DiaResolver.cs +++ b/GoogleTestExtension/DiaAdapter/DiaResolver.cs @@ -44,7 +44,6 @@ public sealed class DiaResolver private static readonly Guid Dia140 = new Guid("e6756135-1e65-4d17-8576-610761398c3c"); private static readonly Guid Dia120 = new Guid("3bfcea48-620f-4b6b-81f7-b9af75454c7d"); private static readonly Guid Dia110 = new Guid("761D3BCD-1304-41D5-94E8-EAC54E4AC172"); - private const uint REGDB_E_CLASSNOTREG = 0x80040154; private string Binary { get; } @@ -62,10 +61,8 @@ private bool TryCreateDiaInstance(Guid clsid) DiaDataSource = (IDiaDataSource)System.Activator.CreateInstance(comType); return true; } - catch (COMException ex) + catch (Exception) { - if((uint)ex.HResult != REGDB_E_CLASSNOTREG) - ErrorMessages.Add(ex.ToString()); return false; } } @@ -76,7 +73,7 @@ public DiaResolver(string binary) if (!TryCreateDiaInstance(Dia140) && !TryCreateDiaInstance(Dia120) && !TryCreateDiaInstance(Dia110)) { - ErrorMessages.Add("Couldn't find any MSDIA implementation"); + ErrorMessages.Add("Couldn't find the msdia.dll to parse *.pdb files. You will not get any source locations for your tests."); return; } diff --git a/GoogleTestExtension/GoogleTestAdapter.VS/TestDiscoverer.cs b/GoogleTestExtension/GoogleTestAdapter.VS/TestDiscoverer.cs index 470adba34..100a982a4 100644 --- a/GoogleTestExtension/GoogleTestAdapter.VS/TestDiscoverer.cs +++ b/GoogleTestExtension/GoogleTestAdapter.VS/TestDiscoverer.cs @@ -7,6 +7,7 @@ using GoogleTestAdapter.VS.Framework; using GoogleTestAdapter.VS.Helpers; using GoogleTestAdapter.VS.Settings; +using System; namespace GoogleTestAdapter.VS { @@ -42,8 +43,16 @@ public void DiscoverTests(IEnumerable executables, IDiscoveryContext dis new DebugHelper(TestEnvironment).CheckDebugModeForDiscoveryCode(); - VsTestFrameworkReporter reporter = new VsTestFrameworkReporter(discoverySink, null, TestEnvironment); - Discoverer.DiscoverTests(executables, loggerAdapter, reporter); + try + { + VsTestFrameworkReporter reporter = new VsTestFrameworkReporter(discoverySink, null, TestEnvironment); + Discoverer.DiscoverTests(executables, reporter); + } + catch (Exception e) + { + TestEnvironment.LogError("Exception while discovering tests: " + e); + } + } } diff --git a/GoogleTestExtension/GoogleTestAdapter/GoogleTestDiscoverer.cs b/GoogleTestExtension/GoogleTestAdapter/GoogleTestDiscoverer.cs index 57e5aeefd..86352e05a 100644 --- a/GoogleTestExtension/GoogleTestAdapter/GoogleTestDiscoverer.cs +++ b/GoogleTestExtension/GoogleTestAdapter/GoogleTestDiscoverer.cs @@ -19,7 +19,7 @@ public GoogleTestDiscoverer(TestEnvironment testEnviroment) TestEnvironment = testEnviroment; } - public void DiscoverTests(IEnumerable executables, ILogger logger, ITestFrameworkReporter reporter) + public void DiscoverTests(IEnumerable executables, ITestFrameworkReporter reporter) { List googleTestExecutables = GetAllGoogleTestExecutables(executables); foreach (string executable in googleTestExecutables) diff --git a/GoogleTestExtension/GoogleTestAdapter/Helpers/TestCaseFactory.cs b/GoogleTestExtension/GoogleTestAdapter/Helpers/TestCaseFactory.cs index 4d826ea3f..10cf02b0e 100644 --- a/GoogleTestExtension/GoogleTestAdapter/Helpers/TestCaseFactory.cs +++ b/GoogleTestExtension/GoogleTestAdapter/Helpers/TestCaseFactory.cs @@ -239,6 +239,7 @@ private IEnumerable FindTestCaseLocationsInBinary( .Select(nsfl => ToTestCaseLocation(nsfl, allTraitSymbols)) .ToList(); // we need to force immediate query execution, otherwise our session object will already be released + errorMessages.AddRange(resolver.ErrorMessages); resolver.Dispose(); return result; diff --git a/GoogleTestExtension/GoogleTestAdapterUiTests/VsExperimentalInstance.cs b/GoogleTestExtension/GoogleTestAdapterUiTests/VsExperimentalInstance.cs index dc1777bc0..1460d2318 100644 --- a/GoogleTestExtension/GoogleTestAdapterUiTests/VsExperimentalInstance.cs +++ b/GoogleTestExtension/GoogleTestAdapterUiTests/VsExperimentalInstance.cs @@ -95,14 +95,17 @@ private IEnumerable GetVsDirectories() { string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); foreach(var folder in new[]{ VersionAndSuffix, Suffix }) - yield return Path.Combine(localAppData, "Microsoft", "VisualStudio", folder); + yield return Path.Combine(localAppData, @"Microsoft\VisualStudio", folder); } private IEnumerable GetVsHkcuKeys() { - string path = Path.Combine("SOFTWARE", "Microsoft", "VisualStudio", VersionAndSuffix); + string path = Path.Combine(@"SOFTWARE\Microsoft\VisualStudio", VersionAndSuffix); foreach (var additionalSuffix in new[] { "", "_Config", "_Remote" }) yield return path + additionalSuffix; + + yield return Path.Combine(@"SOFTWARE\Microsoft\VSCommon", Suffix); + yield return Path.Combine(@"SOFTWARE\Microsoft\VsHub\ServiceModules\Settings\PerHubName", Suffix); } } }