atoum / ruler-extension

The atoum ruler-extension allows you to filter your tests using Hoa\Ruler.
MIT License
9 stars 4 forks source link

add filter on php version constraint #23

Closed agallou closed 8 years ago

agallou commented 8 years ago

We will now be able to limit the tests launched, on the php version constraint.

For exemple : phpVersionConstraint.containsGte("7.0").

jubianchi commented 8 years ago

@agallou could you add a changelog entry please ?

Hywan commented 8 years ago

Sorry but the API looks horrible :-/. Why not simply: php >= 7 instead of phpVersionConstraint.hasGte(7)? This is almost unreadable :-(.

agallou commented 8 years ago

@Hywan there could be more that one php version constaint on an atoum test.

Hywan commented 8 years ago

@agallou php >=7 and php < 7.2?

agallou commented 8 years ago

In the test, the constaint could be :

/**
 * @php >= 7.0
 * @php <  7.2
 */

or :

/**
 * @php = 5.5
 * @php =  7.0
 */

For now, the PR filters on the constraint not the php version were the test could be executed. We search if the test has in the pphdoc the constraint provided in the filter.

@Hywan could you explain what the php >=7 and php < 7.2 filter will do ?

Hywan commented 8 years ago

@agallou It will select the test cases with @php >= 7.0 @php < 7.2 constraints.

agallou commented 8 years ago

I don't see how we can achive that kind of filter. We have to constraint (the one in atoum and the one passed to the ruler), and no finite list of PHP versions.

Hywan commented 8 years ago

@agallou Yes, that would be difficult without overloading the <, > & co. operators. But, what about a php_version function instead? Like this: php_version('>', 7.0) for instance… hmm, it reads bad. I don't know how to do exactly, but phpVersionConstraint.hasGt looks horrible for me :-/. Am I the only one?

agallou commented 8 years ago

has seen or IRC, there is no concrete case. We'll reopen it when it will be the case.

jubianchi commented 8 years ago

Even if I think the feature is interesting, it has to be well crafted. The proposed API is not my main concern here.

Look, when a test is tagged with some PHP version it means it can only run on those specific versions. It makes no sense to filter on test targeting php >= 5.5.0 when we run a PHP 5.4 CLI for example.

To me, the only valid use case would be a filter to only run test tagged with the currently used PHP version: if I run a 5.5 CLI, it will only run test matching this version.

BTW, if you still want this feature, here is what I propose to clean the arguments: --filter 'phpVersion includes "7.0.1"' which will run all tests with a constraint including the provided version.