@@ -31,9 +31,35 @@ module.exports = function (file, opts) {
31
31
} : false
32
32
} , opts ) ;
33
33
34
- var ps = childProcess . fork ( path . join ( __dirname , 'test-worker.js' ) , [ JSON . stringify ( opts ) ] , {
35
- cwd : path . dirname ( file ) ,
36
- silent : true ,
34
+ // Workaround for breakage caused by https://github.com/nodejs/node/pull/5950
35
+ // Those changes will be reverted in https://github.com/nodejs/node/pull/6537
36
+
37
+ // Revert #815 when these changes land in Node.js
38
+ var execArgv = process . execArgv ;
39
+ var cwd = path . dirname ( file ) ;
40
+
41
+ // This whole if statement is copied straight out of Nodes `child_process`
42
+ if ( process . _eval != null ) { // eslint-disable-line
43
+ var index = execArgv . lastIndexOf ( process . _eval ) ;
44
+ if ( index > 0 ) {
45
+ // Remove the -e switch to avoid fork bombing ourselves.
46
+ execArgv = execArgv . slice ( ) ;
47
+ execArgv . splice ( index - 1 , 2 ) ;
48
+ }
49
+ }
50
+
51
+ var testWorkerPath = path . join ( __dirname , 'test-worker.js' ) ;
52
+
53
+ var args = execArgv . concat ( [
54
+ '-e' ,
55
+ 'require(' + JSON . stringify ( testWorkerPath ) + ')' ,
56
+ testWorkerPath ,
57
+ JSON . stringify ( opts )
58
+ ] ) ;
59
+
60
+ var ps = childProcess . spawn ( process . execPath , args , {
61
+ cwd : cwd ,
62
+ stdio : [ 'pipe' , 'pipe' , 'pipe' , 'ipc' ] ,
37
63
env : env
38
64
} ) ;
39
65
0 commit comments