Skip to content
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

Deferred execution (2014) #1124

Closed
wants to merge 2 commits into from
Closed

Deferred execution (2014) #1124

wants to merge 2 commits into from

Conversation

reid
Copy link

@reid reid commented Feb 3, 2014

This is @tarruda's #719 pull request from last year updated to cleanly merge. All tests pass.

From the original request:

This should solve issue #362.

A global 'wait' function is added so the test files can pause mocha processing and generate
tests asynchronously. The function returns a semaphore with a single method 'resume' to continue processing test files.

@travisjeffery This pull request implements TJ's suggestion for fixing #362 and includes a test. Can this be included in Mocha? Deferred execution has inspired Mocha forks and prevents test runners like Yeti from running async-defined Mocha tests. Thank you!

/cc @alex-seville

tarruda and others added 2 commits January 17, 2013 08:38
This function signals mocha to pause processing files while tests are
generated asynchronously.

For this to work, a few changes were required in the Mocha and Runner classes:

- In the Mocha class, the 'loadFiles' method was refactored to work
  asynchonously.
- In the Runner class, the globals initialization was moved out of the
  constructor into a new method: 'initDefaultGlobals'. This method needs
  to be invoked prior to running the tests, so the runner will take a
  'snapshot' of the global properties.

This commit should also solve issue mochajs#362
@travisjeffery
Copy link
Contributor

looks good mostly, i'm not so sure about having the wait fn on global

@alex-seville
Copy link

👍

This will help address some compatibility issues in Blanket as well.

The wait fn does get removed from global, fwiw - https://github.com/visionmedia/mocha/pull/1124/files#diff-aa849a970cef551664c12f04a4209f6fR188.

@alex-seville
Copy link

Bump?

@NickHeiner
Copy link

This would be nice to have. On my team, we basically have a rule to never generate tests asynchronously because it isn't supported.

@chrismeyersfsu
Copy link

Bump

@nnnnathann
Copy link

Also, bump.

@arcanis
Copy link

arcanis commented Jun 22, 2014

The PR doesn't seem too big. Is there something holding the merge, @visionmedia ?

@jbnicolai
Copy link

@travisjeffery any objections to merging?

@travisjeffery
Copy link
Contributor

i'd rather add an option to Mocha and then use the existing run api. same with tj

@reid
Copy link
Author

reid commented Jul 18, 2014

@travisjeffery How would we set this "async" Mocha option on a per-test basis (or browser usage)? mocha.wait(), which returns the semaphore?

By "existing run api" I assume you mean mocha.run()? I think it makes more sense to call resume on the object returned by something like wait() or mocha.wait(). Am I mistaken? (I didn't find anything in the documentation page linked from the README, but that's what TJ mentioned 2 years ago.)

@boneskull boneskull added the status: waiting for author waiting on response from OP - more information needed label Oct 17, 2014
@travisjeffery travisjeffery force-pushed the master branch 2 times, most recently from 35c1580 to 64dfc0b Compare October 22, 2014 04:56
@okv
Copy link

okv commented Oct 28, 2014

bump

@okv
Copy link

okv commented Oct 29, 2014

It's really very usefull feature when you need to do some async stuff (e.g. get test data from db which will be used at describe labels) before test will be loaded by mocha. Do you have any plans about merging it into master?

@boneskull boneskull added Duplicate and removed status: waiting for author waiting on response from OP - more information needed labels Nov 21, 2014
@boneskull boneskull closed this Nov 21, 2014
@boneskull
Copy link
Contributor

this won't get merged; see #1439

boneskull pushed a commit to boneskull/mocha that referenced this pull request Feb 16, 2015


modifies http tests to avoid race conditions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.