-
Notifications
You must be signed in to change notification settings - Fork 176
/
Copy pathlanguage_python.test.vim
159 lines (127 loc) · 4.62 KB
/
language_python.test.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
function! SetUp()
call vimspector#test#setup#SetUpWithMappings( 'HUMAN' )
endfunction
function! TearDown()
call vimspector#test#setup#TearDown()
endfunction
function! Test_Python_Simple()
let fn='main.py'
lcd ../support/test/python/simple_python
exe 'edit ' . fn
call setpos( '.', [ 0, 6, 1 ] )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 6, 1 )
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 6 )
" Add the breakpoint
call feedkeys( "\<F9>", 'xt' )
call vimspector#test#signs#AssertSignGroupSingletonAtLine( 'VimspectorBP',
\ 6,
\ 'vimspectorBP',
\ 9 )
call setpos( '.', [ 0, 1, 1 ] )
" Here we go. Start Debugging
call vimspector#LaunchWithSettings( { 'configuration': 'run' } )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 6, 1 )
" Step
call feedkeys( "\<F10>", 'xt' )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 7, 1 )
call WaitForAssert( {->
\ vimspector#test#signs#AssertPCIsAtLineInBuffer( fn, 7 )
\ } )
call vimspector#test#setup#Reset()
lcd -
%bwipeout!
endfunction
function! Test_Python_Simple_Adhoc_Config()
let fn='main.py'
lcd ../support/test/python/simple_python
exe 'edit ' . fn
call setpos( '.', [ 0, 6, 1 ] )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 6, 1 )
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 6 )
" Add the breakpoint
call feedkeys( "\<F9>", 'xt' )
call vimspector#test#signs#AssertSignGroupSingletonAtLine( 'VimspectorBP',
\ 6,
\ 'vimspectorBP',
\ 9 )
call setpos( '.', [ 0, 1, 1 ] )
" Here we go. Start Debugging
" call vimspector#LaunchWithSettings( { 'configuration': 'run' } )
call vimspector#LaunchWithConfigurations({
\ 'run': {
\ 'adapter': 'debugpy',
\ 'configuration': {
\ 'request': 'launch',
\ 'type': 'python',
\ 'cwd': '${workspaceRoot}',
\ 'program': '${file}',
\ 'stopOnEntry': v:false,
\ 'console': 'integratedTerminal'
\ },
\ 'breakpoints': {
\ 'exception': {
\ 'raised': 'N',
\ 'uncaught': '',
\ 'userUnhandled': ''
\ }
\ }
\ }
\ })
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 6, 1 )
" Step
call feedkeys( "\<F10>", 'xt' )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 7, 1 )
call WaitForAssert( {->
\ vimspector#test#signs#AssertPCIsAtLineInBuffer( fn, 7 )
\ } )
call vimspector#test#setup#Reset()
lcd -
%bwipeout!
endfunction
function! Test_Python_Remote_Attach()
call SkipNeovim()
lcd ../support/test/python/simple_python
let fn='main.py'
exe 'edit ' . fn
let ready = v:false
function! ReceiveFromLauncher( ch, data ) closure
if a:data ==# '*** Launching ***'
let ready = v:true
endif
endfunction
let jobid = job_start( [ './run_with_debugpy' ], {
\ 'out_mode': 'nl',
\ 'out_cb': funcref( 'ReceiveFromLauncher' ),
\ } )
" Wait up to 60s for the debuggee to be launched (the script faffs with
" virtualenvs etc.)
call WaitFor( {-> ready == v:true }, 60000 )
call setpos( '.', [ 0, 6, 1 ] )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 6, 1 )
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 6 )
" Add the breakpoint
call feedkeys( "\<F9>", 'xt' )
call vimspector#test#signs#AssertSignGroupSingletonAtLine( 'VimspectorBP',
\ 6,
\ 'vimspectorBP',
\ 9 )
call setpos( '.', [ 0, 1, 1 ] )
" Here we go. Start Debugging (note will wait up to 10s for the script to do
" its virtualenv thing)
call vimspector#LaunchWithSettings( {
\ 'configuration': 'attach',
\ 'port': 5678,
\ 'host': 'localhost'
\ } )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 6, 1 )
" Step
call feedkeys( "\<F10>", 'xt' )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 7, 1 )
call WaitForAssert( {->
\ vimspector#test#signs#AssertPCIsAtLineInBuffer( fn, 7 )
\ } )
call vimspector#test#setup#Reset()
call job_stop( jobid )
lcd -
%bwipeout!
endfunction