Merge pull request #312 from puremourning/watch-errors

Print failure when watch expression errors
This commit is contained in:
Ben Jackson 2020-12-02 18:19:39 +00:00 committed by GitHub
commit 573121ee08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 76 additions and 8 deletions

View file

@ -38,6 +38,7 @@ jobs:
options: --cap-add=SYS_PTRACE --security-opt seccomp=unconfined
steps:
- uses: actions/checkout@v2
- run: |
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
go get -u github.com/go-delve/delve/cmd/dlv
@ -79,17 +80,26 @@ jobs:
name: 'package-linux'
path: 'package/linux-${{ github.run_id }}.tar.gz'
# - name: Start SSH session if failed
# uses: luchihoratiu/debug-via-ssh@main
# if: failure()
# with:
# NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
# SSH_PASS: ${{ secrets.SSH_PASS }}
MacOS:
runs-on: 'macos-10.15'
steps:
- uses: actions/checkout@v2
- run: |
brew update-reset
brew doctor || true
for p in macvim tcl-tk llvm lua luajit love; do
brew install $p
brew outdated $p || brew upgrade $p
for p in python@3.8 tcl-tk llvm lua luajit love; do
brew install $p || brew outdated $p || brew upgrade $p
done
brew install --cask macvim
brew link --overwrite python@3.8
name: 'Install vim and deps'
- run: go get -u github.com/go-delve/delve/cmd/dlv
@ -128,6 +138,13 @@ jobs:
name: 'package-macos'
path: 'package/macos-${{ github.run_id }}.tar.gz'
# - name: Start SSH session if failed
# uses: luchihoratiu/debug-via-ssh@main
# if: failure()
# with:
# NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
# SSH_PASS: ${{ secrets.SSH_PASS }}
PublishRelease:
runs-on: 'ubuntu-16.04'
needs:

View file

@ -84,6 +84,12 @@ class WatchResult( Expandable ):
self.result = result
class WatchFailure( WatchResult ):
def __init__( self, reason ):
super().__init__( { 'result': reason } )
self.changed = True
class Variable( Expandable ):
"""Holds one level of an expanded value tree. Also itself expandable."""
def __init__( self, variable: dict ):
@ -296,11 +302,14 @@ class VariablesView( object ):
def EvaluateWatches( self ):
for watch in self._watches:
self._connection.DoRequest( partial( self._UpdateWatchExpression,
watch ), {
'command': 'evaluate',
'arguments': watch.expression,
} )
self._connection.DoRequest(
partial( self._UpdateWatchExpression, watch ),
{
'command': 'evaluate',
'arguments': watch.expression,
},
failure_handler = lambda reason, msg, watch=watch:
self._WatchExpressionFailed( reason, watch ) )
def _UpdateWatchExpression( self, watch: Watch, message: dict ):
if watch.result is not None:
@ -321,6 +330,14 @@ class VariablesView( object ):
self._DrawWatches()
def _WatchExpressionFailed( self, reason: str, watch: Watch ):
if watch.result is not None:
# We already have a result for this watch. Wut ?
return
watch.result = WatchFailure( reason )
self._DrawWatches()
def ExpandVariable( self ):
if vim.current.buffer == self._vars.buf:
view = self._vars

View file

@ -557,3 +557,37 @@ function Test_EvaluatePromptConsole()
call vimspector#test#setup#Reset()
%bwipe!
endfunction
function! Test_EvaluateFailure()
call s:StartDebugging()
" Add a wtch
call vimspector#AddWatch( 'test' )
call WaitForAssert( {->
\ AssertMatchist(
\ [
\ 'Watches: ----',
\ 'Expression: test',
\ " *- Result: NameError: name 'test' is not defined",
\ ],
\ getbufline( winbufnr( g:vimspector_session_windows.watches ),
\ 1,
\ '$' )
\ )
\ } )
VimspectorEval test
call assert_equal( bufnr( 'vimspector.Console' ),
\ winbufnr( g:vimspector_session_windows.output ) )
call WaitForAssert( {->
\ assert_equal(
\ [
\ "NameError: name 'test' is not defined"
\ ],
\ getbufline( bufnr( 'vimspector.Console' ), '$', '$' )
\ )
\ } )
call vimspector#test#setup#Reset()
%bwipe!
endfunction