-
Notifications
You must be signed in to change notification settings - Fork 235
Add simple integration test, with an LSP client PowerShell module #944
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
Merged
Merged
Changes from 43 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
c708a1b
Add first parts of ps pses client
e36001a
Make message reading work
9e67dea
Start pipe module
rjmholt b66a9ac
Add simple startup test
rjmholt 6711016
Add shutdown test
rjmholt be4587e
Add pester installation to build step
rjmholt 2158e3b
Response to Codacy bot's feedback
rjmholt 4952bad
Add classes and types to psm1
rjmholt 7ba21c2
Fix build logic, add return types
rjmholt 558abc0
Rename pester test file to be more specific
rjmholt 5c35561
Kill process properly
rjmholt 81631a1
Fix process kill
rjmholt adcb527
Add diagnostic line;
rjmholt b16429d
Attempt to exit
rjmholt 0435cb6
Add some documentation comments
rjmholt 7e9a76d
Ensure pipe is closed during disposal
rjmholt 9b66b61
Fix pipe disposal
rjmholt d949558
Change cancellation method
rjmholt b061b65
Try invoking pester in proc
rjmholt 6b13e22
Add doc comments
rjmholt 29ccd29
Use better exceptions
rjmholt 2896933
Comply with some of Codacy's draconian views
rjmholt 7b3ee70
Publish Pester results in CI
rjmholt 5a2b3d0
Remove .vscode folder
rjmholt 3bb6df4
Merge branch 'master' into integration-tools
rjmholt 228b5eb
Fix typo
rjmholt 516cbb0
Fix NRE in test
rjmholt beeef02
Improve client module building
rjmholt dae7511
Pass through dotnet location
rjmholt f8654d6
Ensure new enough Pester is installed
rjmholt 14b8884
Add -Force flag
rjmholt 4069a40
Update tools/PsesPsClient/PsesPsClient.psd1
TylerLeonhardt a6e2e99
Rework module, address @TylerLeonhardt's feedback
rjmholt e8529dd
Update PowerShellEditorServices.build.ps1
TylerLeonhardt b0d704c
Update tools/PsesPsClient/Client.cs
rjmholt 1b90683
Add server output to integration test
c0bcefb
Try stderr recording
d9b3a0b
Try procinfo
c48b586
Don't use stream when it doesn't exist
e2e3c9b
Try again with error file
a7e599c
Use log parser to find errors
47cdb90
Add test exception for pwsh pipe close error
d5a67c2
Improve error message
dc2506e
Test without skipping crash log exception
135d47d
Try ending server stream first
37ddedf
Improve testing
9f5666f
Add comments about test ordering
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
|
||
$script:ExceptionRegex = [regex]::new('\s*Exception: (.*)$', 'Compiled,Multiline,IgnoreCase') | ||
function ReportLogErrors | ||
{ | ||
param( | ||
[Parameter()][string]$LogPath, | ||
|
||
[Parameter()][ref]<#[int]#>$FromIndex = 0, | ||
|
||
[Parameter()][string[]]$IgnoreException = @() | ||
) | ||
|
||
$logEntries = Parse-PsesLog $LogPath | | ||
Where-Object Index -ge $FromIndex.Value | ||
|
||
# Update the index to the latest in the log | ||
$FromIndex.Value = ($FromIndex.Value,$errorLogs.Index | Measure-Object -Maximum).Maximum | ||
|
||
$errorLogs = $logEntries | | ||
Where-Object LogLevel -eq Error | | ||
Where-Object { | ||
$match = $script:ExceptionRegex.Match($_.Message.Data) | ||
|
||
(-not $match) -or ($match.Groups[1].Value.Trim() -notin $IgnoreException) | ||
} | ||
|
||
if ($errorLogs) | ||
{ | ||
$errorLogs | ForEach-Object { Write-Error "ERROR from PSES log: $($_.Message.Data)" } | ||
} | ||
} | ||
|
||
Describe "Loading and running PowerShellEditorServices" { | ||
BeforeAll { | ||
Import-Module -Force "$PSScriptRoot/../../module/PowerShellEditorServices" | ||
Import-Module -Force "$PSScriptRoot/../../tools/PsesPsClient/out/PsesPsClient" | ||
Import-Module -Force "$PSScriptRoot/../../tools/PsesLogAnalyzer" | ||
rjmholt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
$logIdx = 0 | ||
$psesServer = Start-PsesServer | ||
$client = Connect-PsesServer -PipeName $psesServer.SessionDetails.languageServicePipeName | ||
} | ||
|
||
AfterAll { | ||
try | ||
{ | ||
$client.Dispose() | ||
$psesServer.PsesProcess.Kill() | ||
$psesServer.PsesProcess.Dispose() | ||
} | ||
catch | ||
{ | ||
# Do nothing | ||
} | ||
|
||
# TODO: We shouldn't need to skip this error | ||
rjmholt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ReportLogErrors -LogPath $psesServer.LogPath -FromIndex ([ref]$logIdx) -IgnoreException 'EndOfStreamException' | ||
} | ||
|
||
It "Starts and responds to an initialization request" { | ||
$request = Send-LspInitializeRequest -Client $client | ||
$response = Get-LspResponse -Client $client -Id $request.Id | ||
$response.Id | Should -BeExactly $request.Id | ||
|
||
ReportLogErrors -LogPath $psesServer.LogPath -FromIndex ([ref]$logIdx) | ||
rjmholt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
It "Shuts down the process properly" { | ||
$request = Send-LspShutdownRequest -Client $client | ||
$response = Get-LspResponse -Client $client -Id $request.Id | ||
$response.Id | Should -BeExactly $request.Id | ||
$response.Result | Should -BeNull | ||
# TODO: The server seems to stay up waiting for the debug connection | ||
# $psesServer.PsesProcess.HasExited | Should -BeTrue | ||
|
||
ReportLogErrors -LogPath $psesServer.LogPath -FromIndex ([ref]$logIdx) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just add this to the
#Requires
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of
#requires
in general, but I think here we might want to build without testing in some circumstances