ciscoheat / buddy

Your friendly BDD testing library for Haxe!
MIT License
96 stars 24 forks source link

PHP Async Support #32

Closed jasononeil closed 9 years ago

jasononeil commented 9 years ago

I have interest in making async tests work on PHP.

I understand that PHP doesn't support true async, but my use case is:

Anyway, this is all fine, but the async tests don't work because promhx doesn't support PHP.

So my question: what would be the best approach to support pseudo-async PHP tests in Buddy:

  1. Work around the need for promhx on PHP
  2. Go ask @jdonaldson how to make Promhx work on PHP?
ciscoheat commented 9 years ago

I've made a little effort in the beginning to make async work with PHP, but decided it wasn't worth the time. I'm simply using #if !php for those parts.

ciscoheat commented 9 years ago

PHP simply refuses to play nice, but is it the same for Neko? I had no problem with async tests there.

ciscoheat commented 9 years ago

I mean that I'm using Thread.create and Sys.sleep on Neko, and it seems to be async, not just pretending? Btw, here's the code I'm using for the async tests: https://github.com/ciscoheat/buddy/blob/master/src/buddy/tools/AsyncTools.hx Quite platform-specific, and PHP just doesn't work, so I dropped that effort.

jasononeil commented 9 years ago

Haha okay, so if I want this to work I had better get prepared to do the dirty work myself :)

You're right that neko is similar and generally synchronous, but it has the neko.vm.Thread API, which Haxe PHP doesn't have.

A quick question: do you actually run multiple tests at the same time, or does it wait (asynchronously) for one test to complete before starting the next one?

jasononeil commented 9 years ago

(p.s. Closed the issue. If I get a solution I'll open a pull request)

jasononeil commented 9 years ago

Just saw your other comment. That makes sense. Yes if you're using threads then neko is "real" async. And I don't think PHP supports threads without extensions, so Haxe/PHP doesn't bother to provide an API.

Would you be open to a pull request that gets PHP working with "fake" async? So the async code works, the done() callback works etc, but they are all executed synchronously, without threads. I feel like that's a workable approach for my problem.

If you'd prefer not to have that in the code let me know and I'll move on.

ciscoheat commented 9 years ago

It sounds interesting, but before you do any work I'm curious about your approach, since I've looked at the issue before and couldn't make it work. Promhx works in general for PHP (as 90% of the tests pass), but things like timeoutMs doesn't make much sense in a sync environment.

ciscoheat commented 9 years ago

(To answer your previous question: The tests are run one at a time, no parallel processing is done)

jdonaldson commented 9 years ago

php is busted for me too :(

I haven't looked closely into it. This seems like a good opportunity to bother @fponticelli