-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Promisification #39
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
Promisification #39
Conversation
You can just use |
Don't know why, but I knew you would say that, haha |
@sindresorhus this PR is ready for you to review, let me know what you think ;) |
@@ -1,8 +1,10 @@ | |||
'use strict'; | |||
var Promise = require('pinkie-promise'); |
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.
Actually. I think it's worth using https://github.com/petkaantonov/bluebird here for performance reasons.
this._timeStart = Date.now(); | ||
return new Promise(function (resolve, reject) { | ||
this.promise.resolve = resolve; | ||
this.promise.reject = reject; |
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 can't really think of a better way right now, but this feels weird.
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, it does. My goal was to switch to promises with a minimum code changed.
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.
Ok. Can you at least add a TODO
in there so it's not forgotten that it needs improving?
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, sure
}.bind(this)); | ||
}.bind(this), cb); | ||
Runner.prototype.serial = function (tests) { | ||
return Promise.resolve(tests).each(function (test) { |
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 inner function can be DRYed up as the Runner.prototype.concurrent
has the exact same function content.
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, thought of that too
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.
Just wanted to get a quick feedback on the PR as a whole
You can also remove |
@sindresorhus Right, good catch, missed that |
The code base is so much cleaner with promises. Excellent work @vdemedes :) Gonna give it a more thorough review tomorrow. Need sleep now. |
Thank you @sindresorhus ;) |
I tried running this on
It seems the (Can you add a regression test for this when fixed?) |
if (err) { | ||
this.stats.failCount++; | ||
} | ||
Runner.prototype.addTestResult = function (test) { |
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 should be a private method, meaning prefixed with _
: Runner.prototype._addTestResult
@sindresorhus Trying to figure out the right way to test |
Using |
@sindresorhus Pushed critical fixes and updated es6 test to use But now we have another problem. There's no continuous output, meaning that all output is displayed at the end, when all tests finish. This happens, because |
First thing that I came up with to fix that is to use |
@sindresorhus Oh my God, I know how to fix this, never mind ;) |
Yeah, let's use |
I came up with a much better solution and without use of |
Here's that change: https://github.com/sindresorhus/ava/pull/39/files#diff-b3b53682a18f203ac8d29b0e277cad26R52. The logic here is to output test results immediately, as they are available. But, use |
👍 for @vdemedes on the project. Lots of great stuff there. |
@sindresorhus @Qix- Thank you, guys! Yes, I am definitely interested in joining AVA! I really like it and would love to contribute more! |
This PR is related to #38. After this PR is complete and callbacks are removed to the maximum extent, AVA's code should be much cleaner.
Overview
As stated in #38,
pinkie-promise
andpify
modules are used in this PR.Changes
Runner.prototype.serial
Runner.prototype.concurrent
Runner.prototype.run
Test.prototype.run
As usual, let me know what you think and let's discuss this!