mirror of https://github.com/lukechilds/node.git
Browse Source
with tests Fix module path resolve bug. Normally the module path is taken from realpath(__filename) but with eval there is (of course) no filenamev0.7.4-release
Ben Noordhuis
14 years ago
committed by
Ryan Dahl
2 changed files with 46 additions and 7 deletions
@ -0,0 +1,28 @@ |
|||
assert = require('assert'); |
|||
child = require('child_process'); |
|||
|
|||
nodejs = process.execPath; |
|||
|
|||
if (module.parent) { |
|||
// signal we've been loaded as a module
|
|||
console.log('Loaded as a module, exiting with status code 42.'); |
|||
process.exit(42); |
|||
} |
|||
|
|||
// assert that the result of the final expression is written to stdout
|
|||
child.exec(nodejs + ' --eval \'1337; 42\'', |
|||
function(err, stdout, stderr) { |
|||
assert.equal(parseInt(stdout), 42); |
|||
}); |
|||
|
|||
// assert that module loading works
|
|||
child.exec(nodejs + ' --eval \'require("' + __filename + '")\'', |
|||
function(status, stdout, stderr) { |
|||
assert.equal(status.code, 42); |
|||
}); |
|||
|
|||
// module path resolve bug, regression test
|
|||
child.exec(nodejs + ' --eval \'require("./test/simple/test-cli-eval.js")\'', |
|||
function(status, stdout, stderr) { |
|||
assert.equal(status.code, 42); |
|||
}); |
Loading…
Reference in new issue