-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add randomization support #1512
Conversation
I'll take a look at Node.js 0.8 later (which is causing the Travis error). |
affba74
to
22e2c13
Compare
man those added apis are nastyyyy :S |
i'm not really keen on this being in mocha |
@travisjeffery you mean those |
It would be desirable to discuss/design the API before hand in the issue. :/ |
@dasilvacontin well I did comment on the issue but nobody responded: #902 (comment) |
@TimothyGu, sorry, I'm quite busy until mid-Feb, and since I tend to not open slack anymore I miss a lot of convs/threads. |
@dasilvacontin It's all good, just wanted to point out my comment |
it's not the api, i just don't think it's needed in mocha |
@travisjeffery You mean the feature? Well #902 is tagged as "PR PLEASE" |
@travisjeffery pretty much everyone in the issue agreed it would be helpful, even @boneskull. At the very least we could leave it in a plugin. |
@travisjeffery It's probably not something I'd use, but many people want this. |
all kinds of people want kinds of stuff, not really a great argument for anything imo. it would be sweet if we could add enable this feature as an external plugin however |
Well again I just implemented it because it looks doable, fun, requested, and tagged as "PR PLEASE." If you disagree with doing it in Mocha, I would seriously think that you guys should clean up the issues tagged as PR PLEASE first, AND possibly close #902. Personally, I do not care about this feature. It is likely that I will not even ever use this feature. I just did it for the good of the community, and as it looks like that the feature is requested by multiple people and looks useful. I am not inclined to do further work on it if it is not appreciated, nor am I motivated enough to turn it into a plugin (even less so when there is literally zero documentation on doing so anywhere I could find). |
I said:
Ah now I understand why, because the plugin framework doesn't even exist. |
No time to pull them out. Extracting the reporters (especially these reporters) from the core is on the TODO list. |
There was even an initiative to make framework-independent reporters, but guess how that is going. :) |
As @TimothyGu said, no such thing exists. So in the meantime, I'm happy to add one of the most requested features, which is why this was tagged |
If one random dude wants one random thing, then probably not. This is not one of those, however. If I had more time to dedicate to this, I'd try to give the most requested features attention, and add them, if I agree they belong somewhere in this framework. But I don't have the time, and we don't have the luxury of saying x feature should be in core, and y should be a plugin, because we have no plugin API. So we have @TimothyGu who takes the time to do it. I haven't even had a chance to look at the PR, but if it looks good, I'd like to merge it. |
This is not necessary. |
Same thoughts here, @boneskull. I tend not to express myself much, maybe I should do it more often. |
We definitely appreciate the work you've put into the PR, @TimothyGu, in case it is not clear. Once it looks good, we will merge it into core. And once we have a stable Plugin API, we will debate whether to export it into a plugin. |
@boneskull and @dasilvacontin, I appreciate your constructive comments. |
@dasilvacontin @boneskull ping? I will rebase the PR if you guys can take a look at it first. |
*/ | ||
|
||
Suite.prototype.enableRandomize = function(enabled){ | ||
if (arguments.length === 0) return this._enableRandomize; |
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.
It feels to me that executing this.enableRandomize()
in a suite should enable randomize, but it doesn't, right?
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.
Nvm, without arguments it's used as a getter... I think it would be bad to see .enableRandomize()
around being used as a getter – not logical at all.
The PR is lacking tests asserting that It would also be nice to have a test suite that we run with a fixed seed, and check if the order of test execution is correct. And another one with a non-defined seed that just checks the tests are not run in the order they are described (it can still fail, but the probability is very low). |
@TimothyGu Sorry busy as hell atm. Should have some time tomorrow |
Also, are suites inheriting |
@dasilvacontin said:
I know, hence the TODOs in the first comment of the thread. |
@TimothyGu Oh sorry, I didn't re-read that part and just went on giving overall review of the PR. |
|
||
Runner.prototype.randomize = function(mode, seed){ | ||
debug('randomize mode: "' + mode + '"; seed: ' + seed); | ||
if (mode !== 'tests') return this; |
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.
Is this temporary?
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.
Yes, as for now only tests can be randomized.
Any update, @TimothyGu? |
@dasilvacontin I've been fairly busy with other stuff recently, but I'll take a look at the suggestions soon (I hope). |
No worries. :)
|
@TimothyGu not saying anyone will do this, but I'd like to get some traction on it; do you mind if me or someone else grabs your branch and makes changes? |
@boneskull not at all, as long as maybe I'm credited for an initial implementation. |
@boneskull 👍 if you'd like to pick this up. Great feature to have :) |
2f458ab
to
2952eca
Compare
I'm going to see what I can do with this. |
@TimothyGu I will need to close this PR and create a new one, but your name will be on at least one commit here. |
Alright, thanks. |
Big Fat Warning
This is a WIP. I just wanted to throw the idea out there and see if there's any feedback before I start writing tests and docs.
How to use it?
The array shuffling is done with the knuth-shuffle-seeded, my fork of knuth-shuffle that supports seeding.
If your test needs to be tested in a particular order, add
noRandom
:noRandom
plays nicely with other modifiers (although I admit the implementation is a little ugly):Current state
Currently it only supports test-level randomization (
mode === 'tests'
), which means that only the order of tests within a suite is randomized.TODO
Fixes #902.