|
|
@ -16,7 +16,7 @@ const nodeBinary = process.argv[0]; |
|
|
|
const preloadOption = (preloads) => { |
|
|
|
let option = ''; |
|
|
|
preloads.forEach(function(preload, index) { |
|
|
|
option += `-r ${preload} `; |
|
|
|
option += `-r "${preload}" `; |
|
|
|
}); |
|
|
|
return option; |
|
|
|
}; |
|
|
@ -30,7 +30,7 @@ const fixtureD = fixture('define-global.js'); |
|
|
|
const fixtureThrows = fixture('throws_error4.js'); |
|
|
|
|
|
|
|
// test preloading a single module works
|
|
|
|
childProcess.exec(`${nodeBinary} ${preloadOption([fixtureA])} ${fixtureB}`, |
|
|
|
childProcess.exec(`"${nodeBinary}" ${preloadOption([fixtureA])} "${fixtureB}"`, |
|
|
|
function(err, stdout, stderr) { |
|
|
|
assert.ifError(err); |
|
|
|
assert.strictEqual(stdout, 'A\nB\n'); |
|
|
@ -38,7 +38,7 @@ childProcess.exec(`${nodeBinary} ${preloadOption([fixtureA])} ${fixtureB}`, |
|
|
|
|
|
|
|
// test preloading multiple modules works
|
|
|
|
childProcess.exec( |
|
|
|
`${nodeBinary} ${preloadOption([fixtureA, fixtureB])} ${fixtureC}`, |
|
|
|
`"${nodeBinary}" ${preloadOption([fixtureA, fixtureB])} "${fixtureC}"`, |
|
|
|
function(err, stdout, stderr) { |
|
|
|
assert.ifError(err); |
|
|
|
assert.strictEqual(stdout, 'A\nB\nC\n'); |
|
|
@ -47,7 +47,7 @@ childProcess.exec( |
|
|
|
|
|
|
|
// test that preloading a throwing module aborts
|
|
|
|
childProcess.exec( |
|
|
|
`${nodeBinary} ${preloadOption([fixtureA, fixtureThrows])} ${fixtureB}`, |
|
|
|
`"${nodeBinary}" ${preloadOption([fixtureA, fixtureThrows])} "${fixtureB}"`, |
|
|
|
function(err, stdout, stderr) { |
|
|
|
if (err) { |
|
|
|
assert.strictEqual(stdout, 'A\n'); |
|
|
@ -59,7 +59,7 @@ childProcess.exec( |
|
|
|
|
|
|
|
// test that preload can be used with --eval
|
|
|
|
childProcess.exec( |
|
|
|
`${nodeBinary} ${preloadOption([fixtureA])}-e "console.log('hello');"`, |
|
|
|
`"${nodeBinary}" ${preloadOption([fixtureA])}-e "console.log('hello');"`, |
|
|
|
function(err, stdout, stderr) { |
|
|
|
assert.ifError(err); |
|
|
|
assert.strictEqual(stdout, 'A\nhello\n'); |
|
|
@ -105,7 +105,7 @@ replProc.on('close', function(code) { |
|
|
|
// test that preload placement at other points in the cmdline
|
|
|
|
// also test that duplicated preload only gets loaded once
|
|
|
|
childProcess.exec( |
|
|
|
`${nodeBinary} ${preloadOption([fixtureA])}-e "console.log('hello');" ${ |
|
|
|
`"${nodeBinary}" ${preloadOption([fixtureA])}-e "console.log('hello');" ${ |
|
|
|
preloadOption([fixtureA, fixtureB])}`,
|
|
|
|
function(err, stdout, stderr) { |
|
|
|
assert.ifError(err); |
|
|
@ -115,7 +115,7 @@ childProcess.exec( |
|
|
|
|
|
|
|
// test that preload works with -i
|
|
|
|
const interactive = childProcess.exec( |
|
|
|
`${nodeBinary} ${preloadOption([fixtureD])}-i`, |
|
|
|
`"${nodeBinary}" ${preloadOption([fixtureD])}-i`, |
|
|
|
common.mustCall(function(err, stdout, stderr) { |
|
|
|
assert.ifError(err); |
|
|
|
assert.strictEqual(stdout, "> 'test'\n> "); |
|
|
@ -126,8 +126,8 @@ interactive.stdin.write('a\n'); |
|
|
|
interactive.stdin.write('process.exit()\n'); |
|
|
|
|
|
|
|
childProcess.exec( |
|
|
|
`${nodeBinary} --require ${fixture('cluster-preload.js')} ${ |
|
|
|
fixture('cluster-preload-test.js')}`,
|
|
|
|
`"${nodeBinary}" --require "${fixture('cluster-preload.js')}" "${ |
|
|
|
fixture('cluster-preload-test.js')}"`,
|
|
|
|
function(err, stdout, stderr) { |
|
|
|
assert.ifError(err); |
|
|
|
assert.ok(/worker terminated with code 43/.test(stdout)); |
|
|
@ -137,8 +137,8 @@ childProcess.exec( |
|
|
|
// https://github.com/nodejs/node/issues/1691
|
|
|
|
process.chdir(common.fixturesDir); |
|
|
|
childProcess.exec( |
|
|
|
`${nodeBinary} --expose_natives_as=v8natives --require ` + |
|
|
|
`${fixture('cluster-preload.js')} cluster-preload-test.js`, |
|
|
|
`"${nodeBinary}" --expose_natives_as=v8natives --require ` + |
|
|
|
`"${fixture('cluster-preload.js')}" cluster-preload-test.js`, |
|
|
|
function(err, stdout, stderr) { |
|
|
|
assert.ifError(err); |
|
|
|
assert.ok(/worker terminated with code 43/.test(stdout)); |
|
|
|