Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: don't spawn child processes in domain test #974

Merged
merged 2 commits into from
Mar 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/node_counters.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
#include "node_win32_perfctr_provider.h"
#else
#define NODE_COUNTER_ENABLED() (false)
#define NODE_COUNT_HTTP_SERVER_REQUEST()
#define NODE_COUNT_HTTP_SERVER_RESPONSE()
#define NODE_COUNT_HTTP_CLIENT_REQUEST()
#define NODE_COUNT_HTTP_CLIENT_RESPONSE()
#define NODE_COUNT_SERVER_CONN_OPEN()
#define NODE_COUNT_SERVER_CONN_CLOSE()
#define NODE_COUNT_NET_BYTES_SENT(bytes)
#define NODE_COUNT_NET_BYTES_RECV(bytes)
#define NODE_COUNT_GET_GC_RAWTIME()
#define NODE_COUNT_GC_PERCENTTIME(percent)
#define NODE_COUNT_PIPE_BYTES_SENT(bytes)
#define NODE_COUNT_PIPE_BYTES_RECV(bytes)
#define NODE_COUNT_GC_PERCENTTIME(percent) do { } while (false)
#define NODE_COUNT_GET_GC_RAWTIME() do { } while (false)
#define NODE_COUNT_HTTP_CLIENT_REQUEST() do { } while (false)
#define NODE_COUNT_HTTP_CLIENT_RESPONSE() do { } while (false)
#define NODE_COUNT_HTTP_SERVER_REQUEST() do { } while (false)
#define NODE_COUNT_HTTP_SERVER_RESPONSE() do { } while (false)
#define NODE_COUNT_NET_BYTES_RECV(bytes) do { } while (false)
#define NODE_COUNT_NET_BYTES_SENT(bytes) do { } while (false)
#define NODE_COUNT_PIPE_BYTES_RECV(bytes) do { } while (false)
#define NODE_COUNT_PIPE_BYTES_SENT(bytes) do { } while (false)
#define NODE_COUNT_SERVER_CONN_CLOSE() do { } while (false)
#define NODE_COUNT_SERVER_CONN_OPEN() do { } while (false)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't feel like filing a separate PR for this so here you have it. :-)

#endif

#include "v8.h"
Expand Down
54 changes: 20 additions & 34 deletions test/parallel/test-domain-abort-on-uncaught.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
// Flags: --abort_on_uncaught_exception
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL!


var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
var domain = require('domain');

var tests = [
nextTick,
timer,
timerPlusNextTick,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's very peculiar but if firstRun is not last, errors == 4 instead of 5...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems ... bizarre.

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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -73,37 +62,34 @@ 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!');
});
}

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();
});
});
}