-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support NODE_PATH in forked process #531
Changes from all commits
c2aab4f
3704a07
33dd8f6
669be7c
d37a356
082708b
d4bf3ee
1e2d8ad
eecfebb
c42afed
581e776
5dc109e
f947eb0
f932f07
d2fa2a2
efdc4c2
75b0de0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,16 +8,19 @@ var arrify = require('arrify'); | |
var touch = require('touch'); | ||
var cliPath = path.join(__dirname, '../cli.js'); | ||
|
||
function execCli(args, dirname, cb) { | ||
if (typeof dirname === 'function') { | ||
cb = dirname; | ||
function execCli(args, opts, cb) { | ||
var dirname; | ||
var env; | ||
|
||
if (typeof opts === 'function') { | ||
cb = opts; | ||
dirname = __dirname; | ||
env = {}; | ||
} else { | ||
dirname = path.join(__dirname, dirname); | ||
dirname = path.join(__dirname, opts.dirname ? opts.dirname : ''); | ||
env = opts.env || {}; | ||
} | ||
|
||
var env = {}; | ||
|
||
if (process.env.AVA_APPVEYOR) { | ||
env.AVA_APPVEYOR = 1; | ||
} | ||
|
@@ -95,21 +98,21 @@ test('log failed tests', function (t) { | |
}); | ||
|
||
test('pkg-conf: defaults', function (t) { | ||
execCli([], 'fixture/pkg-conf/defaults', function (err) { | ||
execCli([], {dirname: 'fixture/pkg-conf/defaults'}, function (err) { | ||
t.ifError(err); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
test('pkg-conf: pkg-overrides', function (t) { | ||
execCli([], 'fixture/pkg-conf/pkg-overrides', function (err) { | ||
execCli([], {dirname: 'fixture/pkg-conf/pkg-overrides'}, function (err) { | ||
t.ifError(err); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
test('pkg-conf: cli takes precedence', function (t) { | ||
execCli(['--no-serial', '--cache', '--no-fail-fast', '--require=./required.js', 'c.js'], 'fixture/pkg-conf/precedence', function (err) { | ||
execCli(['--no-serial', '--cache', '--no-fail-fast', '--require=./required.js', 'c.js'], {dirname: 'fixture/pkg-conf/precedence'}, function (err) { | ||
t.ifError(err); | ||
t.end(); | ||
}); | ||
|
@@ -124,7 +127,7 @@ test('watcher works', function (t) { | |
hasChokidar = true; | ||
} catch (err) {} | ||
|
||
var child = execCli(['--verbose', '--watch', 'test.js'], 'fixture/watcher', function (err, stdout) { | ||
var child = execCli(['--verbose', '--watch', 'test.js'], {dirname: 'fixture/watcher'}, function (err, stdout) { | ||
if (err && err.code === 1 && !hasChokidar) { | ||
t.comment('chokidar dependency is missing, cannot test watcher'); | ||
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) { | |
} | ||
}); | ||
}); | ||
|
||
test('handles NODE_PATH', function (t) { | ||
var nodePaths = 'node-paths/modules' + path.delimiter + 'node-paths/deep/nested'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sindresorhus do you mean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, nvm, I read it as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Node probably handles any platform issues with the slashes in |
||
execCli('fixture/node-paths.js', {env: {NODE_PATH: nodePaths}}, function (err) { | ||
t.notOk(err); | ||
t.end(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import test from '../../'; | ||
|
||
import foo from 'nested/foo'; | ||
import bar from 'path/bar'; | ||
|
||
test('relative require', t => { | ||
t.is(foo(), 'bar'); | ||
t.is(bar(), 'baz'); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = function () { | ||
return 'baz'; | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = function () { | ||
return 'bar'; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, discovered this too late. This makes no sense. Here you overwrite the modified
NODE_PATH
with the original one. This means the tests are also invalid. Tests still pass when the.map
is commented out.// @ingro @novemberborn