summaryrefslogtreecommitdiff
path: root/test/parallel/test-domain-abort-on-uncaught.js
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2015-02-26 21:54:09 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2015-03-05 20:08:56 +0100
commit7b554b1a8ff8d98162fa26e7821b65be3fe7db3d (patch)
treeab93e19170365fb09125572e70d9442b929a6c20 /test/parallel/test-domain-abort-on-uncaught.js
parentb150c9839e2e522dbdaef9f6f6e2863842ca63d9 (diff)
downloadandroid-node-v8-7b554b1a8ff8d98162fa26e7821b65be3fe7db3d.tar.gz
android-node-v8-7b554b1a8ff8d98162fa26e7821b65be3fe7db3d.tar.bz2
android-node-v8-7b554b1a8ff8d98162fa26e7821b65be3fe7db3d.zip
test: don't spawn child processes in domain test
Make parallel/test-domain-abort-on-uncaught a little easier to debug, make it execute the tests in the same process instead of each test in a separate child process. PR-URL: https://github.com/iojs/io.js/pull/974 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Diffstat (limited to 'test/parallel/test-domain-abort-on-uncaught.js')
-rw-r--r--test/parallel/test-domain-abort-on-uncaught.js54
1 files changed, 20 insertions, 34 deletions
diff --git a/test/parallel/test-domain-abort-on-uncaught.js b/test/parallel/test-domain-abort-on-uncaught.js
index 9a4bd132a3..e11bbcc6bc 100644
--- a/test/parallel/test-domain-abort-on-uncaught.js
+++ b/test/parallel/test-domain-abort-on-uncaught.js
@@ -1,37 +1,30 @@
+// Flags: --abort_on_uncaught_exception
+
var common = require('../common');
var assert = require('assert');
-var spawn = require('child_process').spawn;
+var domain = require('domain');
var tests = [
nextTick,
timer,
timerPlusNextTick,
+ netServer,
firstRun,
- netServer
-]
+];
-tests.forEach(function(test) {
- console.log(test.name);
- var child = spawn(process.execPath, [
- '--abort-on-uncaught-exception',
- '-e',
- '(' + test + ')()',
- common.PORT
- ]);
- child.stderr.pipe(process.stderr);
- child.stdout.pipe(process.stdout);
- child.on('exit', function(code) {
- assert.strictEqual(code, 0);
- });
+var errors = 0;
+
+process.on('exit', function() {
+ assert.equal(errors, tests.length);
});
+tests.forEach(function(test) { test(); })
+
function nextTick() {
- var domain = require('domain');
var d = domain.create();
- d.on('error', function(err) {
- console.log('ok');
- process.exit(0);
+ d.once('error', function(err) {
+ errors += 1;
});
d.run(function() {
process.nextTick(function() {
@@ -41,12 +34,10 @@ function nextTick() {
}
function timer() {
- var domain = require('domain');
var d = domain.create();
d.on('error', function(err) {
- console.log('ok');
- process.exit(0);
+ errors += 1;
});
d.run(function() {
setTimeout(function() {
@@ -56,12 +47,10 @@ function timer() {
}
function timerPlusNextTick() {
- var domain = require('domain');
var d = domain.create();
d.on('error', function(err) {
- console.log('ok');
- process.exit(0);
+ errors += 1;
});
d.run(function() {
setTimeout(function() {
@@ -73,12 +62,10 @@ function timerPlusNextTick() {
}
function firstRun() {
- var domain = require('domain');
var d = domain.create();
d.on('error', function(err) {
- console.log('ok');
- process.exit(0);
+ errors += 1;
});
d.run(function() {
throw new Error('exceptional!');
@@ -86,24 +73,23 @@ function firstRun() {
}
function netServer() {
- var domain = require('domain');
var net = require('net');
var d = domain.create();
d.on('error', function(err) {
- console.log('ok');
- process.exit(0);
+ errors += 1;
});
d.run(function() {
var server = net.createServer(function(conn) {
conn.pipe(conn);
});
- server.listen(Number(process.argv[1]), '0.0.0.0', function() {
- var conn = net.connect(Number(process.argv[1]), '0.0.0.0')
+ server.listen(common.PORT, '0.0.0.0', function() {
+ var conn = net.connect(common.PORT, '0.0.0.0')
conn.once('data', function() {
throw new Error('ok');
})
conn.end('ok');
+ server.close();
});
});
}