Skip to content

Commit e570335

Browse files
Robert HoltTylerLeonhardt
Robert Holt
authored andcommitted
[Ignore] Fix rebase errors, migrate upstream tests
1 parent af43440 commit e570335

File tree

3 files changed

+67
-24
lines changed

3 files changed

+67
-24
lines changed

src/PowerShellEditorServices/Language/LanguageService.cs

+6-7
Original file line numberDiff line numberDiff line change
@@ -744,13 +744,12 @@ private async Task GetAliases()
744744
return;
745745
}
746746

747-
CommandInvocationIntrinsics invokeCommand = runspaceHandle.Runspace.SessionStateProxy.InvokeCommand;
748-
var aliases = await _powerShellContext.ExecuteCommand<AliasInfo>(
749-
new PSCommand()
750-
.AddCommand("Microsoft.PowerShell.Core\\Get-Command")
751-
.AddParameter("CommandType", CommandTypes.Alias),
752-
sendOutputToHost: false,
753-
sendErrorToHost: false);
747+
var aliases = await _powerShellContext.ExecuteCommand<AliasInfo>(
748+
new PSCommand()
749+
.AddCommand("Microsoft.PowerShell.Core\\Get-Command")
750+
.AddParameter("CommandType", CommandTypes.Alias),
751+
sendOutputToHost: false,
752+
sendErrorToHost: false);
754753

755754
foreach (AliasInfo aliasInfo in aliases)
756755
{

test/PowerShellEditorServices.Test/Session/ScriptFileTests.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -137,31 +137,31 @@ public void CanApplyMultiLineDelete()
137137
public void CanApplyEditsToEndOfFile()
138138
{
139139
this.AssertFileChange(
140-
"line1\r\nline2\r\nline3\r\n\r\n",
141-
"line1\r\nline2\r\nline3\r\n\r\n\r\n\r\n",
140+
TestUtilities.NormalizeNewlines("line1\nline2\nline3\n\n"),
141+
TestUtilities.NormalizeNewlines("line1\nline2\nline3\n\n\n\n"),
142142
new FileChange
143143
{
144144
Line = 5,
145145
EndLine = 5,
146146
Offset = 1,
147147
EndOffset = 1,
148-
InsertString = "\r\n\r\n"
148+
InsertString = TestUtilities.NormalizeNewlines("\n\n")
149149
});
150150
}
151151

152152
[Fact]
153153
public void CanAppendToEndOfFile()
154154
{
155155
this.AssertFileChange(
156-
"line1\r\nline2\r\nline3",
157-
"line1\r\nline2\r\nline3\r\nline4\r\nline5",
156+
TestUtilities.NormalizeNewlines("line1\nline2\nline3"),
157+
TestUtilities.NormalizeNewlines("line1\nline2\nline3\nline4\nline5"),
158158
new FileChange
159159
{
160160
Line = 4,
161161
EndLine = 5,
162162
Offset = 1,
163163
EndOffset = 1,
164-
InsertString = "line4\r\nline5"
164+
InsertString = TestUtilities.NormalizeNewlines("line4\nline5")
165165
}
166166
);
167167
}
@@ -216,8 +216,8 @@ public void ThrowsExceptionWithEditOutsideOfRange()
216216
public void CanDeleteFromEndOfFile()
217217
{
218218
this.AssertFileChange(
219-
"line1\r\nline2\r\nline3\r\nline4",
220-
"line1\r\nline2",
219+
TestUtilities.NormalizeNewlines("line1\nline2\nline3\nline4"),
220+
TestUtilities.NormalizeNewlines("line1\nline2"),
221221
new FileChange
222222
{
223223
Line = 3,

test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs

+53-9
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55

66
using System;
77
using System.IO;
8+
using System.Collections.Generic;
89
using Microsoft.PowerShell.EditorServices.Test.Shared;
910
using Microsoft.PowerShell.EditorServices.Utility;
1011
using Xunit;
1112

13+
#if CoreCLR
14+
using System.Runtime.InteropServices;
15+
#endif
16+
1217
namespace Microsoft.PowerShell.EditorServices.Test.Session
1318
{
1419
public class WorkspaceTests
@@ -76,15 +81,7 @@ public void CanDetermineIsPathInMemory()
7681
}
7782

7883
[Theory()]
79-
[InlineData("file:///C%3A/banana/", @"C:\banana\")]
80-
[InlineData("file:///C%3A/banana/ex.ps1", @"C:\banana\ex.ps1")]
81-
[InlineData("file:///E%3A/Path/to/awful%23path", @"E:\Path\to\awful#path")]
82-
[InlineData("file:///path/with/no/drive", @"C:\path\with\no\drive")]
83-
[InlineData("file:///path/wi[th]/squ[are/brackets/", @"C:\path\wi[th]\squ[are\brackets\")]
84-
[InlineData("file:///Carrots/A%5Ere/Good/", @"C:\Carrots\A^re\Good\")]
85-
[InlineData("file:///Users/barnaby/%E8%84%9A%E6%9C%AC/Reduce-Directory", @"C:\Users\barnaby\脚本\Reduce-Directory")]
86-
[InlineData("file:///C%3A/Program%20Files%20%28x86%29/PowerShell/6/pwsh.exe", @"C:\Program Files (x86)\PowerShell\6\pwsh.exe")]
87-
[InlineData("file:///home/maxim/test%20folder/%D0%9F%D0%B0%D0%BF%D0%BA%D0%B0/helloworld.ps1", @"C:\home\maxim\test folder\Папка\helloworld.ps1")]
84+
[MemberData(nameof(PathResolutionInput))]
8885
public void CorrectlyResolvesPaths(string givenPath, string expectedPath)
8986
{
9087
Workspace workspace = new Workspace(PowerShellVersion, Logging.NullLogger);
@@ -93,5 +90,52 @@ public void CorrectlyResolvesPaths(string givenPath, string expectedPath)
9390

9491
Assert.Equal(expectedPath, resolvedPath);
9592
}
93+
94+
public static IEnumerable<object[]> PathResolutionInput
95+
{
96+
get
97+
{
98+
#if !CoreCLR
99+
return new [] {
100+
new [] { "file:///C%3A/banana/", @"C:\banana\" },
101+
new [] { "file:///C%3A/banana/ex.ps1", @"C:\banana\ex.ps1" },
102+
new [] { "file:///E%3A/Path/to/awful%23path", @"E:\Path\to\awful#path" },
103+
new [] { "file:///path/with/no/drive", @"C:\path\with\no\drive" },
104+
new [] { "file:///path/wi[th]/squ[are/brackets/", @"C:\path\wi[th]\squ[are\brackets\" },
105+
new [] { "file:///Carrots/A%5Ere/Good/", @"C:\Carrots\A^re\Good\" },
106+
new [] { "file:///Users/barnaby/%E8%84%9A%E6%9C%AC/Reduce-Directory", @"C:\Users\barnaby\脚本\Reduce-Directory" },
107+
new [] { "file:///C%3A/Program%20Files%20%28x86%29/PowerShell/6/pwsh.exe", @"C:\Program Files (x86)\PowerShell\6\pwsh.exe" },
108+
new [] { "file:///home/maxim/test%20folder/%D0%9F%D0%B0%D0%BF%D0%BA%D0%B0/helloworld.ps1", @"C:\home\maxim\test folder\Папка\helloworld.ps1" }
109+
};
110+
#else
111+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
112+
{
113+
return new [] {
114+
new [] { "file:///C%3A/banana/", @"C:\banana\" },
115+
new [] { "file:///C%3A/banana/ex.ps1", @"C:\banana\ex.ps1" },
116+
new [] { "file:///E%3A/Path/to/awful%23path", @"E:\Path\to\awful#path" },
117+
new [] { "file:///path/with/no/drive", @"C:\path\with\no\drive" },
118+
new [] { "file:///path/wi[th]/squ[are/brackets/", @"C:\path\wi[th]\squ[are\brackets\" },
119+
new [] { "file:///Carrots/A%5Ere/Good/", @"C:\Carrots\A^re\Good\" },
120+
new [] { "file:///Users/barnaby/%E8%84%9A%E6%9C%AC/Reduce-Directory", @"C:\Users\barnaby\脚本\Reduce-Directory" },
121+
new [] { "file:///C%3A/Program%20Files%20%28x86%29/PowerShell/6/pwsh.exe", @"C:\Program Files (x86)\PowerShell\6\pwsh.exe" },
122+
new [] { "file:///home/maxim/test%20folder/%D0%9F%D0%B0%D0%BF%D0%BA%D0%B0/helloworld.ps1", @"C:\home\maxim\test folder\Папка\helloworld.ps1" }
123+
};
124+
}
125+
126+
return new [] {
127+
new [] { "file:///banana/", "/banana/" },
128+
new [] { "file:///banana/ex.ps1", "/banana/ex.ps1" },
129+
new [] { "file://Path/to/awful%23path", "/Path/to/awful#path" },
130+
new [] { "file:///path/wi[th]/squ[are/brackets/", "/path/wi[th]/sq[are/brackets/" },
131+
new [] { "file:///path%5Cto/file", "/path\\to/file" },
132+
new [] { "file:///Carrots/A%5Ere/Good/", "/Carrots/A^re/Good/" },
133+
new [] { "file:///Users/barnaby/%E8%84%9A%E6%9C%AC/Reduce-Directory", "/Users/barnaby/脚本/Reduce-Directory" },
134+
new [] { "file:///Program%20Files%20%28x86%29/PowerShell/6/pwsh.exe", "/Program Files (x86)/PowerShell/6/pwsh.exe" },
135+
new [] { "file:///home/maxim/test%20folder/%D0%9F%D0%B0%D0%BF%D0%BA%D0%B0/helloworld.ps1", @"/home/maxim/test folder/Папка/helloworld.ps1" }
136+
};
137+
#endif
138+
}
139+
}
96140
}
97141
}

0 commit comments

Comments
 (0)