@@ -66,12 +66,8 @@ let testCounter = 0;
66
66
return new DebugClientEx ( testAdapterFilePath , debuggerType , coverageDirectory , { cwd : EXTENSION_ROOT_DIR } ) ;
67
67
}
68
68
}
69
- function buildLauncArgs ( pythonFile : string , stopOnEntry : boolean = false ) : LaunchRequestArguments {
70
- const env = { } ;
71
- if ( debuggerType === 'pythonExperimental' ) {
72
- // tslint:disable-next-line:no-string-literal
73
- env [ 'PYTHONPATH' ] = PTVSD_PATH ;
74
- }
69
+ function buildLaunchArgs ( pythonFile : string , stopOnEntry : boolean = false ) : LaunchRequestArguments {
70
+ const env = debuggerType === 'pythonExperimental' ? { PYTHONPATH : PTVSD_PATH } : { } ;
75
71
// tslint:disable-next-line:no-unnecessary-local-variable
76
72
const options : LaunchRequestArguments = {
77
73
program : path . join ( debugFilesPath , pythonFile ) ,
@@ -92,7 +88,7 @@ let testCounter = 0;
92
88
test ( 'Should run program to the end' , async ( ) => {
93
89
await Promise . all ( [
94
90
debugClient . configurationSequence ( ) ,
95
- debugClient . launch ( buildLauncArgs ( 'simplePrint.py' , false ) ) ,
91
+ debugClient . launch ( buildLaunchArgs ( 'simplePrint.py' , false ) ) ,
96
92
debugClient . waitForEvent ( 'initialized' ) ,
97
93
debugClient . waitForEvent ( 'terminated' )
98
94
] ) ;
@@ -103,7 +99,7 @@ let testCounter = 0;
103
99
}
104
100
await Promise . all ( [
105
101
debugClient . configurationSequence ( ) ,
106
- debugClient . launch ( buildLauncArgs ( 'simplePrint.py' , true ) ) ,
102
+ debugClient . launch ( buildLaunchArgs ( 'simplePrint.py' , true ) ) ,
107
103
debugClient . waitForEvent ( 'initialized' ) ,
108
104
debugClient . waitForEvent ( 'stopped' )
109
105
] ) ;
@@ -112,7 +108,7 @@ let testCounter = 0;
112
108
const output = debuggerType === 'python' ? 'stdout' : 'stderr' ;
113
109
await Promise . all ( [
114
110
debugClient . configurationSequence ( ) ,
115
- debugClient . launch ( buildLauncArgs ( 'stdErrOutput.py' , false ) ) ,
111
+ debugClient . launch ( buildLaunchArgs ( 'stdErrOutput.py' , false ) ) ,
116
112
debugClient . waitForEvent ( 'initialized' ) ,
117
113
//TODO: ptvsd does not differentiate.
118
114
debugClient . assertOutput ( output , 'error output' ) ,
@@ -122,7 +118,7 @@ let testCounter = 0;
122
118
test ( 'Test stdout output' , async ( ) => {
123
119
await Promise . all ( [
124
120
debugClient . configurationSequence ( ) ,
125
- debugClient . launch ( buildLauncArgs ( 'stdOutOutput.py' , false ) ) ,
121
+ debugClient . launch ( buildLaunchArgs ( 'stdOutOutput.py' , false ) ) ,
126
122
debugClient . waitForEvent ( 'initialized' ) ,
127
123
debugClient . assertOutput ( 'stdout' , 'normal output' ) ,
128
124
debugClient . waitForEvent ( 'terminated' )
@@ -136,7 +132,7 @@ let testCounter = 0;
136
132
137
133
await Promise . all ( [
138
134
debugClient . configurationSequence ( ) ,
139
- debugClient . launch ( buildLauncArgs ( 'simplePrint.py' , true ) ) ,
135
+ debugClient . launch ( buildLaunchArgs ( 'simplePrint.py' , true ) ) ,
140
136
debugClient . waitForEvent ( 'initialized' ) ,
141
137
debugClient . waitForEvent ( 'stopped' )
142
138
] ) ;
@@ -155,7 +151,7 @@ let testCounter = 0;
155
151
156
152
await Promise . all ( [
157
153
debugClient . configurationSequence ( ) ,
158
- debugClient . launch ( buildLauncArgs ( 'simplePrint.py' , true ) ) ,
154
+ debugClient . launch ( buildLaunchArgs ( 'simplePrint.py' , true ) ) ,
159
155
debugClient . waitForEvent ( 'initialized' ) ,
160
156
debugClient . waitForEvent ( 'stopped' )
161
157
] ) ;
@@ -168,15 +164,15 @@ let testCounter = 0;
168
164
] ) ;
169
165
} ) ;
170
166
test ( 'Should break at print statement (line 3)' , async ( ) => {
171
- const launchArgs = buildLauncArgs ( 'sample2.py' , false ) ;
167
+ const launchArgs = buildLaunchArgs ( 'sample2.py' , false ) ;
172
168
const breakpointLocation = { path : path . join ( debugFilesPath , 'sample2.py' ) , column : 1 , line : 5 } ;
173
169
await debugClient . hitBreakpoint ( launchArgs , breakpointLocation ) ;
174
170
} ) ;
175
171
test ( 'Should kill python process when ending debug session' , async function ( ) {
176
172
if ( debuggerType === 'python' ) {
177
173
return this . skip ( ) ;
178
174
}
179
- const launchArgs = buildLauncArgs ( 'sample2.py' , false ) ;
175
+ const launchArgs = buildLaunchArgs ( 'sample2.py' , false ) ;
180
176
const breakpointLocation = { path : path . join ( debugFilesPath , 'sample2.py' ) , column : 1 , line : 5 } ;
181
177
const processPromise = debugClient . waitForEvent ( 'process' ) as Promise < DebugProtocol . ProcessEvent > ;
182
178
await debugClient . hitBreakpoint ( launchArgs , breakpointLocation ) ;
@@ -195,7 +191,7 @@ let testCounter = 0;
195
191
196
192
await Promise . all ( [
197
193
debugClient . configurationSequence ( ) ,
198
- debugClient . launch ( buildLauncArgs ( 'forever.py' , false ) ) ,
194
+ debugClient . launch ( buildLaunchArgs ( 'forever.py' , false ) ) ,
199
195
debugClient . waitForEvent ( 'initialized' )
200
196
] ) ;
201
197
@@ -225,7 +221,7 @@ let testCounter = 0;
225
221
const threadIdPromise = debugClient . waitForEvent ( 'thread' ) ;
226
222
await Promise . all ( [
227
223
debugClient . configurationSequence ( ) ,
228
- debugClient . launch ( buildLauncArgs ( 'sample2.py' , false ) ) ,
224
+ debugClient . launch ( buildLaunchArgs ( 'sample2.py' , false ) ) ,
229
225
debugClient . waitForEvent ( 'initialized' )
230
226
] ) ;
231
227
@@ -262,7 +258,7 @@ let testCounter = 0;
262
258
test ( 'Test editing variables' , async ( ) => {
263
259
await Promise . all ( [
264
260
debugClient . configurationSequence ( ) ,
265
- debugClient . launch ( buildLauncArgs ( 'sample2.py' , false ) ) ,
261
+ debugClient . launch ( buildLaunchArgs ( 'sample2.py' , false ) ) ,
266
262
debugClient . waitForEvent ( 'initialized' )
267
263
] ) ;
268
264
@@ -296,7 +292,7 @@ let testCounter = 0;
296
292
297
293
await Promise . all ( [
298
294
debugClient . configurationSequence ( ) ,
299
- debugClient . launch ( buildLauncArgs ( 'sample2.py' , false ) ) ,
295
+ debugClient . launch ( buildLaunchArgs ( 'sample2.py' , false ) ) ,
300
296
debugClient . waitForEvent ( 'initialized' )
301
297
] ) ;
302
298
@@ -322,7 +318,7 @@ let testCounter = 0;
322
318
323
319
await Promise . all ( [
324
320
debugClient . configurationSequence ( ) ,
325
- debugClient . launch ( buildLauncArgs ( 'sample2.py' , false ) ) ,
321
+ debugClient . launch ( buildLaunchArgs ( 'sample2.py' , false ) ) ,
326
322
debugClient . waitForEvent ( 'initialized' )
327
323
] ) ;
328
324
@@ -360,7 +356,7 @@ let testCounter = 0;
360
356
361
357
await Promise . all ( [
362
358
debugClient . configurationSequence ( ) ,
363
- debugClient . launch ( buildLauncArgs ( 'sample2.py' , false ) ) ,
359
+ debugClient . launch ( buildLaunchArgs ( 'sample2.py' , false ) ) ,
364
360
debugClient . waitForEvent ( 'initialized' )
365
361
] ) ;
366
362
@@ -411,7 +407,7 @@ let testCounter = 0;
411
407
412
408
await Promise . all ( [
413
409
debugClient . configurationSequence ( ) ,
414
- debugClient . launch ( buildLauncArgs ( 'forever.py' , false ) ) ,
410
+ debugClient . launch ( buildLaunchArgs ( 'forever.py' , false ) ) ,
415
411
debugClient . waitForEvent ( 'initialized' ) ,
416
412
debugClient . waitForEvent ( 'process' )
417
413
] ) ;
@@ -432,7 +428,7 @@ let testCounter = 0;
432
428
433
429
await Promise . all ( [
434
430
debugClient . configurationSequence ( ) ,
435
- debugClient . launch ( buildLauncArgs ( 'sample3WithEx.py' , false ) ) ,
431
+ debugClient . launch ( buildLaunchArgs ( 'sample3WithEx.py' , false ) ) ,
436
432
debugClient . waitForEvent ( 'initialized' )
437
433
] ) ;
438
434
@@ -447,7 +443,7 @@ let testCounter = 0;
447
443
}
448
444
await Promise . all ( [
449
445
debugClient . configurationSequence ( ) ,
450
- debugClient . launch ( buildLauncArgs ( 'multiThread.py' , false ) ) ,
446
+ debugClient . launch ( buildLaunchArgs ( 'multiThread.py' , false ) ) ,
451
447
debugClient . waitForEvent ( 'initialized' )
452
448
] ) ;
453
449
@@ -471,7 +467,7 @@ let testCounter = 0;
471
467
test ( 'Test multi-threaded debugging' , async function ( ) {
472
468
this . timeout ( 30000 ) ;
473
469
await Promise . all ( [
474
- debugClient . launch ( buildLauncArgs ( 'multiThread.py' , false ) ) ,
470
+ debugClient . launch ( buildLaunchArgs ( 'multiThread.py' , false ) ) ,
475
471
debugClient . waitForEvent ( 'initialized' )
476
472
] ) ;
477
473
@@ -514,7 +510,7 @@ let testCounter = 0;
514
510
test ( 'Test stack frames' , async ( ) => {
515
511
await Promise . all ( [
516
512
debugClient . configurationSequence ( ) ,
517
- debugClient . launch ( buildLauncArgs ( 'stackFrame.py' , false ) ) ,
513
+ debugClient . launch ( buildLaunchArgs ( 'stackFrame.py' , false ) ) ,
518
514
debugClient . waitForEvent ( 'initialized' )
519
515
] ) ;
520
516
const pythonFile = path . join ( debugFilesPath , 'stackFrame.py' ) ;
@@ -539,5 +535,20 @@ let testCounter = 0;
539
535
expect ( stackframes . body . stackFrames [ 2 ] . line ) . to . be . equal ( 10 ) ;
540
536
expect ( fileSystem . arePathsSame ( stackframes . body . stackFrames [ 2 ] . source ! . path ! , pythonFile ) ) . to . be . equal ( true , 'paths do not match' ) ;
541
537
} ) ;
538
+ test ( 'Test Passing custom args to python file' , async function ( ) {
539
+ this . retries ( 0 ) ;
540
+ if ( debuggerType !== 'pythonExperimental' ) {
541
+ return this . skip ( ) ;
542
+ }
543
+
544
+ const options = buildLaunchArgs ( 'printSysArgv.py' , false ) ;
545
+ options . args = [ '1' , '2' , '3' ] ;
546
+ await Promise . all ( [
547
+ debugClient . configurationSequence ( ) ,
548
+ debugClient . launch ( options ) ,
549
+ debugClient . assertOutput ( 'stdout' , options . args . join ( ',' ) ) ,
550
+ debugClient . waitForEvent ( 'terminated' )
551
+ ] ) ;
552
+ } ) ;
542
553
} ) ;
543
554
} ) ;
0 commit comments