This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree 4 files changed +47
-40
lines changed
4 files changed +47
-40
lines changed Original file line number Diff line number Diff line change 2
2
3
3
process . env . NODE_ENV = process . env . NODE_ENV || 'test' ;
4
4
5
- /**
6
- * This tiny wrapper file checks for node debug flags and appends them
7
- * when found, before invoking the real executable. Thanks to mocha for the
8
- * pattern.
9
- */
10
-
11
- var spawn = require ( 'child_process' ) . spawn ;
12
- var args = [ __dirname + '/../lib/cli.js' ] ;
13
-
14
- process . argv . slice ( 2 ) . forEach ( function ( arg ) {
15
- var flag = arg . split ( '=' ) [ 0 ] ;
16
-
17
- switch ( flag ) {
18
- case '-d' :
19
- args . unshift ( '--debug' ) ;
20
- break ;
21
- case 'debug' :
22
- case '--debug' :
23
- case '--debug-brk' :
24
- args . unshift ( arg ) ;
25
- break ;
26
- default :
27
- if ( 0 == arg . indexOf ( '--trace' ) ) { args . unshift ( arg ) ; }
28
- else { args . push ( arg ) ; }
29
- break ;
30
- }
31
- } ) ;
32
-
33
- var proc = spawn ( process . argv [ 0 ] , args , { stdio : 'inherit' } ) ;
34
- proc . on ( 'exit' , function ( code , signal ) {
35
- process . on ( 'exit' , function ( ) {
36
- if ( signal ) {
37
- process . kill ( process . pid , signal ) ;
38
- } else {
39
- process . exit ( code ) ;
40
- }
41
- } ) ;
42
- } ) ;
5
+ require ( '../lib/cli.js' ) ;
Original file line number Diff line number Diff line change 6
6
*/
7
7
'use strict' ;
8
8
9
+ var args = [ ] ;
10
+
11
+ process . argv . slice ( 2 ) . forEach ( function ( arg ) {
12
+ var flag = arg . split ( '=' ) [ 0 ] ;
13
+
14
+ switch ( flag ) {
15
+ case 'debug' :
16
+ args . push ( '--nodeDebug' ) ;
17
+ args . push ( 'true' ) ;
18
+ break ;
19
+ case '-d' :
20
+ case '--debug' :
21
+ case '--debug-brk' :
22
+ args . push ( '--v8Debug' ) ;
23
+ args . push ( 'true' ) ;
24
+ break ;
25
+ default :
26
+ args . push ( arg ) ;
27
+ break ;
28
+ }
29
+ } ) ;
30
+
9
31
var util = require ( 'util' ) ;
10
32
var path = require ( 'path' ) ;
11
33
var child = require ( 'child_process' ) ;
@@ -44,7 +66,7 @@ var argv = require('optimist').
44
66
throw '' ;
45
67
}
46
68
} ) .
47
- argv ;
69
+ parse ( args ) ;
48
70
49
71
if ( argv . version ) {
50
72
util . puts ( 'Version ' + require ( path . join ( __dirname , '../package.json' ) ) . version ) ;
Original file line number Diff line number Diff line change @@ -73,6 +73,9 @@ var init = function(argv) {
73
73
}
74
74
75
75
if ( config . multiCapabilities . length ) {
76
+ if ( config . debug ) {
77
+ throw new Error ( 'Cannot run in debug mode with multiCapabilities' ) ;
78
+ }
76
79
log_ ( 'Running using config.multiCapabilities - ' +
77
80
'config.capabilities will be ignored' ) ;
78
81
}
Original file line number Diff line number Diff line change @@ -18,7 +18,26 @@ var Runner = function(config) {
18
18
this . driverprovider_ = null ;
19
19
this . config_ = config ;
20
20
21
- // Init
21
+ if ( config . v8Debug ) {
22
+ process . kill ( process . pid , 'SIGUSR1' ) ;
23
+ }
24
+
25
+ if ( config . nodeDebug ) {
26
+ process . kill ( process . pid , 'SIGUSR1' ) ;
27
+ var flow = webdriver . promise . controlFlow ( ) ;
28
+
29
+ flow . execute ( function ( ) {
30
+ var nodedebug = require ( 'child_process' ) . fork ( 'debug' , [ 'localhost:5858' ] ) ;
31
+ process . on ( 'exit' , function ( ) {
32
+ nodedebug . kill ( 'SIGTERM' ) ;
33
+ } ) ;
34
+ nodedebug . on ( 'exit' , function ( ) {
35
+ process . exit ( '1' ) ;
36
+ } ) ;
37
+ } ) ;
38
+ flow . timeout ( 1000 , 'waiting for debugger to attach' ) ;
39
+ }
40
+
22
41
this . loadDriverProvider_ ( config ) ;
23
42
} ;
24
43
You can’t perform that action at this time.
0 commit comments