mirror of https://github.com/lukechilds/node.git
Browse Source
Passing a filename is still supported in place of certain options arguments, for backward-compatibility, but timeout and display-errors are not translated since those were undocumented. Also managed to eliminate an extra stack trace line by not calling through the `createScript` export. Added a few message tests to show how `displayErrors` works.v0.11.7-release
committed by
isaacs
17 changed files with 331 additions and 88 deletions
@ -0,0 +1,30 @@ |
|||
// Copyright Joyent, Inc. and other Node contributors.
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|||
// copy of this software and associated documentation files (the
|
|||
// "Software"), to deal in the Software without restriction, including
|
|||
// without limitation the rights to use, copy, modify, merge, publish,
|
|||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|||
// persons to whom the Software is furnished to do so, subject to the
|
|||
// following conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be included
|
|||
// in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
|||
var common = require('../common'); |
|||
var assert = require('assert'); |
|||
var vm = require('vm'); |
|||
|
|||
console.error('beginning'); |
|||
|
|||
vm.runInThisContext('throw new Error("boo!")', { filename: 'test.vm' }); |
|||
|
|||
console.error('end'); |
@ -0,0 +1,16 @@ |
|||
beginning |
|||
|
|||
test.vm:1 |
|||
throw new Error("boo!") |
|||
^ |
|||
Error: boo! |
|||
at test.vm:1:7 |
|||
at Object.exports.runInThisContext (vm.js:*) |
|||
at Object.<anonymous> (*test*message*vm_display_runtime_error.js:*) |
|||
at Module._compile (module.js:*) |
|||
at Object.Module._extensions..js (module.js:*) |
|||
at Module.load (module.js:*) |
|||
at Function.Module._load (module.js:*) |
|||
at Function.Module.runMain (module.js:*) |
|||
at startup (node.js:*) |
|||
at node.js:* |
@ -0,0 +1,30 @@ |
|||
// Copyright Joyent, Inc. and other Node contributors.
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|||
// copy of this software and associated documentation files (the
|
|||
// "Software"), to deal in the Software without restriction, including
|
|||
// without limitation the rights to use, copy, modify, merge, publish,
|
|||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|||
// persons to whom the Software is furnished to do so, subject to the
|
|||
// following conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be included
|
|||
// in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
|||
var common = require('../common'); |
|||
var assert = require('assert'); |
|||
var vm = require('vm'); |
|||
|
|||
console.error('beginning'); |
|||
|
|||
vm.runInThisContext('var 5;', { filename: 'test.vm' }); |
|||
|
|||
console.error('end'); |
@ -0,0 +1,15 @@ |
|||
beginning |
|||
|
|||
test.vm:1 |
|||
var 5; |
|||
^ |
|||
SyntaxError: Unexpected number |
|||
at Object.exports.runInThisContext (vm.js:*) |
|||
at Object.<anonymous> (*test*message*vm_display_syntax_error.js:*) |
|||
at Module._compile (module.js:*) |
|||
at Object.Module._extensions..js (module.js:*) |
|||
at Module.load (module.js:*) |
|||
at Function.Module._load (module.js:*) |
|||
at Function.Module.runMain (module.js:*) |
|||
at startup (node.js:*) |
|||
at node.js:* |
@ -0,0 +1,42 @@ |
|||
// Copyright Joyent, Inc. and other Node contributors.
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|||
// copy of this software and associated documentation files (the
|
|||
// "Software"), to deal in the Software without restriction, including
|
|||
// without limitation the rights to use, copy, modify, merge, publish,
|
|||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|||
// persons to whom the Software is furnished to do so, subject to the
|
|||
// following conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be included
|
|||
// in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
|||
var common = require('../common'); |
|||
var assert = require('assert'); |
|||
var vm = require('vm'); |
|||
|
|||
console.error('beginning'); |
|||
|
|||
try { |
|||
vm.runInThisContext('throw new Error("boo!")', { |
|||
filename: 'test.vm', |
|||
displayErrors: false |
|||
}); |
|||
} catch (e) {} |
|||
|
|||
console.error('middle'); |
|||
|
|||
vm.runInThisContext('throw new Error("boo!")', { |
|||
filename: 'test.vm', |
|||
displayErrors: false |
|||
}); |
|||
|
|||
console.error('end'); |
@ -0,0 +1,17 @@ |
|||
beginning |
|||
middle |
|||
|
|||
vm.js:* |
|||
return script.runInThisContext(options); |
|||
^ |
|||
Error: boo! |
|||
at test.vm:1:7 |
|||
at Object.exports.runInThisContext (vm.js:*) |
|||
at Object.<anonymous> (*test*message*vm_dont_display_runtime_error.js:*) |
|||
at Module._compile (module.js:*) |
|||
at Object.Module._extensions..js (module.js:*) |
|||
at Module.load (module.js:*) |
|||
at Function.Module._load (module.js:*) |
|||
at Function.Module.runMain (module.js:*) |
|||
at startup (node.js:*) |
|||
at node.js:* |
@ -0,0 +1,42 @@ |
|||
// Copyright Joyent, Inc. and other Node contributors.
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|||
// copy of this software and associated documentation files (the
|
|||
// "Software"), to deal in the Software without restriction, including
|
|||
// without limitation the rights to use, copy, modify, merge, publish,
|
|||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|||
// persons to whom the Software is furnished to do so, subject to the
|
|||
// following conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be included
|
|||
// in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
|||
var common = require('../common'); |
|||
var assert = require('assert'); |
|||
var vm = require('vm'); |
|||
|
|||
console.error('beginning'); |
|||
|
|||
try { |
|||
vm.runInThisContext('var 5;', { |
|||
filename: 'test.vm', |
|||
displayErrors: false |
|||
}); |
|||
} catch (e) {} |
|||
|
|||
console.error('middle'); |
|||
|
|||
vm.runInThisContext('var 5;', { |
|||
filename: 'test.vm', |
|||
displayErrors: false |
|||
}); |
|||
|
|||
console.error('end'); |
@ -0,0 +1,16 @@ |
|||
beginning |
|||
middle |
|||
|
|||
vm.js:* |
|||
var script = new Script(code, options); |
|||
^ |
|||
SyntaxError: Unexpected number |
|||
at Object.exports.runInThisContext (vm.js:*) |
|||
at Object.<anonymous> (*test*message*vm_dont_display_syntax_error.js:*) |
|||
at Module._compile (module.js:*) |
|||
at Object.Module._extensions..js (module.js:*) |
|||
at Module.load (module.js:*) |
|||
at Function.Module._load (module.js:*) |
|||
at Function.Module.runMain (module.js:*) |
|||
at startup (node.js:*) |
|||
at node.js:* |
Loading…
Reference in new issue