Skip to content

Commit 8e8728b

Browse files
Bring back PSES tests (#1190)
* initial attempt * update sln * use combine instead * PowerShell Core fixed tests * use CodeBase instead of Location because of .NET Framework * codacy fixes * path fix for unix * use temp path * address rob's feedback * codacy
1 parent 15df5e0 commit 8e8728b

File tree

55 files changed

+1924
-3437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1924
-3437
lines changed

PowerShellEditorServices.build.ps1

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function Invoke-WithCreateDefaultHook {
5050
}
5151
}
5252

53-
task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestE2E {
53+
task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestE2E {
5454

5555
$dotnetPath = "$PSScriptRoot/.dotnet"
5656
$dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" }
@@ -241,8 +241,7 @@ function DotNetTestFilter {
241241
if ($TestFilter) { @("--filter",$TestFilter) } else { "" }
242242
}
243243

244-
# task Test TestServer,TestProtocol,TestE2E
245-
task Test TestE2E
244+
task Test TestServer,TestE2E
246245

247246
task TestServer {
248247
Set-Location .\test\PowerShellEditorServices.Test\
@@ -256,18 +255,6 @@ task TestServer {
256255
}
257256
}
258257

259-
task TestProtocol {
260-
Set-Location .\test\PowerShellEditorServices.Test.Protocol\
261-
262-
if (-not $script:IsUnix) {
263-
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Desktop (DotNetTestFilter) }
264-
}
265-
266-
Invoke-WithCreateDefaultHook {
267-
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Core (DotNetTestFilter) }
268-
}
269-
}
270-
271258
task TestHost {
272259
Set-Location .\test\PowerShellEditorServices.Test.Host\
273260

PowerShellEditorServices.sln

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{E231
1818
scripts\AddCopyrightHeaders.ps1 = scripts\AddCopyrightHeaders.ps1
1919
EndProjectSection
2020
EndProject
21-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.Test.Protocol", "test\PowerShellEditorServices.Test.Protocol\PowerShellEditorServices.Test.Protocol.csproj", "{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}"
22-
EndProject
2321
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.VSCode", "src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj", "{3B38E8DA-8BFF-4264-AF16-47929E6398A3}"
2422
EndProject
2523
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices", "src\PowerShellEditorServices\PowerShellEditorServices.csproj", "{29EEDF03-0990-45F4-846E-2616970D1FA2}"
@@ -95,24 +93,6 @@ Global
9593
{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|x64.Build.0 = Release|Any CPU
9694
{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|x86.ActiveCfg = Release|Any CPU
9795
{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|x86.Build.0 = Release|Any CPU
98-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.CoreCLR|Any CPU.ActiveCfg = Release|Any CPU
99-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.CoreCLR|Any CPU.Build.0 = Release|Any CPU
100-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.CoreCLR|x64.ActiveCfg = Release|Any CPU
101-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.CoreCLR|x64.Build.0 = Release|Any CPU
102-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.CoreCLR|x86.ActiveCfg = Release|Any CPU
103-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.CoreCLR|x86.Build.0 = Release|Any CPU
104-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
105-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
106-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|x64.ActiveCfg = Debug|Any CPU
107-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|x64.Build.0 = Debug|Any CPU
108-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|x86.ActiveCfg = Debug|Any CPU
109-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|x86.Build.0 = Debug|Any CPU
110-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
111-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|Any CPU.Build.0 = Release|Any CPU
112-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|x64.ActiveCfg = Release|Any CPU
113-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|x64.Build.0 = Release|Any CPU
114-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|x86.ActiveCfg = Release|Any CPU
115-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|x86.Build.0 = Release|Any CPU
11696
{3B38E8DA-8BFF-4264-AF16-47929E6398A3}.CoreCLR|Any CPU.ActiveCfg = CoreCLR|Any CPU
11797
{3B38E8DA-8BFF-4264-AF16-47929E6398A3}.CoreCLR|Any CPU.Build.0 = CoreCLR|Any CPU
11898
{3B38E8DA-8BFF-4264-AF16-47929E6398A3}.CoreCLR|x64.ActiveCfg = CoreCLR|Any CPU
@@ -193,7 +173,6 @@ Global
193173
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
194174
{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
195175
{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
196-
{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
197176
{3B38E8DA-8BFF-4264-AF16-47929E6398A3} = {F594E7FD-1E72-4E51-A496-B019C2BA3180}
198177
{29EEDF03-0990-45F4-846E-2616970D1FA2} = {F594E7FD-1E72-4E51-A496-B019C2BA3180}
199178
{2561F253-8F72-436A-BCC3-AA63AB82EDC0} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}

src/PowerShellEditorServices/PowerShellEditorServices.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
2525
<_Parameter1>Microsoft.PowerShell.EditorServices.Hosting</_Parameter1>
2626
</AssemblyAttribute>
27+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
28+
<_Parameter1>Microsoft.PowerShell.EditorServices.Test</_Parameter1>
29+
</AssemblyAttribute>
30+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
31+
<_Parameter1>Microsoft.PowerShell.EditorServices.Test.Shared</_Parameter1>
32+
</AssemblyAttribute>
2733
</ItemGroup>
2834

2935
<ItemGroup>

src/PowerShellEditorServices/Services/PowerShellContext/Console/ChoicePromptHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public Task<int> PromptForChoiceAsync(
146146
throw new TaskCanceledException(task);
147147
}
148148

149-
return this.GetSingleResult(task.Result);
149+
return this.GetSingleResult(task.GetAwaiter().GetResult());
150150
}));
151151
}
152152

@@ -205,7 +205,7 @@ private async Task<T> WaitForTaskAsync<T>(Task<T> taskToWait)
205205
throw new PipelineStoppedException();
206206
}
207207

208-
return taskToWait.Result;
208+
return await taskToWait.ConfigureAwait(false);
209209
}
210210

211211
private async Task<int[]> StartPromptLoopAsync(

src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,13 @@ public void Initialize(
431431
/// the runspace. This method will be moved somewhere else soon.
432432
/// </summary>
433433
/// <returns></returns>
434-
public Task ImportCommandsModuleAsync()
434+
public Task ImportCommandsModuleAsync() => ImportCommandsModuleAsync(s_commandsModulePath);
435+
436+
public Task ImportCommandsModuleAsync(string path)
435437
{
436438
PSCommand importCommand = new PSCommand()
437439
.AddCommand("Import-Module")
438-
.AddArgument(s_commandsModulePath);
440+
.AddArgument(path);
439441

440442
return this.ExecuteCommandAsync<PSObject>(importCommand, sendOutputToHost: false, sendErrorToHost: false);
441443
}

src/PowerShellEditorServices/Services/TextDocument/FoldingReference.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.PowerShell.EditorServices.Services.TextDocument
1212
/// <summary>
1313
/// A class that holds the information for a foldable region of text in a document
1414
/// </summary>
15-
public class FoldingReference: IComparable<FoldingReference>
15+
public class FoldingReference: IComparable<FoldingReference>, IEquatable<FoldingReference>
1616
{
1717
/// <summary>
1818
/// The zero-based line number from where the folded range starts.
@@ -59,8 +59,26 @@ public int CompareTo(FoldingReference that) {
5959
if (this.EndCharacter > that.EndCharacter) { return 1; }
6060

6161
// They're the same range, but what about kind
62-
return that.Kind.Value - this.Kind.Value;
62+
if (this.Kind == null)
63+
{
64+
if (that.Kind == null)
65+
{
66+
return 0;
67+
}
68+
// that has a kind but this doesn't.
69+
return 1;
70+
}
71+
72+
if (that.Kind != null)
73+
{
74+
return that.Kind.Value - this.Kind.Value;
75+
}
76+
77+
// this has a kind but that doesn't.
78+
return -1;
6379
}
80+
81+
public bool Equals(FoldingReference other) => this.CompareTo(other) == 0;
6482
}
6583

6684
/// <summary>

test/PowerShellEditorServices.Test.Host/PowerShellEditorServices.Test.Host.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
</ItemGroup>
1212
<ItemGroup>
1313
<ProjectReference Include="..\..\src\PowerShellEditorServices\PowerShellEditorServices.csproj" />
14-
<ProjectReference Include="..\..\src\PowerShellEditorServices.Protocol\PowerShellEditorServices.Protocol.csproj" />
1514
<ProjectReference Include="..\..\src\PowerShellEditorServices.Host\PowerShellEditorServices.Host.csproj" />
1615
<ProjectReference Include="..\PowerShellEditorServices.Test.Shared\PowerShellEditorServices.Test.Shared.csproj" />
1716
</ItemGroup>

test/PowerShellEditorServices.Test.Protocol/App.config

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

test/PowerShellEditorServices.Test.Protocol/DebugAdapter/V8MessageSerializerTests.cs

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

0 commit comments

Comments
 (0)