File tree 2 files changed +14
-7
lines changed
src/PowerShellEditorServices/Services/PowerShellContext/Session
test/PowerShellEditorServices.Test/Session
2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,18 @@ internal class PSReadLinePromptContext : IPromptContext
22
22
"..",
23
23
"..",
24
24
"..",
25
- #if TEST
26
- // When using xUnit (dotnet test) the assemblies are deployed to the
27
- // test project folder, invalidating our relative path assumption.
25
+ "PSReadLine");
26
+
27
+ // When using xUnit (dotnet test) the assemblies are deployed to the
28
+ // test project folder, invalidating our relative path assumption.
29
+ private static readonly string _psReadLineTestModulePath = Path.Combine(
30
+ Path.GetDirectoryName(typeof(PSReadLinePromptContext).Assembly.Location),
31
+ "..",
32
+ "..",
33
+ "..",
28
34
"..",
29
35
"..",
30
36
"module",
31
- #endif
32
37
"PSReadLine");
33
38
34
39
private static readonly Lazy<CmdletInfo> s_lazyInvokeReadLineForEditorServicesCmdletInfo = new Lazy<CmdletInfo>(() =>
@@ -79,15 +84,16 @@ internal PSReadLinePromptContext(
79
84
internal static bool TryGetPSReadLineProxy(
80
85
ILogger logger,
81
86
Runspace runspace,
82
- out PSReadLineProxy readLineProxy)
87
+ out PSReadLineProxy readLineProxy,
88
+ bool testing = false)
83
89
{
84
90
readLineProxy = null;
85
91
logger.LogTrace("Attempting to load PSReadLine");
86
92
using (var pwsh = PowerShell.Create())
87
93
{
88
94
pwsh.Runspace = runspace;
89
95
pwsh.AddCommand("Microsoft.PowerShell.Core\\Import-Module")
90
- .AddParameter("Name", _psReadLineModulePath)
96
+ .AddParameter("Name", testing ? _psReadLineTestModulePath : _psReadLineModulePath)
91
97
.Invoke();
92
98
93
99
var psReadLineType = Type.GetType("Microsoft.PowerShell.PSConsoleReadLine, Microsoft.PowerShell.PSReadLine2");
Original file line number Diff line number Diff line change @@ -155,7 +155,8 @@ public void CanGetPSReadLineProxy()
155
155
Assert.True(PSReadLinePromptContext.TryGetPSReadLineProxy(
156
156
NullLogger.Instance,
157
157
PowerShellContextFactory.initialRunspace,
158
- out PSReadLineProxy proxy));
158
+ out PSReadLineProxy proxy,
159
+ true));
159
160
}
160
161
161
162
#region Helper Methods
You can’t perform that action at this time.
0 commit comments