-
Notifications
You must be signed in to change notification settings - Fork 237
The entire Debug Adapter moved over... #1043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
97e1357
2ce7dd8
52a5308
a6c1a0e
fc25e18
ced08a2
d000616
dea9d82
c0478c5
903f4fc
162f22c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Logging; | ||
using Newtonsoft.Json.Linq; | ||
using OmniSharp.Extensions.LanguageServer.Client; | ||
using OmniSharp.Extensions.LanguageServer.Client.Processes; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Models; | ||
|
||
namespace PowerShellEditorServices.Test.E2E | ||
{ | ||
public class LSPTestsFixture : TestsFixture | ||
{ | ||
public override bool IsDebugAdapterTests => false; | ||
|
||
public LanguageClient LanguageClient { get; private set; } | ||
public List<Diagnostic> Diagnostics { get; set; } | ||
|
||
public async override Task CustomInitializeAsync( | ||
ILoggerFactory factory, | ||
StdioServerProcess process) | ||
{ | ||
LanguageClient = new LanguageClient(factory, process); | ||
|
||
DirectoryInfo testdir = | ||
Directory.CreateDirectory(Path.Combine(s_binDir, Path.GetRandomFileName())); | ||
|
||
await LanguageClient.Initialize(testdir.FullName); | ||
|
||
// Make sure Script Analysis is enabled because we'll need it in the tests. | ||
LanguageClient.Workspace.DidChangeConfiguration(JObject.Parse(@" | ||
{ | ||
""PowerShell"": { | ||
""ScriptAnalysis"": { | ||
""Enable"": true | ||
} | ||
} | ||
} | ||
")); | ||
|
||
Diagnostics = new List<Diagnostic>(); | ||
LanguageClient.TextDocument.OnPublishDiagnostics((uri, diagnostics) => | ||
{ | ||
Diagnostics.AddRange(diagnostics); | ||
}); | ||
} | ||
|
||
public override async Task DisposeAsync() | ||
{ | ||
await LanguageClient.Shutdown(); | ||
await _psesProcess.Stop(); | ||
LanguageClient?.Dispose(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,9 @@ | |
|
||
namespace PowerShellEditorServices.Test.E2E | ||
{ | ||
public class TestsFixture : IAsyncLifetime | ||
public abstract class TestsFixture : IAsyncLifetime | ||
{ | ||
private readonly static string s_binDir = | ||
protected readonly static string s_binDir = | ||
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); | ||
|
||
private readonly static string s_bundledModulePath = new FileInfo(Path.Combine( | ||
|
@@ -38,11 +38,11 @@ public class TestsFixture : IAsyncLifetime | |
const string s_hostVersion = "1.0.0"; | ||
readonly static string[] s_additionalModules = { "PowerShellEditorServices.VSCode" }; | ||
|
||
private StdioServerProcess _psesProcess; | ||
protected StdioServerProcess _psesProcess; | ||
|
||
public static string PwshExe { get; } = Environment.GetEnvironmentVariable("PWSH_EXE_NAME") ?? "pwsh"; | ||
public LanguageClient LanguageClient { get; private set; } | ||
public List<Diagnostic> Diagnostics { get; set; } | ||
|
||
public virtual bool IsDebugAdapterTests { get; set; } | ||
|
||
public async Task InitializeAsync() | ||
{ | ||
|
@@ -56,7 +56,8 @@ public async Task InitializeAsync() | |
processStartInfo.ArgumentList.Add("-NoProfile"); | ||
processStartInfo.ArgumentList.Add("-EncodedCommand"); | ||
|
||
string[] args = { | ||
List<string> args = new List<string> | ||
{ | ||
Path.Combine(s_bundledModulePath, "PowerShellEditorServices", "Start-EditorServices.ps1"), | ||
"-LogPath", s_logPath, | ||
"-LogLevel", s_logLevel, | ||
|
@@ -70,6 +71,11 @@ public async Task InitializeAsync() | |
"-Stdio" | ||
}; | ||
|
||
if (IsDebugAdapterTests) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is intended for a particular subclass, ideally the superclass shouldn't know about it at all. But in test classes, not such a big deal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah this isn't final. There's more work I need to do wrt testing. |
||
{ | ||
args.Add("-DebugServiceOnly"); | ||
} | ||
|
||
string base64Str = Convert.ToBase64String( | ||
System.Text.Encoding.Unicode.GetBytes(string.Join(' ', args))); | ||
|
||
|
@@ -78,36 +84,16 @@ public async Task InitializeAsync() | |
_psesProcess = new StdioServerProcess(factory, processStartInfo); | ||
await _psesProcess.Start(); | ||
|
||
LanguageClient = new LanguageClient(factory, _psesProcess); | ||
|
||
DirectoryInfo testdir = | ||
Directory.CreateDirectory(Path.Combine(s_binDir, Path.GetRandomFileName())); | ||
|
||
await LanguageClient.Initialize(testdir.FullName); | ||
|
||
// Make sure Script Analysis is enabled because we'll need it in the tests. | ||
LanguageClient.Workspace.DidChangeConfiguration(JObject.Parse(@" | ||
{ | ||
""PowerShell"": { | ||
""ScriptAnalysis"": { | ||
""Enable"": true | ||
await CustomInitializeAsync(factory, _psesProcess); | ||
} | ||
} | ||
} | ||
")); | ||
|
||
Diagnostics = new List<Diagnostic>(); | ||
LanguageClient.TextDocument.OnPublishDiagnostics((uri, diagnostics) => | ||
{ | ||
Diagnostics.AddRange(diagnostics); | ||
}); | ||
} | ||
|
||
public async Task DisposeAsync() | ||
public virtual async Task DisposeAsync() | ||
{ | ||
await LanguageClient.Shutdown(); | ||
await _psesProcess.Stop(); | ||
LanguageClient?.Dispose(); | ||
} | ||
|
||
public abstract Task CustomInitializeAsync( | ||
ILoggerFactory factory, | ||
StdioServerProcess process); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.