@@ -8,16 +8,19 @@ var arrify = require('arrify');
8
8
var touch = require ( 'touch' ) ;
9
9
var cliPath = path . join ( __dirname , '../cli.js' ) ;
10
10
11
- function execCli ( args , dirname , cb ) {
12
- if ( typeof dirname === 'function' ) {
13
- cb = dirname ;
11
+ function execCli ( args , opts , cb ) {
12
+ var dirname ;
13
+ var env ;
14
+
15
+ if ( typeof opts === 'function' ) {
16
+ cb = opts ;
14
17
dirname = __dirname ;
18
+ env = { } ;
15
19
} else {
16
- dirname = path . join ( __dirname , dirname ) ;
20
+ dirname = path . join ( __dirname , opts . dirname ? opts . dirname : '' ) ;
21
+ env = opts . env || { } ;
17
22
}
18
23
19
- var env = { } ;
20
-
21
24
if ( process . env . AVA_APPVEYOR ) {
22
25
env . AVA_APPVEYOR = 1 ;
23
26
}
@@ -95,21 +98,21 @@ test('log failed tests', function (t) {
95
98
} ) ;
96
99
97
100
test ( 'pkg-conf: defaults' , function ( t ) {
98
- execCli ( [ ] , 'fixture/pkg-conf/defaults' , function ( err ) {
101
+ execCli ( [ ] , { dirname : 'fixture/pkg-conf/defaults' } , function ( err ) {
99
102
t . ifError ( err ) ;
100
103
t . end ( ) ;
101
104
} ) ;
102
105
} ) ;
103
106
104
107
test ( 'pkg-conf: pkg-overrides' , function ( t ) {
105
- execCli ( [ ] , 'fixture/pkg-conf/pkg-overrides' , function ( err ) {
108
+ execCli ( [ ] , { dirname : 'fixture/pkg-conf/pkg-overrides' } , function ( err ) {
106
109
t . ifError ( err ) ;
107
110
t . end ( ) ;
108
111
} ) ;
109
112
} ) ;
110
113
111
114
test ( 'pkg-conf: cli takes precedence' , function ( t ) {
112
- execCli ( [ '--no-serial' , '--cache' , '--no-fail-fast' , '--require=./required.js' , 'c.js' ] , 'fixture/pkg-conf/precedence' , function ( err ) {
115
+ execCli ( [ '--no-serial' , '--cache' , '--no-fail-fast' , '--require=./required.js' , 'c.js' ] , { dirname : 'fixture/pkg-conf/precedence' } , function ( err ) {
113
116
t . ifError ( err ) ;
114
117
t . end ( ) ;
115
118
} ) ;
@@ -124,7 +127,7 @@ test('watcher works', function (t) {
124
127
hasChokidar = true ;
125
128
} catch ( err ) { }
126
129
127
- var child = execCli ( [ '--verbose' , '--watch' , 'test.js' ] , 'fixture/watcher' , function ( err , stdout ) {
130
+ var child = execCli ( [ '--verbose' , '--watch' , 'test.js' ] , { dirname : 'fixture/watcher' } , function ( err , stdout ) {
128
131
if ( err && err . code === 1 && ! hasChokidar ) {
129
132
t . comment ( 'chokidar dependency is missing, cannot test watcher' ) ;
130
133
t . match ( stdout , 'The optional dependency chokidar failed to install and is required for --watch. Chokidar is likely not supported on your platform.' ) ;
@@ -155,3 +158,11 @@ test('watcher works', function (t) {
155
158
}
156
159
} ) ;
157
160
} ) ;
161
+
162
+ test ( 'handles NODE_PATH' , function ( t ) {
163
+ var nodePaths = 'node-paths/modules' + path . delimiter + 'node-paths/deep/nested' ;
164
+ execCli ( 'fixture/node-paths.js' , { env : { NODE_PATH : nodePaths } } , function ( err ) {
165
+ t . notOk ( err ) ;
166
+ t . end ( ) ;
167
+ } ) ;
168
+ } ) ;
0 commit comments