Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Adding support for parallel execution of examples #1526

Closed
wants to merge 2 commits into from
Closed

Adding support for parallel execution of examples #1526

wants to merge 2 commits into from

Conversation

bicarbon8
Copy link

These changes add handling of an additional parameter "--parallel-test" that takes a number as input. This number will then be used to limit execution of examples to the specified number of parallel threads. To accomplish this the ExampleGroups each are started in a sub-thread which can then start up to the specified number of example threads running in parallel. A global maximum is used to prevent going over the specified number and execution of additional threads will wait until an available thread is free for cases where the maximum number of parallel threads are in use.

Additionally, these changes ensure that Before / After Suite and Before / After All calls are executed only once per expected grouping, but that Before / After Each calls are executed before and after each example as part of the parallel thread.

The advantage of this change is that it fully supports all platforms supported by rspec (unlike parallel_tests gem which does not work correctly on all Windows systems) and the output remains serially reported so you avoid the need to stitch together test reports at the completion of testing (as can be required with solutions like parallel_tests and prspec gems where parallel execution is actually split between multiple instances of rspec).

@myronmarston
Copy link
Member

@bicarbon8 -- thanks for the PR. We're focused right now on shipping 3.0 RC1 and since this is a new feature and doesn't fit into our plans for 3.0 (although we had something similar slated for 3.1 -- see rspec/rspec#7) we're probably not going to get around to reviewing it until 3.0 has shipped in a few weeks.

@JonRowe
Copy link
Member

JonRowe commented May 12, 2014

Also as an aside, we wouldn't back port this to 2-14-maintenance so it needs to be targeted to master.

@JonRowe JonRowe closed this May 12, 2014
@bicarbon8
Copy link
Author

Thanks for the comments. I knew in submitting this that it was a bit of a long shot to get it into a maintenance branch. Would you be open to my attempt at the same for the master branch? I had originally investigated making the changes there, but because I'm actively using v2.14 I went with it instead. Shouldn't be too difficult to make a similar change to master, though I know some of the stuff around example groups seems to have changed for the better there.

@JonRowe
Copy link
Member

JonRowe commented May 13, 2014

Very much so. The only reason I closed it is that 2.14 has been feature
frozen for a while.

You should be able to upgrade your specs easily to 3.x by upgrading to
2.99.beta2 then 3.0.0.beta2.

For there you should find things mostly compatible with master which is
very near to rc1 of 3.0.0.

Although we call it a beta it's very stable and you should have no
difficulties with it.

On Tuesday, 13 May 2014, bicarbon8 [email protected] wrote:

Thanks for the comments. I knew in submitting this that it was a bit of a
long shot to get it into a maintenance branch. Would you be open to my
attempt at the same for the master branch? I had originally investigated
making the changes there, but because I'm actively using v2.14 I went with
it instead. Shouldn't be too difficult to make a similar change to master,
though I know some of the stuff around example groups seems to have changed
for the better there.


Reply to this email directly or view it on GitHubhttps://github.com//pull/1526#issuecomment-42926118
.

@bicarbon8
Copy link
Author

Thanks @JonRowe
I've tried running with the 3.0.0 Beta 2 build, but it seems that the RSpec::Support.require_rspec_support method doesn't exist in this version (called in core.rb, line 5)... is there something else I need to update?

EDIT
seems the rspec-support 3.0.0 Beta2 version on rubygems doesn't have the correct methods, but the one on github does so I've just used that instead.

@JonRowe
Copy link
Member

JonRowe commented May 13, 2014

If you're running a master gem they all need to be master (core mocks
expectations and support)

On Tuesday, 13 May 2014, bicarbon8 [email protected] wrote:

Thanks @JonRowe https://github.com/JonRowe
I've tried running with the 3.0.0 Beta 2 build, but it seems that the
RSpec::Support.require_rspec_support method doesn't exist in this version
(called in core.rb, line 5)... is there something else I need to update?


Reply to this email directly or view it on GitHubhttps://github.com//pull/1526#issuecomment-42935982
.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants