-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
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: #974 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
- Loading branch information
commit 7b554b1a8ff8d98162fa26e7821b65be3fe7db3d
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() { | ||
|
@@ -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,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(); | ||
}); | ||
}); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL!