-
Notifications
You must be signed in to change notification settings - Fork 6
Parallel options #2
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
base: master
Are you sure you want to change the base?
Conversation
…rallel by options"
…to insert taskNum before .xml, adding docs
Could you not mix code formatting and functional commits? It makes it makes it very had to read the changes. |
Hi @sebv apologies for that. I have a habit of auto-formatting as I go. I tried to figure out how to change my editor rules to match the style you'd originally used, but couldn't. And I was interested to get your opinion on the substantive changes. When I can sit at my computer for a length of time I'll go carefully through and roll back the stylistic changes. If you're inclined you can use |
lib/index.js
Outdated
@@ -128,18 +134,25 @@ util.inherits(SpawnMocha, EventEmitter); | |||
|
|||
var mochaStream = function mocha(opts) { | |||
opts = opts || {}; | |||
var files = []; |
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 files
related logic is a stream you need to do in your own customs stream, it affects concurrency. To optimize concurrency, you want the default to be splitting the jobs file by file.
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 PR is to base concurrency on the iterations
Array elements as an alternative to file concurrency. Are you concerned that waiting for the gulp.src
stream to end before spawning the mocha processes is going to be a performance drag?
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.
No I am concerned that your code is reverting what gulp.src does. If someone is using gulp.src, it is because they want file by file effect.
It'll be better not to use stream at all in this case, just use node-glob, promises and the spawnMocha object. (That also shows that in my current code, the error handling is at the wrong place.)
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.
Thanks for taking the time to look at this. I apologize that I'm learning as I go here. I'll give
what you've said some thought and try the promises approach.
I added a new exported method to cover this use case. Instead of using promises I used the callback task pattern as mentioned in the gulp docs: https://github.com/gulpjs/gulp/blob/master/docs/API.md#accept-a-callback There is duplicated code between |
Try this pattern, it's better for promise:
Edit: Sorry might not be clear, I try to stay away from callbacks, they don't really scale in complexity, so I keep them to very low level stuff, and wrap them immediately and systematically in promises. |
What do you think of SpawnMocha being its own module? If it is, and has the small changes for |
It already is, there are no dependencies on gulp. |
Yes of course that's true. I've pared down the PR to be the essence of what is necessary to override the |
If
opts.iterations
is defined,mochaStream
will pass along all test files as an array, and executespawnMocha.add
for each iteration array element.This allows parallel behavior where each spawned process operates over the same file/fileset, but each process will differ based on the iteration level "opts" overrides to the top level "opts" object.
Only for those opts properties that it makes sense to override on a per-process basis is the iteration level override used.