-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Mega PR: unhandledRejection, uncaughtException, reliable IO capture, consistent tests. #206
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
Conversation
6585856
to
cfbba40
Compare
// TODO: figure out why this needs to be here to | ||
// correctly flush the output when multiple test files | ||
process.stdout.write(''); | ||
process.stderr.write(''); |
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.
Wut, another one? :p
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.
Yeah, there's 3 of process.stdout.write('')
now for no explained reason.
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.
oops - I meant to delete that other one.
There should be one each stderr
and stdout
. This belongs in the "it seamed to help" pile. Definitely room to experiment with removing it down the road.
Why combine the unhandledRejection/uncaughtException stuff with the rest? Seems it could be a separate PR? Or is there a coupling with the other fixes? |
|
||
var endPromise = Promise.all([promise.reflect(), stdout, stderr]).then(function () { |
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.
This is weird. Why not just wait on ps.on('exit')
?
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.
I've come at this at least 5 times, and every time, it has required all these fixes.
I don't know that I've ever applied this one last, so it could be unnecessary. I can pull it out with another commit and see what happens.
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.
#219 will tell us if this was necessary.
// @vdemedes @floatdrop |
The uncaught exception stuff is definitely coupled. These all started as separate PR's (see description). |
My preference would be to get this merged so everybody can start getting green PR's again. I can then work backwards and see what can be pulled out. Working backwards from green is going to be easier than going the other direction. |
Tests are just too brittle on AppVeyor. `npm install` fails frequently, and Node on Windows does not seem to reliably flush stdout/stderr of forked child processes. I don't like this, but I'm at a loss for other solutions.
cfbba40
to
9611e2f
Compare
9611e2f
to
7ef0503
Compare
7ef0503
to
a156f25
Compare
add small delay on exit from babel (cherry picked from commit 11961f7) if AVA is not required in a test, throw an error instead of process.exit only extend timeout if env.AVA_APPVEYOR is set, so we only slow down in our tests.
29d55cc
to
15bd794
Compare
@sindresorhus I think I can pull it out if you really think it is necessary. I think we will still have reliable builds without it. |
Great work! - reliable builds on Windows is must have. Rough edges can be improved from there. I'm think that unhandled related code (and |
Unfortunately, I committed the I think I did do a pretty good job maintaining a good git history, and have squashed relevant commits together. Perhaps do not squash this PR so |
@jamestalmage no offence at all (sorry if it seems so, English is not my strongest part), really appreciate work you done in |
none taken 😄 The only thing that has offended me during this process is Windows! |
execCli('fixture/uncaught-exception.js', function (err, stdout, stderr) { | ||
t.ok(err); | ||
t.ok(/Can't catch me!/.test(stderr)); | ||
// TODO: This should get printed, but we reject the promise (ending all tests) instead of just ending that one test and reporting. |
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.
For TODO's I prefer to include the username so we know who added it without having to git blame.
TODO(jamestalmage):
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.
cool, I'm assuming you took care of it in the merge? Or do you want me to go handle it now?
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.
I'll do it.
Looks good to me. Let's get this merged asap. Just waiting for @vdemedes to review. |
@@ -18,6 +18,10 @@ module.exports = function (args) { | |||
|
|||
var ps = childProcess.fork(babel, args, options); | |||
|
|||
function send(command, data) { | |||
ps.send({'ava-child-process-command': command, 'data': data}); |
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.
can just be:
ps.send({
name: command,
data: data
});
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.
My only thought there was wether or not we wanted to monkeypatch process.on
on the child process, so users never saw our communication.
I can imagine a scenario where you are writing some code that might be a child process (or might be top level), and so they would will listen to process.on('message')
. By choosing a unique property name here we could monkeypatch on
and filter out these messages. I reemit these on the child process as specific ava-
prefixed events(process.on('ava-kill', ...)
, process.on('ava-cleanup')
, etc) - that it is really unlikely users will listen to.
None of that is implemented. Just leaving the door open.
Mega PR: unhandledRejection, uncaughtException, reliable IO capture, consistent tests.
Landed! Superb work tracking down all these issues @jamestalmage :) I would honestly have just given up and removed AppVeyor :p |
Awesome!
Now you tell me!! 😉 |
Automated Windows testing is especially important for a test runner, though, so glad we have it, regardless of what I feel about Windows. |
Combination of other PR's: #211, #213, #215
It adds the following features:
I have some ideas for refactoring that might make some of this cleaner, but I know there are a number of pending PR's, and I don't want to go crazy until those land.