Skip to content

Commit

Permalink
Several small bits: better logging in some places, better handle issu…
Browse files Browse the repository at this point in the history
…es when DIA can't be loaded, better cleanup of VS experimental instance
  • Loading branch information
jgefele committed Jan 6, 2016
1 parent 88ea84d commit 667d2fe
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
7 changes: 2 additions & 5 deletions GoogleTestExtension/DiaAdapter/DiaResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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;
}
}
Expand All @@ -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;
}

Expand Down
13 changes: 11 additions & 2 deletions GoogleTestExtension/GoogleTestAdapter.VS/TestDiscoverer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using GoogleTestAdapter.VS.Framework;
using GoogleTestAdapter.VS.Helpers;
using GoogleTestAdapter.VS.Settings;
using System;

namespace GoogleTestAdapter.VS
{
Expand Down Expand Up @@ -42,8 +43,16 @@ public void DiscoverTests(IEnumerable<string> 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);
}

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public GoogleTestDiscoverer(TestEnvironment testEnviroment)
TestEnvironment = testEnviroment;
}

public void DiscoverTests(IEnumerable<string> executables, ILogger logger, ITestFrameworkReporter reporter)
public void DiscoverTests(IEnumerable<string> executables, ITestFrameworkReporter reporter)
{
List<string> googleTestExecutables = GetAllGoogleTestExecutables(executables);
foreach (string executable in googleTestExecutables)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ private IEnumerable<TestCaseLocation> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,17 @@ private IEnumerable<string> 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<string> 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);
}
}
}

0 comments on commit 667d2fe

Please sign in to comment.