@@ -67,12 +67,8 @@ let testCounter = 0;
67
67
return new DebugClientEx ( testAdapterFilePath , debuggerType , coverageDirectory , { cwd : EXTENSION_ROOT_DIR } ) ;
68
68
}
69
69
}
70
- function buildLauncArgs ( pythonFile : string , stopOnEntry : boolean = false ) : LaunchRequestArguments {
71
- const env = { } ;
72
- if ( debuggerType === 'pythonExperimental' ) {
73
- // tslint:disable-next-line:no-string-literal
74
- env [ 'PYTHONPATH' ] = PTVSD_PATH ;
75
- }
70
+ function buildLaunchArgs ( pythonFile : string , stopOnEntry : boolean = false ) : LaunchRequestArguments {
71
+ const env = debuggerType === 'pythonExperimental' ? { PYTHONPATH : PTVSD_PATH } : { } ;
76
72
// tslint:disable-next-line:no-unnecessary-local-variable
77
73
const options : LaunchRequestArguments = {
78
74
program : path . join ( debugFilesPath , pythonFile ) ,
@@ -93,7 +89,7 @@ let testCounter = 0;
93
89
test ( 'Should run program to the end' , async ( ) => {
94
90
await Promise . all ( [
95
91
debugClient . configurationSequence ( ) ,
96
- debugClient . launch ( buildLauncArgs ( 'simplePrint.py' , false ) ) ,
92
+ debugClient . launch ( buildLaunchArgs ( 'simplePrint.py' , false ) ) ,
97
93
debugClient . waitForEvent ( 'initialized' ) ,
98
94
debugClient . waitForEvent ( 'terminated' )
99
95
] ) ;
@@ -104,7 +100,7 @@ let testCounter = 0;
104
100
}
105
101
await Promise . all ( [
106
102
debugClient . configurationSequence ( ) ,
107
- debugClient . launch ( buildLauncArgs ( 'simplePrint.py' , true ) ) ,
103
+ debugClient . launch ( buildLaunchArgs ( 'simplePrint.py' , true ) ) ,
108
104
debugClient . waitForEvent ( 'initialized' ) ,
109
105
debugClient . waitForEvent ( 'stopped' )
110
106
] ) ;
@@ -113,7 +109,7 @@ let testCounter = 0;
113
109
const output = debuggerType === 'python' ? 'stdout' : 'stderr' ;
114
110
await Promise . all ( [
115
111
debugClient . configurationSequence ( ) ,
116
- debugClient . launch ( buildLauncArgs ( 'stdErrOutput.py' , false ) ) ,
112
+ debugClient . launch ( buildLaunchArgs ( 'stdErrOutput.py' , false ) ) ,
117
113
debugClient . waitForEvent ( 'initialized' ) ,
118
114
//TODO: ptvsd does not differentiate.
119
115
debugClient . assertOutput ( output , 'error output' ) ,
@@ -123,7 +119,7 @@ let testCounter = 0;
123
119
test ( 'Test stdout output' , async ( ) => {
124
120
await Promise . all ( [
125
121
debugClient . configurationSequence ( ) ,
126
- debugClient . launch ( buildLauncArgs ( 'stdOutOutput.py' , false ) ) ,
122
+ debugClient . launch ( buildLaunchArgs ( 'stdOutOutput.py' , false ) ) ,
127
123
debugClient . waitForEvent ( 'initialized' ) ,
128
124
debugClient . assertOutput ( 'stdout' , 'normal output' ) ,
129
125
debugClient . waitForEvent ( 'terminated' )
@@ -137,7 +133,7 @@ let testCounter = 0;
137
133
138
134
await Promise . all ( [
139
135
debugClient . configurationSequence ( ) ,
140
- debugClient . launch ( buildLauncArgs ( 'simplePrint.py' , true ) ) ,
136
+ debugClient . launch ( buildLaunchArgs ( 'simplePrint.py' , true ) ) ,
141
137
debugClient . waitForEvent ( 'initialized' ) ,
142
138
debugClient . waitForEvent ( 'stopped' )
143
139
] ) ;
@@ -156,7 +152,7 @@ let testCounter = 0;
156
152
157
153
await Promise . all ( [
158
154
debugClient . configurationSequence ( ) ,
159
- debugClient . launch ( buildLauncArgs ( 'simplePrint.py' , true ) ) ,
155
+ debugClient . launch ( buildLaunchArgs ( 'simplePrint.py' , true ) ) ,
160
156
debugClient . waitForEvent ( 'initialized' ) ,
161
157
debugClient . waitForEvent ( 'stopped' )
162
158
] ) ;
@@ -169,15 +165,15 @@ let testCounter = 0;
169
165
] ) ;
170
166
} ) ;
171
167
test ( 'Should break at print statement (line 3)' , async ( ) => {
172
- const launchArgs = buildLauncArgs ( 'sample2.py' , false ) ;
168
+ const launchArgs = buildLaunchArgs ( 'sample2.py' , false ) ;
173
169
const breakpointLocation = { path : path . join ( debugFilesPath , 'sample2.py' ) , column : 1 , line : 5 } ;
174
170
await debugClient . hitBreakpoint ( launchArgs , breakpointLocation ) ;
175
171
} ) ;
176
172
test ( 'Should kill python process when ending debug session' , async function ( ) {
177
173
if ( debuggerType === 'python' ) {
178
174
return this . skip ( ) ;
179
175
}
180
- const launchArgs = buildLauncArgs ( 'sample2.py' , false ) ;
176
+ const launchArgs = buildLaunchArgs ( 'sample2.py' , false ) ;
181
177
const breakpointLocation = { path : path . join ( debugFilesPath , 'sample2.py' ) , column : 1 , line : 5 } ;
182
178
const processPromise = debugClient . waitForEvent ( 'process' ) as Promise < DebugProtocol . ProcessEvent > ;
183
179
await debugClient . hitBreakpoint ( launchArgs , breakpointLocation ) ;
@@ -196,7 +192,7 @@ let testCounter = 0;
196
192
197
193
await Promise . all ( [
198
194
debugClient . configurationSequence ( ) ,
199
- debugClient . launch ( buildLauncArgs ( 'forever.py' , false ) ) ,
195
+ debugClient . launch ( buildLaunchArgs ( 'forever.py' , false ) ) ,
200
196
debugClient . waitForEvent ( 'initialized' )
201
197
] ) ;
202
198
@@ -226,7 +222,7 @@ let testCounter = 0;
226
222
const threadIdPromise = debugClient . waitForEvent ( 'thread' ) ;
227
223
await Promise . all ( [
228
224
debugClient . configurationSequence ( ) ,
229
- debugClient . launch ( buildLauncArgs ( 'sample2.py' , false ) ) ,
225
+ debugClient . launch ( buildLaunchArgs ( 'sample2.py' , false ) ) ,
230
226
debugClient . waitForEvent ( 'initialized' )
231
227
] ) ;
232
228
@@ -263,7 +259,7 @@ let testCounter = 0;
263
259
test ( 'Test editing variables' , async ( ) => {
264
260
await Promise . all ( [
265
261
debugClient . configurationSequence ( ) ,
266
- debugClient . launch ( buildLauncArgs ( 'sample2.py' , false ) ) ,
262
+ debugClient . launch ( buildLaunchArgs ( 'sample2.py' , false ) ) ,
267
263
debugClient . waitForEvent ( 'initialized' )
268
264
] ) ;
269
265
@@ -297,7 +293,7 @@ let testCounter = 0;
297
293
298
294
await Promise . all ( [
299
295
debugClient . configurationSequence ( ) ,
300
- debugClient . launch ( buildLauncArgs ( 'sample2.py' , false ) ) ,
296
+ debugClient . launch ( buildLaunchArgs ( 'sample2.py' , false ) ) ,
301
297
debugClient . waitForEvent ( 'initialized' )
302
298
] ) ;
303
299
@@ -323,7 +319,7 @@ let testCounter = 0;
323
319
324
320
await Promise . all ( [
325
321
debugClient . configurationSequence ( ) ,
326
- debugClient . launch ( buildLauncArgs ( 'sample2.py' , false ) ) ,
322
+ debugClient . launch ( buildLaunchArgs ( 'sample2.py' , false ) ) ,
327
323
debugClient . waitForEvent ( 'initialized' )
328
324
] ) ;
329
325
@@ -361,7 +357,7 @@ let testCounter = 0;
361
357
362
358
await Promise . all ( [
363
359
debugClient . configurationSequence ( ) ,
364
- debugClient . launch ( buildLauncArgs ( 'sample2.py' , false ) ) ,
360
+ debugClient . launch ( buildLaunchArgs ( 'sample2.py' , false ) ) ,
365
361
debugClient . waitForEvent ( 'initialized' )
366
362
] ) ;
367
363
@@ -412,7 +408,7 @@ let testCounter = 0;
412
408
413
409
await Promise . all ( [
414
410
debugClient . configurationSequence ( ) ,
415
- debugClient . launch ( buildLauncArgs ( 'forever.py' , false ) ) ,
411
+ debugClient . launch ( buildLaunchArgs ( 'forever.py' , false ) ) ,
416
412
debugClient . waitForEvent ( 'initialized' ) ,
417
413
debugClient . waitForEvent ( 'process' )
418
414
] ) ;
@@ -433,7 +429,7 @@ let testCounter = 0;
433
429
434
430
await Promise . all ( [
435
431
debugClient . configurationSequence ( ) ,
436
- debugClient . launch ( buildLauncArgs ( 'sample3WithEx.py' , false ) ) ,
432
+ debugClient . launch ( buildLaunchArgs ( 'sample3WithEx.py' , false ) ) ,
437
433
debugClient . waitForEvent ( 'initialized' )
438
434
] ) ;
439
435
@@ -484,7 +480,7 @@ let testCounter = 0;
484
480
}
485
481
await Promise . all ( [
486
482
debugClient . configurationSequence ( ) ,
487
- debugClient . launch ( buildLauncArgs ( 'multiThread.py' , false ) ) ,
483
+ debugClient . launch ( buildLaunchArgs ( 'multiThread.py' , false ) ) ,
488
484
debugClient . waitForEvent ( 'initialized' )
489
485
] ) ;
490
486
@@ -508,7 +504,7 @@ let testCounter = 0;
508
504
test ( 'Test multi-threaded debugging' , async function ( ) {
509
505
this . timeout ( 30000 ) ;
510
506
await Promise . all ( [
511
- debugClient . launch ( buildLauncArgs ( 'multiThread.py' , false ) ) ,
507
+ debugClient . launch ( buildLaunchArgs ( 'multiThread.py' , false ) ) ,
512
508
debugClient . waitForEvent ( 'initialized' )
513
509
] ) ;
514
510
@@ -551,7 +547,7 @@ let testCounter = 0;
551
547
test ( 'Test stack frames' , async ( ) => {
552
548
await Promise . all ( [
553
549
debugClient . configurationSequence ( ) ,
554
- debugClient . launch ( buildLauncArgs ( 'stackFrame.py' , false ) ) ,
550
+ debugClient . launch ( buildLaunchArgs ( 'stackFrame.py' , false ) ) ,
555
551
debugClient . waitForEvent ( 'initialized' )
556
552
] ) ;
557
553
const pythonFile = path . join ( debugFilesPath , 'stackFrame.py' ) ;
@@ -580,15 +576,14 @@ let testCounter = 0;
580
576
if ( debuggerType !== 'pythonExperimental' ) {
581
577
return this . skip ( ) ;
582
578
}
583
-
584
579
const breakpointLocation = { path : path . join ( debugFilesPath , 'sample2WithoutSleep.py' ) , column : 1 , line : 5 } ;
585
580
const breakpointArgs = {
586
581
lines : [ breakpointLocation . line ] ,
587
582
breakpoints : [ { line : breakpointLocation . line , column : breakpointLocation . column } ] ,
588
583
source : { path : breakpointLocation . path }
589
584
} ;
590
585
await Promise . all ( [
591
- debugClient . launch ( buildLauncArgs ( 'sample2WithoutSleep.py' , false ) ) ,
586
+ debugClient . launch ( buildLaunchArgs ( 'sample2WithoutSleep.py' , false ) ) ,
592
587
debugClient . waitForEvent ( 'initialized' )
593
588
. then ( ( ) => debugClient . setBreakpointsRequest ( breakpointArgs ) )
594
589
. then ( ( ) => debugClient . configurationDoneRequest ( ) )
@@ -604,5 +599,18 @@ let testCounter = 0;
604
599
expect ( evaluateResponse . body . result ) . to . equal ( '5' ) ;
605
600
await continueDebugging ( debugClient ) ;
606
601
} ) ;
602
+ test ( 'Test Passing custom args to python file' , async function ( ) {
603
+ if ( debuggerType !== 'pythonExperimental' ) {
604
+ return this . skip ( ) ;
605
+ }
606
+ const options = buildLaunchArgs ( 'printSysArgv.py' , false ) ;
607
+ options . args = [ '1' , '2' , '3' ] ;
608
+ await Promise . all ( [
609
+ debugClient . configurationSequence ( ) ,
610
+ debugClient . launch ( options ) ,
611
+ debugClient . assertOutput ( 'stdout' , options . args . join ( ',' ) ) ,
612
+ debugClient . waitForEvent ( 'terminated' )
613
+ ] ) ;
614
+ } ) ;
607
615
} ) ;
608
616
} ) ;
0 commit comments