Skip to content

Commit 4853da7

Browse files
author
Paul van Brenk
committed
Bunch of fixes for test adapter
1 parent 3274a87 commit 4853da7

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

Nodejs/Product/TestAdapter/TestExecutor.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrame
145145
/// <param name="frameworkHandle">Handle to framework. Used for recording results</param>
146146
public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
147147
{
148-
Debugger.Launch();
149-
150148
ValidateArg.NotNull(tests, "tests");
151149
ValidateArg.NotNull(runContext, "runContext");
152150
ValidateArg.NotNull(frameworkHandle, "frameworkHandle");

Nodejs/Product/TestAdapterShim/AssemblyResolver.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.IO;
55
using System.Reflection;
6+
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
67

78
namespace Microsoft.NodejsTools.TestAdapter
89
{
@@ -13,11 +14,24 @@ public AssemblyResolver()
1314
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
1415
}
1516

17+
internal static string GetVSInstallDir()
18+
{
19+
20+
var vsTestFrameworkAssembly = typeof(ITestExecutor).Assembly;
21+
var testAdapterPath = vsTestFrameworkAssembly.Location;
22+
23+
// C:\Program Files (x86)\Microsoft Visual Studio\2017\VSUJSLT\Common7\IDE\CommonExtensions\Microsoft\NodeJs Tools Unit Test Adapter\Microsoft.nodejstools.TestAdapter.dll
24+
var indexOfCommon7Ide = testAdapterPath.IndexOf("common7", StringComparison.OrdinalIgnoreCase);
25+
string vsInstallDir = testAdapterPath.Substring(0, indexOfCommon7Ide);
26+
27+
return vsInstallDir;
28+
}
29+
1630
private static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
1731
{
1832
// Use the setup API to find the VS install Dir, then build paths to the Private and Public Assemblies folders
19-
string installPath = @"C:\vs2017";
20-
string ideFolder = Path.Combine(installPath, "Common7\\IDE");
33+
var installPath = GetVSInstallDir();
34+
var ideFolder = Path.Combine(installPath, "Common7\\IDE");
2135
var paths = new[] {
2236
Path.Combine(ideFolder, "PrivateAssemblies"),
2337
Path.Combine(ideFolder, "PublicAssemblies"),
@@ -26,7 +40,7 @@ private static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
2640

2741
// This is what comes in for args.Name, but we really just want the dll file name:
2842
// "Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
29-
string resolveTargetAssemblyName = args.Name.Substring(0, args.Name.IndexOf(',')) + ".dll";
43+
var resolveTargetAssemblyName = args.Name.Substring(0, args.Name.IndexOf(',')) + ".dll";
3044

3145
foreach (var path in paths)
3246
{
@@ -42,7 +56,7 @@ private static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
4256
private static bool ResolveAssemblyPath(string possibleDirectory, string assemblyName, out Assembly resolvedAssembly)
4357
{
4458
resolvedAssembly = null;
45-
string candidateAssemblyPath = Path.Combine(possibleDirectory, assemblyName);
59+
var candidateAssemblyPath = Path.Combine(possibleDirectory, assemblyName);
4660
if (File.Exists(candidateAssemblyPath))
4761
{
4862
resolvedAssembly = Assembly.LoadFrom(candidateAssemblyPath);

Nodejs/Product/TestAdapterVsix/TestAdapterVsix.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<ProjectReference Include="..\TestAdapter\TestAdapter.csproj">
5555
<Project>{5085df35-3a32-4894-835e-e5a3956d4f57}</Project>
5656
<Name>TestAdapter</Name>
57-
<IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup%3bBuiltProjectOutputGroupDependencies%3bGetCopyToOutputDirectoryItems%3bSatelliteDllsProjectOutputGroup%3bPkgdefProjectOutputGroup%3b</IncludeOutputGroupsInVSIX>
57+
<IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup%3bBuiltProjectOutputGroupDependencies%3bGetCopyToOutputDirectoryItems%3bSatelliteDllsProjectOutputGroup%3b</IncludeOutputGroupsInVSIX>
5858
<IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup%3b</IncludeOutputGroupsInVSIXLocalOnly>
5959
<Private>True</Private>
6060
<VSIXSubPath>.</VSIXSubPath>

0 commit comments

Comments
 (0)