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: reduce unmanaged parallelism in test #10329

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 22 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 18 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-0.js
Original file line number Diff line number Diff line change
@@ -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();
}
21 changes: 21 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-1.js
Original file line number Diff line number Diff line change
@@ -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();
}
20 changes: 20 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-2.js
Original file line number Diff line number Diff line change
@@ -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();
}
20 changes: 20 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-3.js
Original file line number Diff line number Diff line change
@@ -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();
}
20 changes: 20 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-4.js
Original file line number Diff line number Diff line change
@@ -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();
}
21 changes: 21 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-5.js
Original file line number Diff line number Diff line change
@@ -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();
}
26 changes: 26 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-6.js
Original file line number Diff line number Diff line change
@@ -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();
}
26 changes: 26 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-7.js
Original file line number Diff line number Diff line change
@@ -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();
}
26 changes: 26 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-8.js
Original file line number Diff line number Diff line change
@@ -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();
}
27 changes: 27 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-9.js
Original file line number Diff line number Diff line change
@@ -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();
}
Loading