Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3575f51

Browse filesBrowse files
joyeecheungItalo A. Casas
authored andcommitted
test: reduce unmanaged parallelism in domain test
The original test lauches 10 child processes at once and bypass `test.py`'s process regulation. This PR reduces the unmanaged parallelism and is a temporary workaround for #9979 (not a real fix). PR-URL: #10329 Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 7822d86 commit 3575f51
Copy full SHA for 3575f51
Expand file treeCollapse file tree

12 files changed

+247
-168
lines changed
Open diff view settings
Collapse file

‎test/common.js‎

Copy file name to clipboardExpand all lines: test/common.js
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,28 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) {
203203
});
204204
});
205205

206+
/*
207+
* Check that when running a test with
208+
* `$node --abort-on-uncaught-exception $file child`
209+
* the process aborts.
210+
*/
211+
exports.childShouldThrowAndAbort = function() {
212+
var testCmd = '';
213+
if (!exports.isWindows) {
214+
// Do not create core files, as it can take a lot of disk space on
215+
// continuous testing and developers' machines
216+
testCmd += 'ulimit -c 0 && ';
217+
}
218+
testCmd += `${process.argv[0]} --abort-on-uncaught-exception `;
219+
testCmd += `${process.argv[1]} child`;
220+
const child = child_process.exec(testCmd);
221+
child.on('exit', function onExit(exitCode, signal) {
222+
const errMsg = 'Test should have aborted ' +
223+
`but instead exited with exit code ${exitCode}` +
224+
` and signal ${signal}`;
225+
assert(exports.nodeProcessAborted(exitCode, signal), errMsg);
226+
});
227+
};
206228

207229
exports.ddCommand = function(filename, kilobytes) {
208230
if (exports.isWindows) {
Collapse file
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}
Collapse file
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}
Collapse file
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}
Collapse file
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}
Collapse file
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}
Collapse file
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}
Collapse file
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}
Collapse file
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}
Collapse file
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.