-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
@requires runtime #1356
Comments
This makes sense to me. Do you want to provide a PR, @marcioAlmada? |
Yes, for sure :D |
PS, did you have a chance to look at #1328? |
Nope, I haven't noticed the mentions. Better to fix that before we continue with the runtime feature :) |
We already support |
@sebastianbergmann's suggestion sounds great to me. I like it. In the OP, @marcioAlmada mentioned support for alternative runtimes:
That won't be possible with the simple approach, as we need to hard-code "PHP" and "HHVM" as possible first parameter names. However, there are only a handful of alternative engines/runtimes, so extensible flexibility wouldn't be warranted either way. People can file PRs if they want support for another engine. |
@sun we could add a RuntimeResolution class to solve both runtime-id and runtime-version in the suggested format. I like the @sebastianbergmann |
Yep, I like @sebastianbergmann's idea too. |
Ok, so the feature will expand current Could we add support for runtime exclusions like this
|
Let's create a separate issue for that. It shouldn't be limited to runtimes; I recently had a similar use-case in which I looked for a "run everywhere except this" — i.e., the reverse of |
@sun I usually try to create small pull requests so we have less friction to add improvements. Your suggestion deviates from that, but I think it would be beneficial. Some annotations are currently hardcoded into constants and regexps, if we are going to support an exclusion DSL everywhere then we need to refactor the hardcoded way phpunit handle those annotations. I still prefer the negation operator instead of an antagonist for
|
I think I prefer something like |
Yes. We're wandering on a very thin line between simple meta data vs. a full-blown macro programming language here. — A In any case, negated requirements are out of scope for this issue; let's move that discussion into a separate issue. (It's possible that there are only a few use-cases, so it might not be worth to implement.) |
@whatthejeff No problem, I switched to whatever-it-takes-to-have-the-full-feature mode :D @sun In case there is no way to negate a if(defined('HHVM_VERSION')) $this->markTestSkipped(); // non HHVM To have a $this->requiresExtension($extension, $version);
$this->requiresRuntime($extension, $version);
// antagonic
$this->skipRuntime($extension, $version); Annotations should be only a thin layer that invokes the PHP API behind it IMMO, so the formal api should come first. At this point |
I agree on having a formal API as well 👍 |
Yes, as mentioned before, I (for one) do agree that "negated requirements" for skipping tests more easily would be nice. However, these are really two, very discrete, and very independent issues:
This issue here is about (1) and shouldn't require many changes. The most minimal approach would be to simply adjust the regular expression in PHPUnit_Util_Test, like this: diff --git a/src/Util/Test.php b/src/Util/Test.php
--- a/src/Util/Test.php
+++ b/src/Util/Test.php
@@ -65,7 +65,7 @@ class PHPUnit_Util_Test
- const REGEX_REQUIRES_VERSION = '/@requires\s+(?P<name>PHP(?:Unit)?)\s+(?P<value>[\d\.-]+(dev|(RC|alpha|beta)[\d\.])?)[ \t]*\r?$/m';
+ const REGEX_REQUIRES_VERSION = '/@requires\s+(?P<name>(?:PHP(?:Unit)?|HHVM))\s+(?P<value>[\d\.-]+(dev|(RC|alpha|beta)[\d\.])?)[ \t]*\ :-) |
@sun I volunteered myself to implement whatever is better, not just apply a hard coded regex tweak and call it a feature. @whatthejeff what do you think of adding the "formal" |
@marcioAlmada Yeah, sounds good. Let's do it :) |
Nice, I'll pull request along the week. |
Awesome :) Thanks, @marcioAlmada! |
+1 on the formal API. |
Would it be possible to add an annotation to skip tests on old runtime versions? Possible API: /**
* @requires PHP < 5.5
*/
public function testSomething() {
// ...
}
/**
* @requires PHP 5.5
*/
public function testSomethingElse() {
// ...
} |
Possibility to define which tests should run only on PHP or only on HHVM would be really great!
Any news on any of that features? |
👍 @keradus |
Any progress on this ? :) |
wow, I completely forgot this thread :) I'm gonna start working on this ASAP Somehow I was unsubscribed and missed your pings. |
HHVM also provides PHP version, which is supposed to be compatible with equivalent PHP from Zend. It would be great to allow test to run under:
|
PHPUnit is only supported on PHP. Therefore I see no point in implementing this. |
So I have some tests that should not run against HHVM runtime and others that should run only with HHVM. This can be easily achieved with:
But would be nice to have a way to skip tests from being run in some contexts following the same pattern as
@requires extension <ext-name>
:The text was updated successfully, but these errors were encountered: