Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/common.js22
-rw-r--r--test/parallel/test-domain-no-error-handler-abort-on-uncaught-0.js18
-rw-r--r--test/parallel/test-domain-no-error-handler-abort-on-uncaught-1.js21
-rw-r--r--test/parallel/test-domain-no-error-handler-abort-on-uncaught-2.js20
-rw-r--r--test/parallel/test-domain-no-error-handler-abort-on-uncaught-3.js20
-rw-r--r--test/parallel/test-domain-no-error-handler-abort-on-uncaught-4.js20
-rw-r--r--test/parallel/test-domain-no-error-handler-abort-on-uncaught-5.js21
-rw-r--r--test/parallel/test-domain-no-error-handler-abort-on-uncaught-6.js26
-rw-r--r--test/parallel/test-domain-no-error-handler-abort-on-uncaught-7.js26
-rw-r--r--test/parallel/test-domain-no-error-handler-abort-on-uncaught-8.js26
-rw-r--r--test/parallel/test-domain-no-error-handler-abort-on-uncaught-9.js27
-rw-r--r--test/parallel/test-domain-no-error-handler-abort-on-uncaught.js168
12 files changed, 247 insertions, 168 deletions
diff --git a/test/common.js b/test/common.js
index 84810a007e0..756adcbfd03 100644
--- a/test/common.js
+++ b/test/common.js
@@ -204,6 +204,28 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) {
});
});
+/*
+ * Check that when running a test with
+ * `$node --abort-on-uncaught-exception $file child`
+ * the process aborts.
+ */
+exports.childShouldThrowAndAbort = function() {
+ var testCmd = '';
+ if (!exports.isWindows) {
+ // Do not create core files, as it can take a lot of disk space on
+ // continuous testing and developers' machines
+ testCmd += 'ulimit -c 0 && ';
+ }
+ testCmd += `${process.argv[0]} --abort-on-uncaught-exception `;
+ testCmd += `${process.argv[1]} child`;
+ const child = child_process.exec(testCmd);
+ child.on('exit', function onExit(exitCode, signal) {
+ const errMsg = 'Test should have aborted ' +
+ `but instead exited with exit code ${exitCode}` +
+ ` and signal ${signal}`;
+ assert(exports.nodeProcessAborted(exitCode, signal), errMsg);
+ });
+};
exports.ddCommand = function(filename, kilobytes) {
if (exports.isWindows) {
diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-0.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-0.js
new file mode 100644
index 00000000000..6a3a670b920
--- /dev/null
+++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-0.js
@@ -0,0 +1,18 @@
+'use strict';
+
+const common = require('../common');
+const domain = require('domain');
+
+function test() {
+ const d = domain.create();
+
+ d.run(function() {
+ throw new Error('boom!');
+ });
+}
+
+if (process.argv[2] === 'child') {
+ test();
+} else {
+ common.childShouldThrowAndAbort();
+}
diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-1.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-1.js
new file mode 100644
index 00000000000..e3224517657
--- /dev/null
+++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-1.js
@@ -0,0 +1,21 @@
+'use strict';
+
+const common = require('../common');
+const domain = require('domain');
+
+function test() {
+ const d = domain.create();
+ const d2 = domain.create();
+
+ d.run(function() {
+ d2.run(function() {
+ throw new Error('boom!');
+ });
+ });
+}
+
+if (process.argv[2] === 'child') {
+ test();
+} else {
+ common.childShouldThrowAndAbort();
+}
diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-2.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-2.js
new file mode 100644
index 00000000000..ff0fd5eec35
--- /dev/null
+++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-2.js
@@ -0,0 +1,20 @@
+'use strict';
+
+const common = require('../common');
+const domain = require('domain');
+
+function test() {
+ const d = domain.create();
+
+ d.run(function() {
+ setTimeout(function() {
+ throw new Error('boom!');
+ }, 1);
+ });
+}
+
+if (process.argv[2] === 'child') {
+ test();
+} else {
+ common.childShouldThrowAndAbort();
+}
diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-3.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-3.js
new file mode 100644
index 00000000000..cbe5f3ed8dc
--- /dev/null
+++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-3.js
@@ -0,0 +1,20 @@
+'use strict';
+
+const common = require('../common');
+const domain = require('domain');
+
+function test() {
+ const d = domain.create();
+
+ d.run(function() {
+ setImmediate(function() {
+ throw new Error('boom!');
+ });
+ });
+}
+
+if (process.argv[2] === 'child') {
+ test();
+} else {
+ common.childShouldThrowAndAbort();
+}
diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-4.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-4.js
new file mode 100644
index 00000000000..4d0dd39454d
--- /dev/null
+++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-4.js
@@ -0,0 +1,20 @@
+'use strict';
+
+const common = require('../common');
+const domain = require('domain');
+
+function test() {
+ const d = domain.create();
+
+ d.run(function() {
+ process.nextTick(function() {
+ throw new Error('boom!');
+ });
+ });
+}
+
+if (process.argv[2] === 'child') {
+ test();
+} else {
+ common.childShouldThrowAndAbort();
+}
diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-5.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-5.js
new file mode 100644
index 00000000000..78ef3662a20
--- /dev/null
+++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-5.js
@@ -0,0 +1,21 @@
+'use strict';
+
+const common = require('../common');
+const domain = require('domain');
+
+function test() {
+ const d = domain.create();
+
+ d.run(function() {
+ var fs = require('fs');
+ fs.exists('/non/existing/file', function onExists() {
+ throw new Error('boom!');
+ });
+ });
+}
+
+if (process.argv[2] === 'child') {
+ test();
+} else {
+ common.childShouldThrowAndAbort();
+}
diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-6.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-6.js
new file mode 100644
index 00000000000..c3a91379319
--- /dev/null
+++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-6.js
@@ -0,0 +1,26 @@
+'use strict';
+
+const common = require('../common');
+const domain = require('domain');
+
+function test() {
+ const d = domain.create();
+ const d2 = domain.create();
+
+ d.on('error', function errorHandler() {
+ });
+
+ d.run(function() {
+ d2.run(function() {
+ setTimeout(function() {
+ throw new Error('boom!');
+ }, 1);
+ });
+ });
+}
+
+if (process.argv[2] === 'child') {
+ test();
+} else {
+ common.childShouldThrowAndAbort();
+}
diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-7.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-7.js
new file mode 100644
index 00000000000..9debc754cea
--- /dev/null
+++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-7.js
@@ -0,0 +1,26 @@
+'use strict';
+
+const common = require('../common');
+const domain = require('domain');
+
+function test() {
+ const d = domain.create();
+ const d2 = domain.create();
+
+ d.on('error', function errorHandler() {
+ });
+
+ d.run(function() {
+ d2.run(function() {
+ setImmediate(function() {
+ throw new Error('boom!');
+ });
+ });
+ });
+}
+
+if (process.argv[2] === 'child') {
+ test();
+} else {
+ common.childShouldThrowAndAbort();
+}
diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-8.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-8.js
new file mode 100644
index 00000000000..f1670cbd300
--- /dev/null
+++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-8.js
@@ -0,0 +1,26 @@
+'use strict';
+
+const common = require('../common');
+const domain = require('domain');
+
+function test() {
+ const d = domain.create();
+ const d2 = domain.create();
+
+ d.on('error', function errorHandler() {
+ });
+
+ d.run(function() {
+ d2.run(function() {
+ process.nextTick(function() {
+ throw new Error('boom!');
+ });
+ });
+ });
+}
+
+if (process.argv[2] === 'child') {
+ test();
+} else {
+ common.childShouldThrowAndAbort();
+}
diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-9.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-9.js
new file mode 100644
index 00000000000..a4eebd50e96
--- /dev/null
+++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-9.js
@@ -0,0 +1,27 @@
+'use strict';
+
+const common = require('../common');
+const domain = require('domain');
+
+function test() {
+ const d = domain.create();
+ const d2 = domain.create();
+
+ d.on('error', function errorHandler() {
+ });
+
+ d.run(function() {
+ d2.run(function() {
+ var fs = require('fs');
+ fs.exists('/non/existing/file', function onExists() {
+ throw new Error('boom!');
+ });
+ });
+ });
+}
+
+if (process.argv[2] === 'child') {
+ test();
+} else {
+ common.childShouldThrowAndAbort();
+}
diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught.js
deleted file mode 100644
index 833e7374d7f..00000000000
--- a/test/parallel/test-domain-no-error-handler-abort-on-uncaught.js
+++ /dev/null
@@ -1,168 +0,0 @@
-'use strict';
-
-/*
- * This test makes sure that when using --abort-on-uncaught-exception and
- * when throwing an error from within a domain that does not have an error
- * handler setup, the process aborts.
- */
-const common = require('../common');
-const assert = require('assert');
-const domain = require('domain');
-const child_process = require('child_process');
-
-const tests = [
- function() {
- const d = domain.create();
-
- d.run(function() {
- throw new Error('boom!');
- });
- },
-
- function() {
- const d = domain.create();
- const d2 = domain.create();
-
- d.run(function() {
- d2.run(function() {
- throw new Error('boom!');
- });
- });
- },
-
- function() {
- const d = domain.create();
-
- d.run(function() {
- setTimeout(function() {
- throw new Error('boom!');
- }, 1);
- });
- },
-
- function() {
- const d = domain.create();
-
- d.run(function() {
- setImmediate(function() {
- throw new Error('boom!');
- });
- });
- },
-
- function() {
- const d = domain.create();
-
- d.run(function() {
- process.nextTick(function() {
- throw new Error('boom!');
- });
- });
- },
-
- function() {
- const d = domain.create();
-
- d.run(function() {
- var fs = require('fs');
- fs.exists('/non/existing/file', function onExists() {
- throw new Error('boom!');
- });
- });
- },
-
- function() {
- const d = domain.create();
- const d2 = domain.create();
-
- d.on('error', function errorHandler() {
- });
-
- d.run(function() {
- d2.run(function() {
- setTimeout(function() {
- throw new Error('boom!');
- }, 1);
- });
- });
- },
-
- function() {
- const d = domain.create();
- const d2 = domain.create();
-
- d.on('error', function errorHandler() {
- });
-
- d.run(function() {
- d2.run(function() {
- setImmediate(function() {
- throw new Error('boom!');
- });
- });
- });
- },
-
- function() {
- const d = domain.create();
- const d2 = domain.create();
-
- d.on('error', function errorHandler() {
- });
-
- d.run(function() {
- d2.run(function() {
- process.nextTick(function() {
- throw new Error('boom!');
- });
- });
- });
- },
-
- function() {
- const d = domain.create();
- const d2 = domain.create();
-
- d.on('error', function errorHandler() {
- });
-
- d.run(function() {
- d2.run(function() {
- var fs = require('fs');
- fs.exists('/non/existing/file', function onExists() {
- throw new Error('boom!');
- });
- });
- });
- },
-];
-
-if (process.argv[2] === 'child') {
- const testIndex = +process.argv[3];
- tests[testIndex]();
-} else {
-
- tests.forEach(function(test, testIndex) {
- var testCmd = '';
- if (!common.isWindows) {
- // Do not create core files, as it can take a lot of disk space on
- // continuous testing and developers' machines
- testCmd += 'ulimit -c 0 && ';
- }
-
- testCmd += process.argv[0];
- testCmd += ' ' + '--abort-on-uncaught-exception';
- testCmd += ' ' + process.argv[1];
- testCmd += ' ' + 'child';
- testCmd += ' ' + testIndex;
-
- var child = child_process.exec(testCmd);
-
- child.on('exit', function onExit(exitCode, signal) {
- const errMsg = 'Test at index ' + testIndex + ' should have aborted ' +
- 'but instead exited with exit code ' + exitCode +
- ' and signal ' + signal;
- assert(common.nodeProcessAborted(exitCode, signal), errMsg);
- });
- });
-}