Merge pull request #115 from puremourning/debugpy

Switch to debugpy rather than vscode-python
This commit is contained in:
mergify[bot] 2020-02-08 21:23:01 +00:00 • committed by GitHub
commit 79df51e83c
18 changed files with 222 additions and 145 deletions

3
.vintrc.yml Normal file
View file

@ -0,0 +1,3 @@
cmdargs:
color: true
severity: style_problem

View file

@ -38,6 +38,13 @@ def Settings( **kwargs ):
} }
} }
if kwargs[ 'language' ] == 'python':
return {
'sys_path': [
p.join( PATH_TO_THIS_DIR, 'python3' )
]
}
if IgnoreExtraConf: if IgnoreExtraConf:
raise IgnoreExtraConf() raise IgnoreExtraConf()

View file

@ -72,6 +72,29 @@ For more infomration on the test framework, see
[this article](https://vimways.org/2019/a-test-to-attest-to/), authored by the [this article](https://vimways.org/2019/a-test-to-attest-to/), authored by the
Vimspector creator. Vimspector creator.
### Code Style
The code style of the Python code is "YCM" style, because that's how I like it.
[`flake8`][] is used to check for certain errors and code style.
The code style of the Vimscript is largely the same, and it is linted by
[`vint`][].
To run them:
* (optional) Create and activate a virtual env:
`python3 -m venv venv ; source venv/bin/activate`
* Install the development dependencies: `pip install -r dev_requirements.txt`
* Run `flake8`: `flake8 python3/ *.py`
* Run `vint`: `vint autoload/ plugin/ tests/`
They're also run by CI, so please check for lint failures. The canonical
definition of the command to run is the command run in CI, i.e. in
`azure-pipelines.yml`.
# Code of conduct # Code of conduct
Please see [code of conduct](CODE_OF_CONDUCT.md). Please see [code of conduct](CODE_OF_CONDUCT.md).
[vint]: https://github.com/Vimjas/vint
[flake8]: https://flake8.pycqa.org/en/latest/

114
README.md
View file

@ -41,7 +41,7 @@ For a tutorial and usage overview, take a look at the
* [Debug adapter configuration](#debug-adapter-configuration) * [Debug adapter configuration](#debug-adapter-configuration)
* [C, C , Rust, etc.](#c-c-rust-etc) * [C, C , Rust, etc.](#c-c-rust-etc)
* [Python](#python) * [Python](#python)
* [Alternative: Use debugpy directly](#alternative-use-debugpy-directly) * [Legacy: vscode-python](#legacy-vscode-python)
* [TCL](#tcl) * [TCL](#tcl)
* [C♯](#c) * [C♯](#c)
* [Go](#go) * [Go](#go)
@ -55,7 +55,7 @@ For a tutorial and usage overview, take a look at the
* [FAQ](#faq) * [FAQ](#faq)
* [License](#license) * [License](#license)
<!-- Added by: ben, at: Sat 1 Feb 2020 00:08:19 GMT --> <!-- Added by: ben, at: Sat 8 Feb 2020 21:12:02 GMT -->
<!--te--> <!--te-->
@ -188,19 +188,26 @@ There is no workaroud for the lack of balloons; you'll just have to use
## Language dependencies ## Language dependencies
The debug adapters themselves have certain runtime dependencies: The debug adapters themselves have certain runtime dependencies. They are
categorised as follows:
| Language | Status | Switch | Adapter | Dependencies | * `Tested` : Fully supported, Vimspector regression tests cover them
|------------------|--------------|------------------------------|-------------------|------------------------| * `Supported` : Fully supported, frequently used and manually tested
| C, C++, etc. | Supported | `--all` or ` --enable-c` | vscode-cpptools | mono-core | * `Experimental`: Working, but not frequently used and rarely tested
| Python | Supported | `--all` or `--enable-python` | vscode-python | Node 10, Python 2.7 or Python 3 | * `Legacy`: No longer supported, please migrate your config
| TCL | Experimental | `--all` or `--enable-tcl` | tclpro | TCL 8.5 |
| Bourne Shell | Experimental | `--all` or `--enable-bash` | vscode-bash-debug | Bash v?? | | Language | Status | Switch | Adapter | Dependencies |
| C# (dotnet core) | Experimental | `--force-enable-csharp` | netcoredbg | DotNet core | |------------------|--------------|--------------------------------|---------------------|---------------------------------|
| C# (mono) | Experimental | `--force-enable-csharp` | vscode-mono-debug | Mono | | C, C++, etc. | Tested | `--all` or `--enable-c` | vscode-cpptools | mono-core |
| Go | Experimental | `--enable-go` | vscode-go | Go, [Delve][] | | Python | Tested | `--all` or `--enable-python` | debugpy | Python 2.7 or Python 3 |
| Node.js | Experimental | `--force-enable-node` | vscode-node-debug2 | 6 < Node < 12, Npm | | Go | Tested | `--enable-go` | vscode-go | Go, [Delve][] |
| Javascript | Experimental | `--force-enable-chrome` | debugger-for-chrome | Chrome | | TCL | Supported | `--all` or `--enable-tcl` | tclpro | TCL 8.5 |
| Bourne Shell | Supported | `--all` or `--enable-bash` | vscode-bash-debug | Bash v?? |
| Node.js | Supported | `--force-enable-node` | vscode-node-debug2 | 6 < Node < 12, Npm |
| Javascript | Supported | `--force-enable-chrome` | debugger-for-chrome | Chrome |
| C# (dotnet core) | Experimental | `--force-enable-csharp` | netcoredbg | DotNet core |
| C# (mono) | Experimental | `--force-enable-csharp` | vscode-mono-debug | Mono |
| Python.legacy | Legacy | `--force-enable-python.legacy` | vscode-python | Node 10, Python 2.7 or Python 3 |
For other languages, you'll need some other way to install the gadget. For other languages, you'll need some other way to install the gadget.
@ -696,16 +703,43 @@ For `lldb-vscode` replace the name of the adapter with `lldb-vscode`:
## Python ## Python
NOTE: Please see the alternative approach below, as this will become the * Python: [debugpy][]
standard approach in future. * Requires `install_gadget.py --enable-python`, this requires a working compiler
to build a C python extension for performance.
* Python: [vscode-python](https://github.com/Microsoft/vscode-python) **Migrating from `vscode-python`**: change `"adapter": "vscode-python"` to
`"adapter": "debugpy"`.
```json
{
"configurations": {
"<name>: Launch": {
"adapter": "debugpy",
"configuration": {
"name": "<name>: Launch",
"type": "python",
"request": "launch",
"cwd": "<working directory>",
"python": "/path/to/python/interpreter/to/use",
"stopOnEntry": true,
"console": "externalTerminal",
"debugOptions": [],
"program": "<path to main python file>",
}
}
...
}
}
```
### Legacy: vscode-python
* No longer installed by default - please pass `--force-enable-python.legacy` if
you just want to continue using your working setup.
* [vscode-python](https://github.com/Microsoft/vscode-python)
* NOTE: You must be running `node` 10. See [this issue](https://github.com/puremourning/vimspector/issues/105) * NOTE: You must be running `node` 10. See [this issue](https://github.com/puremourning/vimspector/issues/105)
I recommend installing `nvm` and then `nvm use 10` prior to starting your Vim ```json
session.
```
{ {
"configurations": { "configurations": {
"<name>: Launch": { "<name>: Launch": {
@ -726,43 +760,6 @@ session.
} }
``` ```
### Alternative: Use debugpy directly
If you can't get a node 10 environment set up for whatver reason, then you can
avoid that issue by using `debugpy` (formerly `ptvsd`) directly.
Here's how:
1. Instal `debugpy`: `pip install debugpy`
2. Create `/path/to/vimspector/gadgets/<os>/.gadgets.d/debugpy.json`:
```json
{
"adapters": {
"debugpy": {
"command": [
"python",
"-m",
"debugpy.adapter"
],
"name": "debugpy",
"configuration": {
"python": "python"
}
}
}
}
```
Then in theory you should just have to change `"adapter": "vscode-python"` to
`"adapter": "debugpy"`.
See `support/test/python/simple_python/.vimspector.json` as an example.
NOTE: This will likely become the default in future, and vscode-python will be
phased out.
## TCL ## TCL
* TCL (TclProDebug) * TCL (TclProDebug)
@ -1039,3 +1036,4 @@ Copyright © 2018 Ben Jackson
[vimspector-ref]: https://puremourning.github.io/vimspector/configuration.html [vimspector-ref]: https://puremourning.github.io/vimspector/configuration.html
[vimspector-ref-var]: https://puremourning.github.io/vimspector/configuration.html#replacements-and-variables [vimspector-ref-var]: https://puremourning.github.io/vimspector/configuration.html#replacements-and-variables
[vimspector-ref-exception]: https://puremourning.github.io/vimspector/configuration.html#exception-breakpoints [vimspector-ref-exception]: https://puremourning.github.io/vimspector/configuration.html#exception-breakpoints
[debugpy]: https://github.com/microsoft/debugpy

View file

@ -15,7 +15,7 @@ stages:
- bash: pip3 install -r dev_requirements.txt - bash: pip3 install -r dev_requirements.txt
displayName: "Install requirements" displayName: "Install requirements"
- bash: $HOME/.local/bin/flake8 python3/ - bash: '$HOME/.local/bin/flake8 python3/ *.py'
displayName: "Run flake8" displayName: "Run flake8"
- job: 'Vimscript' - job: 'Vimscript'
@ -27,7 +27,7 @@ stages:
- bash: pip3 install -r dev_requirements.txt - bash: pip3 install -r dev_requirements.txt
displayName: "Install requirements" displayName: "Install requirements"
- bash: $HOME/.local/bin/vint autoload/ plugin/ - bash: $HOME/.local/bin/vint autoload/ plugin/ tests/
displayName: "Run vint" displayName: "Run vint"
- job: 'linux' - job: 'linux'
@ -78,7 +78,11 @@ stages:
steps: steps:
- bash: | - bash: |
brew unlink node@6 brew unlink node@6
brew install macvim node@10 tcl-tk llvm brew update
for p in macvim node@10 tcl-tk llvm; do
brew install $p
brew outdated $p || brew install $p
done
brew link --force --overwrite node@10 brew link --force --overwrite node@10
displayName: 'Install vim and node' displayName: 'Install vim and node'
@ -98,11 +102,13 @@ stages:
displayName: 'Print vim version information' displayName: 'Print vim version information'
- bash: | - bash: |
VERSION=66e8ed9af1812ca0bb6cfcc7023a35742e1bd323
BUILD=1092
set -ex set -ex
mkdir -p lldb-mi mkdir -p lldb-mi
pushd lldb-mi pushd lldb-mi
curl -LO https://github.com/puremourning/lldb-mi/releases/download/1041/lldb-mi-db65c20a3d8e09d9ff2f3748c01cf43ec035a4d8.tar.gz curl -LO https://github.com/puremourning/lldb-mi/releases/download/${BUILD}/lldb-mi-${VERSION}.tar.gz
tar zxvf lldb-mi-db65c20a3d8e09d9ff2f3748c01cf43ec035a4d8.tar.gz tar zxvf lldb-mi-${VERSION}.tar.gz
cp usr/local/bin/lldb-mi /usr/local/bin cp usr/local/bin/lldb-mi /usr/local/bin
popd popd
displayName: 'Install lldb-mi' displayName: 'Install lldb-mi'

View file

@ -1,2 +1,4 @@
flake8==3.7.7 flake8==3.7.7
vim-vint==0.3.21 vim-vint==0.3.21
flake8-comprehensions
flake8-ycm>= 0.1.0

View file

@ -55,7 +55,7 @@ GADGETS = {
'url': 'https://github.com/Microsoft/vscode-cpptools/releases/download/' 'url': 'https://github.com/Microsoft/vscode-cpptools/releases/download/'
'${version}/${file_name}', '${version}/${file_name}',
}, },
'do': lambda name, root: InstallCppTools( name, root ), 'do': lambda name, root, gadget: InstallCppTools( name, root, gadget ),
'all': { 'all': {
'version': '0.26.3', 'version': '0.26.3',
}, },
@ -87,7 +87,8 @@ GADGETS = {
}, },
}, },
'vscode-python': { 'vscode-python': {
'language': 'python', 'language': 'python.legacy',
'enabled': False,
'download': { 'download': {
'url': 'https://github.com/Microsoft/vscode-python/releases/download/' 'url': 'https://github.com/Microsoft/vscode-python/releases/download/'
'${version}/${file_name}', '${version}/${file_name}',
@ -108,6 +109,31 @@ GADGETS = {
} }
}, },
}, },
'debugpy': {
'language': 'python',
'download': {
'url': 'https://github.com/microsoft/debugpy/archive/${file_name}'
},
'all': {
'version': '1.0.0b1',
'file_name': 'v1.0.0b1.zip',
'checksum':
'eb26ac276213bcf26aaeadd7c3c284f7a20f43b63331822831a783dea558e60e'
},
'do': lambda name, root, gadget: InstallDebugpy( name, root, gadget ),
'adapters': {
'debugpy': {
"command": [
"python3",
"${gadgetDir}/debugpy/build/lib/debugpy/adapter"
],
"name": "debugpy",
"configuration": {
"python": sys.executable
}
}
},
},
'vscode-java-debug': { 'vscode-java-debug': {
'language': 'java', 'language': 'java',
'enabled': False, 'enabled': False,
@ -163,7 +189,7 @@ GADGETS = {
'url': 'https://github.com/puremourning/TclProDebug', 'url': 'https://github.com/puremourning/TclProDebug',
'ref': 'f5c56b7067661ce84e205765060224076569ae0e', # master 26/10/2019 'ref': 'f5c56b7067661ce84e205765060224076569ae0e', # master 26/10/2019
}, },
'do': lambda name, root: InstallTclProDebug( name, root ) 'do': lambda name, root, gadget: InstallTclProDebug( name, root, gadget )
}, },
'netcoredbg': { 'netcoredbg': {
'language': 'csharp', 'language': 'csharp',
@ -184,9 +210,10 @@ GADGETS = {
'file_name': 'netcoredbg-linux-master.tar.gz', 'file_name': 'netcoredbg-linux-master.tar.gz',
'checksum': '', 'checksum': '',
}, },
'do': lambda name, root: MakeSymlink( gadget_dir, 'do': lambda name, root, gadget: MakeSymlink(
name, gadget_dir,
os.path.join( root, 'netcoredbg' ) ), name,
os.path.join( root, 'netcoredbg' ) ),
'adapters': { 'adapters': {
'netcoredbg': { 'netcoredbg': {
"name": "netcoredbg", "name": "netcoredbg",
@ -242,7 +269,7 @@ GADGETS = {
'checksum': 'checksum':
'502ee5732851fc4f309294fc296a291b1a114008a1fbcb232f3763be2b8d9c1f', '502ee5732851fc4f309294fc296a291b1a114008a1fbcb232f3763be2b8d9c1f',
}, },
'do': lambda name, root: InstallBashDebug( name, root ), 'do': lambda name, root, gadget: InstallBashDebug( name, root, gadget ),
'adapters': { 'adapters': {
"vscode-bash": { "vscode-bash": {
"name": "bashdb", "name": "bashdb",
@ -297,8 +324,9 @@ GADGETS = {
'language': 'php', 'language': 'php',
'enabled': False, 'enabled': False,
'download': { 'download': {
'url': 'https://github.com/felixfbecker/vscode-php-debug/releases/download/' 'url':
'${version}/${file_name}', 'https://github.com/felixfbecker/vscode-php-debug/releases/download/'
'${version}/${file_name}',
}, },
'all': { 'all': {
'version': 'v1.13.0', 'version': 'v1.13.0',
@ -323,7 +351,7 @@ GADGETS = {
'url': 'https://github.com/microsoft/vscode-node-debug2', 'url': 'https://github.com/microsoft/vscode-node-debug2',
'ref': 'v1.39.1', 'ref': 'v1.39.1',
}, },
'do': lambda name, root: InstallNodeDebug( name, root ), 'do': lambda name, root, gadget: InstallNodeDebug( name, root, gadget ),
'adapters': { 'adapters': {
'vscode-node': { 'vscode-node': {
'name': 'node2', 'name': 'node2',
@ -381,7 +409,7 @@ def MakeExecutable( file_path ):
os.chmod( file_path, 0o755 ) os.chmod( file_path, 0o755 )
def InstallCppTools( name, root ): def InstallCppTools( name, root, gadget ):
extension = os.path.join( root, 'extension' ) extension = os.path.join( root, 'extension' )
# It's hilarious, but the execute bits aren't set in the vsix. So they # It's hilarious, but the execute bits aren't set in the vsix. So they
@ -400,12 +428,24 @@ def InstallCppTools( name, root ):
MakeExtensionSymlink( name, root ) MakeExtensionSymlink( name, root )
def InstallBashDebug( name, root ): def InstallBashDebug( name, root, gadget ):
MakeExecutable( os.path.join( root, 'extension', 'bashdb_dir', 'bashdb' ) ) MakeExecutable( os.path.join( root, 'extension', 'bashdb_dir', 'bashdb' ) )
MakeExtensionSymlink( name, root ) MakeExtensionSymlink( name, root )
def InstallTclProDebug( name, root ): def InstallDebugpy( name, root, gadget ):
wd = os.getcwd()
root = os.path.join( root, 'debugpy-{}'.format( gadget[ 'version' ] ) )
os.chdir( root )
try:
subprocess.check_call( [ sys.executable, 'setup.py', 'build' ] )
finally:
os.chdir( wd )
MakeSymlink( gadget_dir, name, root )
def InstallTclProDebug( name, root, gadget ):
configure = [ './configure' ] configure = [ './configure' ]
if OS == 'macos': if OS == 'macos':
@ -440,7 +480,7 @@ def InstallTclProDebug( name, root ):
MakeSymlink( gadget_dir, name, root ) MakeSymlink( gadget_dir, name, root )
def InstallNodeDebug( name, root ): def InstallNodeDebug( name, root, gadget ):
node_version = subprocess.check_output( [ 'node', '--version' ], node_version = subprocess.check_output( [ 'node', '--version' ],
universal_newlines=True ).strip() universal_newlines=True ).strip()
print( "Node.js version: {}".format( node_version ) ) print( "Node.js version: {}".format( node_version ) )
@ -485,7 +525,11 @@ def UrlOpen( *args, **kwargs ):
return urllib2.urlopen( *args, **kwargs ) return urllib2.urlopen( *args, **kwargs )
def DownloadFileTo( url, destination, file_name = None, checksum = None, sslcheck = True): def DownloadFileTo( url,
destination,
file_name = None,
checksum = None,
sslcheck = True ):
if not file_name: if not file_name:
file_name = url.split( '/' )[ -1 ] file_name = url.split( '/' )[ -1 ]
@ -715,7 +759,7 @@ for name, gadget in GADGETS.items():
destination, destination,
file_name = gadget[ 'download' ].get( 'target' ), file_name = gadget[ 'download' ].get( 'target' ),
checksum = v.get( 'checksum' ), checksum = v.get( 'checksum' ),
sslcheck = not verify_cert_off) sslcheck = not verify_cert_off )
root = os.path.join( destination, 'root' ) root = os.path.join( destination, 'root' )
ExtractZipTo( file_path, ExtractZipTo( file_path,
root, root,
@ -729,7 +773,7 @@ for name, gadget in GADGETS.items():
root = destination root = destination
if 'do' in gadget: if 'do' in gadget:
gadget[ 'do' ]( name, root ) gadget[ 'do' ]( name, root, v )
else: else:
MakeExtensionSymlink( name, root ) MakeExtensionSymlink( name, root )

View file

@ -217,6 +217,11 @@ class ProjectBreakpoints( object ):
response_received() response_received()
# NOTE: Must do this _first_ otherwise we might send requests and get
# replies before we finished sending all the requests.
if self._exception_breakpoints is None:
self._SetUpExceptionBreakpoints( self._configured_breakpoints )
# TODO: add the _configured_breakpoints to line_breakpoints # TODO: add the _configured_breakpoints to line_breakpoints
# TODO: the line numbers might have changed since pressing the F9 key! # TODO: the line numbers might have changed since pressing the F9 key!
@ -272,9 +277,6 @@ class ProjectBreakpoints( object ):
failure_handler = lambda *_: response_received() failure_handler = lambda *_: response_received()
) )
if self._exception_breakpoints is None:
self._SetUpExceptionBreakpoints( self._configured_breakpoints )
if self._exception_breakpoints: if self._exception_breakpoints:
awaiting = awaiting + 1 awaiting = awaiting + 1
self._connection.DoRequest( self._connection.DoRequest(

View file

@ -112,7 +112,7 @@ class DebugSession( object ):
else: else:
configuration_name = utils.SelectFromList( configuration_name = utils.SelectFromList(
'Which launch configuration?', 'Which launch configuration?',
sorted( list( configurations.keys() ) ) ) sorted( configurations.keys() ) )
if not configuration_name or configuration_name not in configurations: if not configuration_name or configuration_name not in configurations:
return return
@ -259,13 +259,13 @@ class DebugSession( object ):
def IfConnected( fct ): def IfConnected( fct ):
"""Decorator, call fct if self._connected else echo warning""" """Decorator, call fct if self._connected else echo warning"""
@functools.wraps( fct ) @functools.wraps( fct )
def wrapper(self, *args, **kwargs): def wrapper( self, *args, **kwargs ):
if not self._connection: if not self._connection:
utils.UserMessage( utils.UserMessage(
'Vimspector not connected, start a debug session first', 'Vimspector not connected, start a debug session first',
persist=True, error=True ) persist=True, error=True )
return return
return fct(self, *args, **kwargs) return fct( self, *args, **kwargs )
return wrapper return wrapper
def OnChannelData( self, data ): def OnChannelData( self, data ):

View file

@ -210,4 +210,4 @@ class OutputView( object ):
'*' if tab_buffer.flag else '' ) ) '*' if tab_buffer.flag else '' ) )
def GetCategories( self ): def GetCategories( self ):
return [ category for category in self._buffers.keys() ] return list( self._buffers.keys() )

View file

@ -232,7 +232,7 @@ def Escape( msg ):
return msg.replace( "'", "''" ) return msg.replace( "'", "''" )
def UserMessage( msg, persist=False, error=False): def UserMessage( msg, persist=False, error=False ):
if persist: if persist:
_logger.warning( 'User Msg: ' + msg ) _logger.warning( 'User Msg: ' + msg )
else: else:
@ -242,11 +242,11 @@ def UserMessage( msg, persist=False, error=False):
vim.command( 'redraw' ) vim.command( 'redraw' )
try: try:
if error: if error:
vim.command("echohl WarningMsg") vim.command( "echohl WarningMsg" )
for line in msg.split( '\n' ): for line in msg.split( '\n' ):
vim.command( "{0} '{1}'".format( cmd, Escape( line ) ) ) vim.command( "{0} '{1}'".format( cmd, Escape( line ) ) )
finally: finally:
vim.command('echohl None') if error else None vim.command( 'echohl None' ) if error else None
vim.command( 'redraw' ) vim.command( 'redraw' )
@ -324,7 +324,7 @@ def SetBufferContents( buf, lines, modified=False ):
if not isinstance( lines, list ): if not isinstance( lines, list ):
lines = lines.splitlines() lines = lines.splitlines()
buf[:] = lines buf[ : ] = lines
finally: finally:
buf.options[ 'modified' ] = modified buf.options[ 'modified' ] = modified
@ -347,7 +347,7 @@ def ExpandReferencesInObject( obj, mapping, user_choices ):
return obj return obj
def ExpandReferencesInString( orig_s, mapping, user_choices): def ExpandReferencesInString( orig_s, mapping, user_choices ):
s = os.path.expanduser( orig_s ) s = os.path.expanduser( orig_s )
s = os.path.expandvars( s ) s = os.path.expandvars( s )

View file

@ -1,19 +1,6 @@
{ {
"adapters": {
"debugpy": {
"command": [
"python",
"-m",
"debugpy.adapter"
],
"name": "debugpy",
"configuration": {
"python": "python"
}
}
},
"configurations": { "configurations": {
"run": { "run legacy vscode-python": {
"adapter": "vscode-python", "adapter": "vscode-python",
"configuration": { "configuration": {
"request": "launch", "request": "launch",
@ -45,14 +32,14 @@
} }
} }
}, },
"run - debugpy": { "run": {
"adapter": "debugpy", "adapter": "debugpy",
"configuration": { "configuration": {
"request": "launch", "request": "launch",
"type": "python", "type": "python",
"cwd": "${workspaceRoot}", "cwd": "${workspaceRoot}",
"program": "${file}", "program": "${file}",
"stopOnEntry": true, "stopOnEntry": false,
"console": "integratedTerminal" "console": "integratedTerminal"
}, },
"breakpoints": { "breakpoints": {

View file

@ -275,7 +275,7 @@ function! Test_Insert_Code_Above_Breakpoint()
" CHeck that we break at the right point " CHeck that we break at the right point
call setpos( '.', [ 0, 1, 1 ] ) call setpos( '.', [ 0, 1, 1 ] )
call vimspector#LaunchWithSettings( { "configuration": "run" } ) call vimspector#LaunchWithSettings( { 'configuration': 'run' } )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 26, 1 ) call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 26, 1 )
call vimspector#Reset() call vimspector#Reset()
call vimspector#test#setup#WaitForReset() call vimspector#test#setup#WaitForReset()

View file

@ -28,7 +28,7 @@ function! Test_Python_Simple()
call setpos( '.', [ 0, 1, 1 ] ) call setpos( '.', [ 0, 1, 1 ] )
" Here we go. Start Debugging " Here we go. Start Debugging
call vimspector#LaunchWithSettings( { "configuration": "run" } ) call vimspector#LaunchWithSettings( { 'configuration': 'run' } )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 6, 1 ) call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 6, 1 )
" Step " Step

View file

@ -28,7 +28,7 @@ endif
func RunVimInTerminal(arguments, options) func RunVimInTerminal(arguments, options)
" If Vim doesn't exit a swap file remains, causing other tests to fail. " If Vim doesn't exit a swap file remains, causing other tests to fail.
" Remove it here. " Remove it here.
call delete(".swp") call delete('.swp')
if exists('$COLORFGBG') if exists('$COLORFGBG')
" Clear $COLORFGBG to avoid 'background' being set to "dark", which will " Clear $COLORFGBG to avoid 'background' being set to "dark", which will
@ -61,7 +61,7 @@ func RunVimInTerminal(arguments, options)
\ 'term_rows': rows, \ 'term_rows': rows,
\ 'term_cols': cols, \ 'term_cols': cols,
\ }) \ })
if &termwinsize == '' if &termwinsize ==# ''
" in the GUI we may end up with a different size, try to set it. " in the GUI we may end up with a different size, try to set it.
if term_getsize(buf) != [rows, cols] if term_getsize(buf) != [rows, cols]
call term_setsize(buf, rows, cols) call term_setsize(buf, rows, cols)
@ -80,7 +80,7 @@ func RunVimInTerminal(arguments, options)
call WaitFor({-> len(term_getline(buf, rows)) >= cols - 1 || len(term_getline(buf, rows - statusoff)) >= cols - 1}) call WaitFor({-> len(term_getline(buf, rows)) >= cols - 1 || len(term_getline(buf, rows - statusoff)) >= cols - 1})
catch /timed out after/ catch /timed out after/
let lines = map(range(1, rows), {key, val -> term_getline(buf, val)}) let lines = map(range(1, rows), {key, val -> term_getline(buf, val)})
call assert_report('RunVimInTerminal() failed, screen contents: ' . join(lines, "<NL>")) call assert_report('RunVimInTerminal() failed, screen contents: ' . join(lines, '<NL>'))
endtry endtry
return buf return buf
@ -88,7 +88,7 @@ endfunc
" Stop a Vim running in terminal buffer "buf". " Stop a Vim running in terminal buffer "buf".
func StopVimInTerminal(buf) func StopVimInTerminal(buf)
call assert_equal("running", term_getstatus(a:buf)) call assert_equal('running', term_getstatus(a:buf))
" CTRL-O : works both in Normal mode and Insert mode to start a command line. " CTRL-O : works both in Normal mode and Insert mode to start a command line.
" In Command-line it's inserted, the CTRL-U removes it again. " In Command-line it's inserted, the CTRL-U removes it again.

View file

@ -37,8 +37,8 @@ endfunc
func RunCommand(cmd) func RunCommand(cmd)
let job = 0 let job = 0
if has('job') if has('job')
let job = job_start(a:cmd, {"stoponexit": "hup"}) let job = job_start(a:cmd, {'stoponexit': 'hup'})
call job_setoptions(job, {"stoponexit": "kill"}) call job_setoptions(job, {'stoponexit': 'kill'})
elseif has('win32') elseif has('win32')
exe 'silent !start cmd /c start "test_channel" ' . a:cmd exe 'silent !start cmd /c start "test_channel" ' . a:cmd
else else
@ -53,7 +53,7 @@ func GetPort()
" with 200 it sometimes failed " with 200 it sometimes failed
for i in range(400) for i in range(400)
try try
let l = readfile("Xportnr") let l = readfile('Xportnr')
catch catch
endtry endtry
if len(l) >= 1 if len(l) >= 1
@ -61,7 +61,7 @@ func GetPort()
endif endif
sleep 10m sleep 10m
endfor endfor
call delete("Xportnr") call delete('Xportnr')
if len(l) == 0 if len(l) == 0
" Can't make the connection, give up. " Can't make the connection, give up.
@ -74,14 +74,14 @@ endfunc
" Always kills the server before returning. " Always kills the server before returning.
func RunServer(cmd, testfunc, args) func RunServer(cmd, testfunc, args)
" The Python program writes the port number in Xportnr. " The Python program writes the port number in Xportnr.
call delete("Xportnr") call delete('Xportnr')
if len(a:args) == 1 if len(a:args) == 1
let arg = ' ' . a:args[0] let arg = ' ' . a:args[0]
else else
let arg = '' let arg = ''
endif endif
let pycmd = s:python . " " . a:cmd . arg let pycmd = s:python . ' ' . a:cmd . arg
try try
let g:currentJob = RunCommand(pycmd) let g:currentJob = RunCommand(pycmd)
@ -108,10 +108,10 @@ func s:kill_server(cmd)
unlet g:currentJob unlet g:currentJob
endif endif
elseif has('win32') elseif has('win32')
let cmd = substitute(a:cmd, ".py", '', '') let cmd = substitute(a:cmd, '.py', '', '')
call system('taskkill /IM ' . s:python . ' /T /F /FI "WINDOWTITLE eq ' . cmd . '"') call system('taskkill /IM ' . s:python . ' /T /F /FI "WINDOWTITLE eq ' . cmd . '"')
else else
call system("pkill -f " . a:cmd) call system('pkill -f ' . a:cmd)
endif endif
endfunc endfunc
@ -253,7 +253,7 @@ func GetVimCommand(...)
" "vimcmd" file, including environment options. " "vimcmd" file, including environment options.
" Other Makefiles just write the executable in the first line, so fall back " Other Makefiles just write the executable in the first line, so fall back
" to that if there is no second line or it is empty. " to that if there is no second line or it is empty.
if len(lines) > 1 && lines[1] != '' if len(lines) > 1 && lines[1] !=# ''
let cmd = lines[1] let cmd = lines[1]
else else
let cmd = lines[0] let cmd = lines[0]
@ -267,7 +267,7 @@ func GetVimCommand(...)
let cmd = substitute(cmd, 'VIMRUNTIME=.*VIMRUNTIME;', '', '') let cmd = substitute(cmd, 'VIMRUNTIME=.*VIMRUNTIME;', '', '')
" If using valgrind, make sure every run uses a different log file. " If using valgrind, make sure every run uses a different log file.
if cmd =~ 'valgrind.*--log-file=' if cmd =~# 'valgrind.*--log-file='
let cmd = substitute(cmd, '--log-file=\(^\s*\)', '--log-file=\1.' . g:valgrind_cnt, '') let cmd = substitute(cmd, '--log-file=\(^\s*\)', '--log-file=\1.' . g:valgrind_cnt, '')
let g:valgrind_cnt += 1 let g:valgrind_cnt += 1
endif endif
@ -308,7 +308,7 @@ func RunVimPiped(before, after, arguments, pipecmd)
let args .= ' -S Xafter.vim' let args .= ' -S Xafter.vim'
endif endif
exe "silent !" . a:pipecmd . cmd . args . ' ' . a:arguments exe 'silent !' . a:pipecmd . cmd . args . ' ' . a:arguments
if len(a:before) > 0 if len(a:before) > 0
call delete('Xbefore.vim') call delete('Xbefore.vim')
@ -320,7 +320,7 @@ func RunVimPiped(before, after, arguments, pipecmd)
endfunc endfunc
func CanRunGui() func CanRunGui()
return has('gui') && ($DISPLAY != "" || has('gui_running')) return has('gui') && ($DISPLAY !=# '' || has('gui_running'))
endfunc endfunc
func WorkingClipboard() func WorkingClipboard()
@ -328,7 +328,7 @@ func WorkingClipboard()
return 0 return 0
endif endif
if has('x11') if has('x11')
return $DISPLAY != "" return $DISPLAY !=# ''
endif endif
return 1 return 1
endfunc endfunc

View file

@ -36,16 +36,18 @@
let s:single_test_timeout = 60000 let s:single_test_timeout = 60000
" Restrict the runtimepath to the exact minimum needed for testing " Restrict the runtimepath to the exact minimum needed for testing
set rtp=$PWD/lib,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after set runtimepath=$PWD/lib,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after
if has('packages') if has('packages')
let &packpath = &rtp let &packpath = &runtimepath
endif endif
call ch_logfile( 'debuglog', 'w' ) call ch_logfile( 'debuglog', 'w' )
" For consistency run all tests with 'nocompatible' set. " For consistency run all tests with 'nocompatible' set.
" This also enables use of line continuation. " This also enables use of line continuation.
set nocp " vint: -ProhibitSetNoCompatible
set nocompatible
" vint: +ProhibitSetNoCompatible
" Use utf-8 by default, instead of whatever the system default happens to be. " Use utf-8 by default, instead of whatever the system default happens to be.
" Individual tests can overrule this at the top of the file. " Individual tests can overrule this at the top of the file.
@ -93,7 +95,7 @@ func RunTheTest(test)
" directory after executing the test. " directory after executing the test.
let save_cwd = getcwd() let save_cwd = getcwd()
if exists("*SetUp_" . a:test) if exists('*SetUp_' . a:test)
try try
exe 'call SetUp_' . a:test exe 'call SetUp_' . a:test
catch catch
@ -109,7 +111,7 @@ func RunTheTest(test)
endtry endtry
endif endif
if exists("*SetUp") if exists('*SetUp')
try try
call SetUp() call SetUp()
catch catch
@ -136,9 +138,14 @@ func RunTheTest(test)
let test_filesafe = substitute( a:test, '[)(,:]', '_', 'g' ) let test_filesafe = substitute( a:test, '[)(,:]', '_', 'g' )
let s:testid_filesafe = g:testpath . '_' . test_filesafe let s:testid_filesafe = g:testpath . '_' . test_filesafe
au VimLeavePre * call EarlyExit(s:test) augroup EarlyExit
au!
au VimLeavePre * call EarlyExit(s:test)
augroup END
exe 'call ' . a:test exe 'call ' . a:test
au! VimLeavePre
au! EarlyExit
catch /^\cskipped/ catch /^\cskipped/
call add(s:messages, ' Skipped') call add(s:messages, ' Skipped')
call add(s:skipped, call add(s:skipped,
@ -164,7 +171,7 @@ func RunTheTest(test)
" reset to avoid trouble with anything else. " reset to avoid trouble with anything else.
set noinsertmode set noinsertmode
if exists("*TearDown") if exists('*TearDown')
try try
call TearDown() call TearDown()
catch catch
@ -179,7 +186,7 @@ func RunTheTest(test)
endtry endtry
endif endif
if exists("*TearDown_" . a:test) if exists('*TearDown_' . a:test)
try try
exe 'call TearDown_' . a:test exe 'call TearDown_' . a:test
catch catch
@ -252,10 +259,9 @@ func FinishTesting()
if filereadable( 'test.log' ) if filereadable( 'test.log' )
let l = readfile( 'test.log' ) let l = readfile( 'test.log' )
endif endif
call writefile( l->extend( [ '', 'From ' . g:testpath . ':' ] ) call extend( l, [ '', 'From ' . g:testpath . ':' ] )
\ ->extend( s:errors ), call extend( l, s:errors )
\ 'test.log', call writefile( l, 'test.log', 's' )
\ 's' )
endif endif
if s:done == 0 if s:done == 0
@ -280,10 +286,9 @@ func FinishTesting()
if filereadable( 'messages' ) if filereadable( 'messages' )
let l = readfile( 'messages' ) let l = readfile( 'messages' )
endif endif
call writefile( l->extend( [ '', 'From ' . g:testpath . ':' ] ) call extend( l, [ '', 'From ' . g:testpath . ':' ] )
\ ->extend( s:messages ), call extend( l, s:messages )
\ 'messages', call writefile( l, 'messages', 's' )
\ 's' )
if s:fail > 0 if s:fail > 0
cquit! cquit!

View file

@ -28,7 +28,7 @@ function! Test_Step_With_Different_Tabpage()
call assert_equal( 1, col( '.' ), 'Current column' ) call assert_equal( 1, col( '.' ), 'Current column' )
" Switch to the other tab " Switch to the other tab
normal gt normal! gt
call assert_notequal( vimspector_tabnr, tabpagenr() ) call assert_notequal( vimspector_tabnr, tabpagenr() )