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

Implement async. WIP #439

Closed
wants to merge 1 commit into from
Closed

Conversation

DorianGray
Copy link
Contributor

No description provided.

@DorianGray
Copy link
Contributor Author

Currently, only IT blocks have async. More to follow. I need to figure out how to make blocks work properly with disconnected block ends.

@DorianGray
Copy link
Contributor Author

@o-lim @ajacksified , please review.

@o-lim
Copy link
Contributor

o-lim commented Jul 7, 2015

I'm not sure what you mean by disconnected block ends. Wouldn't you just add async to it/setup/teardown/before_each/after_each blocks? Wouldn't you just call the event loop inside the block after it returns from busted.safe(descriptor, element.run, element)? async just means that the test or block depends on asynchronous inputs, right? So, it's not like you should start executing the next block/test until the current block/test completes.

Maybe something like:

    local async, evloop
    element.env.async = function(loop)
      async = true
      evloop = loop
      element.env.done = done.new(loop.stop)
    end
    if pass then
      local status = busted.status('success')
      if busted.safe_publish('it', { 'test', 'start' }, element, parent) then
        status:update(busted.safe('it', element.run, element))
        if status:success() then
          status:update(busted.safe('it', evloop.run, element))
        end
        if finally then
          block.reject('pending', element)
          status:update(busted.safe('finally', finally, element))
        end
      else
        status = busted.status('error')
      end
      busted.safe_publish('it', { 'test', 'end' }, element, parent, tostring(status))
    end

Did you want to return done instead of injecting it into the environment? Since done is not available until you call async, it might make more sense to return done in order to avoid possible confusion.

@DorianGray
Copy link
Contributor Author

Yeah, I did want to return done. I'm glad someone else is on board with that, I got some negative feedback when I suggested it earlier. I'm going to take another pass at this this week and see if I can nail this down finally.

@ajacksified
Copy link
Contributor

ping @DorianGray :trollface:

@adriweb
Copy link

adriweb commented Sep 22, 2016

Any news about this? :)

@DorianGray
Copy link
Contributor Author

None. I have no time. Someone else please feel free to open a PR.

@adriweb
Copy link

adriweb commented Sep 22, 2016

Aww that's too bad - indeed with the current patch here the tests just seem to go on without waiting on the async one's completion.
Thanks for the quick reply though.

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

Successfully merging this pull request may close these issues.

4 participants