Skip to content

Commit 3274a87

Browse files
author
Paul van Brenk
committed
test adapter fixes
1 parent 1b44714 commit 3274a87

21 files changed

+322
-159
lines changed

Common/Product/TestAdapter/TestContainer.cs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,18 @@ namespace Microsoft.VisualStudioTools.TestAdapter
1010
{
1111
internal class TestContainer : ITestContainer
1212
{
13-
private readonly DateTime _timeStamp;
14-
private readonly Architecture _architecture;
13+
private readonly DateTime timeStamp;
1514

1615
public TestContainer(ITestContainerDiscoverer discoverer, string source, DateTime timeStamp, Architecture architecture)
1716
{
18-
Discoverer = discoverer;
19-
Source = source;
20-
_timeStamp = timeStamp;
21-
_architecture = architecture;
17+
this.Discoverer = discoverer;
18+
this.Source = source;
19+
this.TargetPlatform = architecture;
20+
this.timeStamp = timeStamp;
2221
}
2322

2423
private TestContainer(TestContainer copy)
25-
: this(copy.Discoverer, copy.Source, copy._timeStamp, copy._architecture)
24+
: this(copy.Discoverer, copy.Source, copy.timeStamp, copy.TargetPlatform)
2625
{ }
2726

2827
public int CompareTo(ITestContainer other)
@@ -39,7 +38,7 @@ public int CompareTo(ITestContainer other)
3938
return result;
4039
}
4140

42-
return _timeStamp.CompareTo(container._timeStamp);
41+
return timeStamp.CompareTo(container.timeStamp);
4342
}
4443

4544
public IEnumerable<Guid> DebugEngines
@@ -61,29 +60,20 @@ public IDeploymentData DeployAppContainer()
6160
return null;
6261
}
6362

64-
public ITestContainerDiscoverer Discoverer { get; private set; }
63+
public ITestContainerDiscoverer Discoverer { get; }
6564

66-
public bool IsAppContainerTestContainer
67-
{
68-
get { return false; }
69-
}
65+
public bool IsAppContainerTestContainer => false;
7066

7167
public ITestContainer Snapshot()
7268
{
7369
return new TestContainer(this);
7470
}
7571

76-
public string Source { get; private set; }
72+
public string Source { get; }
7773

78-
public FrameworkVersion TargetFramework
79-
{
80-
get { return FrameworkVersion.None; }
81-
}
74+
public FrameworkVersion TargetFramework=> FrameworkVersion.None;
8275

83-
public Architecture TargetPlatform
84-
{
85-
get { return _architecture; }
86-
}
76+
public Architecture TargetPlatform { get; }
8777

8878
public override string ToString()
8979
{

Common/Product/TestAdapter/VisualStudioApp.cs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,10 @@ public DTE GetDTE()
7878
return dte;
7979
}
8080

81-
#if DEV15
8281
private static bool DTELoaded = false;
83-
#endif
8482

8583
private static DTE GetDTE(int processId)
8684
{
87-
#if DEV15
8885
// VS 2017 doesn't install some assemblies to the GAC that are needed to work with the
8986
// debugger, and as the tests don't execute in the devenv.exe process, those assemblies
9087
// fail to load - so load them manually from PublicAssemblies.
@@ -107,7 +104,7 @@ private static DTE GetDTE(int processId)
107104
}
108105
DTELoaded = true;
109106
}
110-
#endif
107+
111108
MessageFilter.Register();
112109

113110
var prefix = Process.GetProcessById(processId).ProcessName;
@@ -227,32 +224,30 @@ public bool AttachToProcess(ProcessOutput processOutput, EnvDTE.Process process,
227224
// dialog to the user.
228225
var dte = GetDTE();
229226
dte.SuppressUI = true;
227+
230228
try
231229
{
232-
try
230+
if (engines == null)
233231
{
234-
if (engines == null)
235-
{
236-
process.Attach();
237-
}
238-
else
239-
{
240-
var process3 = process as EnvDTE90.Process3;
241-
if (process3 == null)
242-
{
243-
return false;
244-
}
245-
process3.Attach2(engines.Select(engine => engine.ToString("B")).ToArray());
246-
}
247-
return true;
232+
process.Attach();
248233
}
249-
catch (COMException)
234+
else
250235
{
251-
if (processOutput.Wait(TimeSpan.FromMilliseconds(500)))
236+
var process3 = process as EnvDTE90.Process3;
237+
if (process3 == null)
252238
{
253-
// Process exited while we were trying
254239
return false;
255240
}
241+
process3.Attach2(engines.Select(engine => engine.ToString("B")).ToArray());
242+
}
243+
return true;
244+
}
245+
catch (COMException)
246+
{
247+
if (processOutput.Wait(TimeSpan.FromMilliseconds(500)))
248+
{
249+
// Process exited while we were trying
250+
return false;
256251
}
257252
}
258253
finally

Nodejs/NodejsTools.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26615.0
4+
VisualStudioVersion = 15.0.26430.14
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nodejs", "Product\Nodejs\Nodejs.csproj", "{32EC5259-98DA-40CA-9E2D-1B1B2E966F88}"
77
ProjectSection(ProjectDependencies) = postProject
@@ -28,6 +28,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NodejsToolsVsix", "Product\
2828
EndProject
2929
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TargetsVsix", "Product\TargetsVsix\TargetsVsix.csproj", "{CBA217C4-4338-4E50-9DEC-9227705F8124}"
3030
EndProject
31+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAdapterShim", "Product\TestAdapterShim\TestAdapterShim.csproj", "{A9609A35-B083-41A9-A0E8-AA1E2C4DA9A9}"
32+
EndProject
3133
Global
3234
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3335
Debug|Any CPU = Debug|Any CPU
@@ -74,6 +76,10 @@ Global
7476
{CBA217C4-4338-4E50-9DEC-9227705F8124}.Debug|Any CPU.Build.0 = Debug|Any CPU
7577
{CBA217C4-4338-4E50-9DEC-9227705F8124}.Release|Any CPU.ActiveCfg = Release|Any CPU
7678
{CBA217C4-4338-4E50-9DEC-9227705F8124}.Release|Any CPU.Build.0 = Release|Any CPU
79+
{A9609A35-B083-41A9-A0E8-AA1E2C4DA9A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
80+
{A9609A35-B083-41A9-A0E8-AA1E2C4DA9A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
81+
{A9609A35-B083-41A9-A0E8-AA1E2C4DA9A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
82+
{A9609A35-B083-41A9-A0E8-AA1E2C4DA9A9}.Release|Any CPU.Build.0 = Release|Any CPU
7783
EndGlobalSection
7884
GlobalSection(SolutionProperties) = preSolution
7985
HideSolutionNode = FALSE
@@ -89,6 +95,7 @@ Global
8995
{4EB09870-7422-4368-B8C8-74582764EAB3} = {F9719B35-F359-47A7-A2F8-34F42E53C809}
9096
{F3DB625F-EA2D-420F-BBC7-E4026CC6ECA3} = {F9719B35-F359-47A7-A2F8-34F42E53C809}
9197
{CBA217C4-4338-4E50-9DEC-9227705F8124} = {F9719B35-F359-47A7-A2F8-34F42E53C809}
98+
{A9609A35-B083-41A9-A0E8-AA1E2C4DA9A9} = {F9719B35-F359-47A7-A2F8-34F42E53C809}
9299
EndGlobalSection
93100
GlobalSection(ExtensibilityGlobals) = postSolution
94101
SolutionGuid = {B1CAB318-7961-42BF-A7B1-FBDB3EC225E9}

Nodejs/Product/Nodejs/Nodejs.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@
135135
<Private>False</Private>
136136
</Reference>
137137
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
138-
<SpecificVersion>False</SpecificVersion>
139138
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
140139
<Private>False</Private>
141140
</Reference>
@@ -408,7 +407,6 @@
408407
<Compile Include="Jade\Tokens\Tokenizer.cs" />
409408
<Compile Include="Nodejs.cs" />
410409
<Compile Include="NodejsProjectConfig.cs" />
411-
<Compile Include="NodejsToolsInstallPath.cs" />
412410
<Compile Include="NpmUI\ErrorHelper.cs" />
413411
<Compile Include="Options\NodejsDialogPage.cs">
414412
<SubType>Component</SubType>

Nodejs/Product/Nodejs/NodejsToolsInstallPath.cs

Lines changed: 0 additions & 35 deletions
This file was deleted.

Nodejs/Product/Nodejs/Project/NodejsProjectNode.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ internal override string GetItemType(string filename)
213213
return node.ItemNode.ItemTypeName;
214214
}
215215

216+
// TODO: make sure this also works for .tsx
216217
if (StringComparer.OrdinalIgnoreCase.Equals(Path.GetExtension(filename), NodejsConstants.TypeScriptExtension))
217218
{
218219
return NodejsConstants.TypeScriptCompileItemType;

Nodejs/Product/Npm/Npm.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<ItemGroup>
3535
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
3636
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
37+
<Private>True</Private>
3738
</Reference>
3839
<Reference Include="System" />
3940
<Reference Include="System.Core" />

Nodejs/Product/TestAdapter/TestAdapter.csproj

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
<Import Project="..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.props" />
44
<PropertyGroup>
55
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
6-
<FileUpgradeFlags>
7-
</FileUpgradeFlags>
8-
<UpgradeBackupLocation>
9-
</UpgradeBackupLocation>
10-
<OldToolsVersion>4.0</OldToolsVersion>
116
<NuGetPackageImportStamp>
127
</NuGetPackageImportStamp>
138
<GeneratePkgDefFile>false</GeneratePkgDefFile>
@@ -87,7 +82,7 @@
8782
</Reference>
8883
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
8984
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
90-
<Private>False</Private>
85+
<Private>True</Private>
9186
</Reference>
9287
<Reference Include="PresentationCore" />
9388
<Reference Include="PresentationFramework" />
@@ -180,7 +175,7 @@
180175
</Content>
181176
</ItemGroup>
182177
<ItemGroup>
183-
<FilesToSign Include="$(OutDir)\Microsoft.NodejsTools.TestAdapter.dll">
178+
<FilesToSign Include="$(OutDir)\$(AssemblyName).dll">
184179
<Authenticode>Microsoft</Authenticode>
185180
<StrongName>StrongName</StrongName>
186181
<InProject>false</InProject>

Nodejs/Product/TestAdapter/TestContainerDiscoverer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ private TestContainerDiscoverer([Import(typeof(SVsServiceProvider))]IServiceProv
3636
new SolutionEventsListener(serviceProvider),
3737
new TestFilesUpdateWatcher(),
3838
new TestFileAddRemoveListener(serviceProvider, Guids.NodejsBaseProjectFactory),
39-
operationState)
40-
{ }
39+
operationState)
40+
{
41+
}
4142

4243
public TestContainerDiscoverer(IServiceProvider serviceProvider,
4344
SolutionEventsListener solutionListener,

Nodejs/Product/TestAdapter/TestDiscoverer.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
1212
using Microsoft.VisualStudioTools;
1313
using MSBuild = Microsoft.Build.Evaluation;
14+
using System.Diagnostics;
1415

1516
namespace Microsoft.NodejsTools.TestAdapter
1617
{
17-
[FileExtension(NodejsConstants.NodejsProjectExtension)]
18-
[DefaultExecutorUri(TestExecutor.ExecutorUriString)]
19-
internal class TestDiscoverer : ITestDiscoverer
18+
public class TestDiscoverer
2019
{
2120
public TestDiscoverer()
2221
{
@@ -86,7 +85,6 @@ public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discove
8685
fileList.Add(new TestFileEntry(fileAbsolutePath, typeScriptTest));
8786
}
8887

89-
//Debug.Fail("Before Discover");
9088
DiscoverTests(testItems, proj, discoverySink, logger);
9189
}
9290
}
@@ -108,7 +106,7 @@ private void DiscoverTests(Dictionary<string, List<TestFileEntry>> testItems, MS
108106
{
109107
var result = new List<TestFrameworks.NodejsTestInfo>();
110108
var projectHome = Path.GetFullPath(Path.Combine(proj.DirectoryPath, "."));
111-
var projSource = ((MSBuild.Project)proj).FullPath;
109+
var projSource = proj.FullPath;
112110

113111
var nodeExePath =
114112
Nodejs.GetAbsoluteNodeExePath(
@@ -192,8 +190,8 @@ private class TestFileEntry
192190

193191
public TestFileEntry(string file, bool isTypeScriptTest)
194192
{
195-
File = file;
196-
IsTypeScriptTest = isTypeScriptTest;
193+
this.File = file;
194+
this.IsTypeScriptTest = isTypeScriptTest;
197195
}
198196
}
199197
}

0 commit comments

Comments
 (0)