| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ed76b4a commit c13f01c
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -202,6 +202,28 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) { | |||
| 202 | 202 | }); | |
| 203 | 203 | }); | |
| 204 | 204 | ||
| 205 | + /* | ||
| 206 | + * Check that when running a test with | ||
| 207 | + * `$node --abort-on-uncaught-exception $file child` | ||
| 208 | + * the process aborts. | ||
| 209 | + */ | ||
| 210 | + exports.childShouldThrowAndAbort = function() { | ||
| 211 | + var testCmd = ''; | ||
| 212 | + if (!exports.isWindows) { | ||
| 213 | + // Do not create core files, as it can take a lot of disk space on | ||
| 214 | + // continuous testing and developers' machines | ||
| 215 | + testCmd += 'ulimit -c 0 && '; | ||
| 216 | + } | ||
| 217 | + testCmd += `${process.argv[0]} --abort-on-uncaught-exception `; | ||
| 218 | + testCmd += `${process.argv[1]} child`; | ||
| 219 | + const child = child_process.exec(testCmd); | ||
| 220 | + child.on('exit', function onExit(exitCode, signal) { | ||
| 221 | + const errMsg = 'Test should have aborted ' + | ||
| 222 | + `but instead exited with exit code ${exitCode}` + | ||
| 223 | + ` and signal ${signal}`; | ||
| 224 | + assert(exports.nodeProcessAborted(exitCode, signal), errMsg); | ||
| 225 | + }); | ||
| 226 | + }; | ||
| 205 | 227 | ||
| 206 | 228 | exports.ddCommand = function(filename, kilobytes) { | |
| 207 | 229 | if (exports.isWindows) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,18 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const domain = require('domain'); | ||
| 5 | + | ||
| 6 | + function test() { | ||
| 7 | + const d = domain.create(); | ||
| 8 | + | ||
| 9 | + d.run(function() { | ||
| 10 | + throw new Error('boom!'); | ||
| 11 | + }); | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + if (process.argv[2] === 'child') { | ||
| 15 | + test(); | ||
| 16 | + } else { | ||
| 17 | + common.childShouldThrowAndAbort(); | ||
| 18 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,21 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const domain = require('domain'); | ||
| 5 | + | ||
| 6 | + function test() { | ||
| 7 | + const d = domain.create(); | ||
| 8 | + const d2 = domain.create(); | ||
| 9 | + | ||
| 10 | + d.run(function() { | ||
| 11 | + d2.run(function() { | ||
| 12 | + throw new Error('boom!'); | ||
| 13 | + }); | ||
| 14 | + }); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + if (process.argv[2] === 'child') { | ||
| 18 | + test(); | ||
| 19 | + } else { | ||
| 20 | + common.childShouldThrowAndAbort(); | ||
| 21 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const domain = require('domain'); | ||
| 5 | + | ||
| 6 | + function test() { | ||
| 7 | + const d = domain.create(); | ||
| 8 | + | ||
| 9 | + d.run(function() { | ||
| 10 | + setTimeout(function() { | ||
| 11 | + throw new Error('boom!'); | ||
| 12 | + }, 1); | ||
| 13 | + }); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + if (process.argv[2] === 'child') { | ||
| 17 | + test(); | ||
| 18 | + } else { | ||
| 19 | + common.childShouldThrowAndAbort(); | ||
| 20 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const domain = require('domain'); | ||
| 5 | + | ||
| 6 | + function test() { | ||
| 7 | + const d = domain.create(); | ||
| 8 | + | ||
| 9 | + d.run(function() { | ||
| 10 | + setImmediate(function() { | ||
| 11 | + throw new Error('boom!'); | ||
| 12 | + }); | ||
| 13 | + }); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + if (process.argv[2] === 'child') { | ||
| 17 | + test(); | ||
| 18 | + } else { | ||
| 19 | + common.childShouldThrowAndAbort(); | ||
| 20 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const domain = require('domain'); | ||
| 5 | + | ||
| 6 | + function test() { | ||
| 7 | + const d = domain.create(); | ||
| 8 | + | ||
| 9 | + d.run(function() { | ||
| 10 | + process.nextTick(function() { | ||
| 11 | + throw new Error('boom!'); | ||
| 12 | + }); | ||
| 13 | + }); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + if (process.argv[2] === 'child') { | ||
| 17 | + test(); | ||
| 18 | + } else { | ||
| 19 | + common.childShouldThrowAndAbort(); | ||
| 20 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,21 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const domain = require('domain'); | ||
| 5 | + | ||
| 6 | + function test() { | ||
| 7 | + const d = domain.create(); | ||
| 8 | + | ||
| 9 | + d.run(function() { | ||
| 10 | + var fs = require('fs'); | ||
| 11 | + fs.exists('/non/existing/file', function onExists() { | ||
| 12 | + throw new Error('boom!'); | ||
| 13 | + }); | ||
| 14 | + }); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + if (process.argv[2] === 'child') { | ||
| 18 | + test(); | ||
| 19 | + } else { | ||
| 20 | + common.childShouldThrowAndAbort(); | ||
| 21 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const domain = require('domain'); | ||
| 5 | + | ||
| 6 | + function test() { | ||
| 7 | + const d = domain.create(); | ||
| 8 | + const d2 = domain.create(); | ||
| 9 | + | ||
| 10 | + d.on('error', function errorHandler() { | ||
| 11 | + }); | ||
| 12 | + | ||
| 13 | + d.run(function() { | ||
| 14 | + d2.run(function() { | ||
| 15 | + setTimeout(function() { | ||
| 16 | + throw new Error('boom!'); | ||
| 17 | + }, 1); | ||
| 18 | + }); | ||
| 19 | + }); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + if (process.argv[2] === 'child') { | ||
| 23 | + test(); | ||
| 24 | + } else { | ||
| 25 | + common.childShouldThrowAndAbort(); | ||
| 26 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const domain = require('domain'); | ||
| 5 | + | ||
| 6 | + function test() { | ||
| 7 | + const d = domain.create(); | ||
| 8 | + const d2 = domain.create(); | ||
| 9 | + | ||
| 10 | + d.on('error', function errorHandler() { | ||
| 11 | + }); | ||
| 12 | + | ||
| 13 | + d.run(function() { | ||
| 14 | + d2.run(function() { | ||
| 15 | + setImmediate(function() { | ||
| 16 | + throw new Error('boom!'); | ||
| 17 | + }); | ||
| 18 | + }); | ||
| 19 | + }); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + if (process.argv[2] === 'child') { | ||
| 23 | + test(); | ||
| 24 | + } else { | ||
| 25 | + common.childShouldThrowAndAbort(); | ||
| 26 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const domain = require('domain'); | ||
| 5 | + | ||
| 6 | + function test() { | ||
| 7 | + const d = domain.create(); | ||
| 8 | + const d2 = domain.create(); | ||
| 9 | + | ||
| 10 | + d.on('error', function errorHandler() { | ||
| 11 | + }); | ||
| 12 | + | ||
| 13 | + d.run(function() { | ||
| 14 | + d2.run(function() { | ||
| 15 | + process.nextTick(function() { | ||
| 16 | + throw new Error('boom!'); | ||
| 17 | + }); | ||
| 18 | + }); | ||
| 19 | + }); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + if (process.argv[2] === 'child') { | ||
| 23 | + test(); | ||
| 24 | + } else { | ||
| 25 | + common.childShouldThrowAndAbort(); | ||
| 26 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments