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
Added --testsuite argument, allowing to filter files/directory by parent testsuite name attribute #495
Conversation
…attribute of their parent testsuite node
I've tested it and it seems fine to me. You shouldn't need to recurse the check as testsuites can't be in testsuites. If anything that check should be only done once outside of the foreaches. if $testSuiteNode->getAttribute('name') does not match $testSuiteFilter return $suite; // the empty suite Also I'd name the argument $testSuiteFilter and not $testSuiteName as its there for filtering. Another point is that the --help entry is missing and maybe it would be nicer to say "contains" instead of "equals" so that you could say "all testsuites named For the test hit me up on irc if you need any help |
"testsuites" tags might not be nestable, but "testsuite" tags are... In the phpunit.xml.dist that Sebastian commited (https://fisheye6.atlassian.com/changelog/zetacomponents?cs=1181653#trunkZ002fphpunit.xml.dist), there is such a structure:
You should see the nested "testsuite" tags here. Although one level nesting is relevant in this case (according to Sebastian's commit), I don't know if more levels of nesting would be. Also:
That would work if that method was called with every testsuite tag as argument. Which is not the case. The reason of that is in here: https://github.com/jpic/phpunit/blob/47c5f6d127fe6cffc7d82274ba425e745cb7b4bd/PHPUnit/Util/Configuration.php#L763 In this loop https://github.com/jpic/phpunit/blob/47c5f6d127fe6cffc7d82274ba425e745cb7b4bd/PHPUnit/Util/Configuration.php#L814 :
$testSuiteNode is Anyway, it's of course improvable as you mentionned a wildcard for example. But you know, YAGNI, I personnaly wouldn't decide to implement it until I actually need it - I would be more likely to do it wrong, trying to implement something I don't need. But if you make it a requirement to accept the pull request then I can implement wildcard support in the name (but why not accept a regexp rather than a wildcard for example ?). Wouldn't that be consistent with --filter ? Then maybe shouldn't we consider another --testsuite-filter (or even --testsuite-name-filter) option ? |
Please tell me how to help you integrate this feature before it conflicts with updates :) |
I'll try to find the time this weekend to look into this. |
+1 from me. I'd like to have a test or two for it ( Especially having a test for nested name testsuites would be needed as I'm quite sure this is going to break at some point in the future if we don't have one for it :) So if you already have a sample for this @jpic please include it :=) |
+1 on this. |
Guys, |
@soid It's on the list of things i want/need to get done for the 3.7 release and getting that feature in with regression testing, documentation (which someone has to write too) and possible clean ups will take at least 4 hours. Time i current don't have for stuff that is not a urgent bug fix but a feature for a future version that I'd much rather test with all the other stuff. My current goal is to get 3.7 out of the door as soon as possible but between having a day job and $personalReasons I currently don't have the time.. you taking a piss / venting some sort of frustration in a rather random place doesn't really help ether |
It's not frustration, I'm just trying to understand why it takes so hard. PS. I'll try to contribute here and we'll write some tests for the feature. I hope it won't hang for months :-D |
I had a chance to look at the code from this request and I can say this is piece of shit.
I'd like to volunteer here and implement it right way. I wouldn't introduce a new argument and would just use existing --filter. I'd store parent testsuite for all tests and suites, and then I'd generate somewhere in PHPUnit_Util_Test::describe() strings like "ParentTestSuite::ChildSuite::TestCase". So it would be possible to use it like --filter=ParentTestSuite::ChildSuite for sorting out suites. How do you think would it work? Or it's better to leave --testsuite option? |
Thanks for the objective review. I don't know what this code did to you but you seem pretty mental about it, so please accept my sincere apologies about that. Please understand that I was just trying to help, not to alienate random people. We don't need this feature anymore so I'm closing the request. |
Sorry for being straightforward. It's just my opinion, I don't really know much about the phpunit code and I can be wrong. |
This is not acceptable behavior. Please refrain from talking like that to people sending contribution to a project you are not involved in.
And cleaned up, and tested, and documented and then someone needs to apologize to the contributor that got insulted but someone hickjacking this pull request.
To be honest: You won't get any special (at least not positive) threatmeant for insulting people and shouting around about project managment in some random pull request you have stumbled upon without even talking to the project maintainer or asking whats up on IRC. @jpic First off: I'm sorry that you got disturbed my this dicussion as it has nothing to do the with pull request: Like stated: This can easily go into 3.7 and I can see the need for the feature (at least it would make testsuites a lot more useable again). So if you don't mind I'd gladly merge it into master once I get around to. P.S so zeta switched their test layout? I'd merge it anyways if thats fine |
Thank you, @edorian for making clear that this kind of language is not appropriate. I have to apologize that I did not step up earlier and make this clear. I, too, still want this feature but of course the implementation has to be clean. I trust your judgement of whether or not to merge this pull request. |
The components move from having a single repo with a single phpunit.xml.dist to being each in its own repo with each it's own phpunit.xml.dist. I love this decision. This means that the components project might become an open coding standard rather than a commercially supported set of libraries. We all have our bad days so I'm cool. Probably we all humiliated ourselves on a forum once in our lives, no big deal B) |
My apologies for being rude. I'm still learning English and definitely didn't get what I said :-) Just wanted to be straightforward. I'm glad the request has moved on and @edorian decided to merge the request. It's what I was talking about. But I think some code-tuning should be done here and I'd like to volunteer. I'll try to catch you in IRC. |
Allright, here's my approach. I believe the right way to filter out the suites is to place the logic in PHPUnit_Framework_TestSuite::run() where phpunit runs all tests. It's akin to existing --filter option but extends it and filters testsuites too. I have one concern: $parent member isn't introduced in PHPUnit_Framework_Test and set dynamically in PHPUnit_Framework_TestSuite::addTest(). As PHP interfaces can't specify members it would require to introduce something like getParent() and setParent() and its implementation for all classes implemented PHPUnit_Framework_Test so the change would broke many code implemented PHPUnit_Framework_Test (outside phpunit). What do you link about it? |
I don't like the approach taken in your pull request. It puts additional complexity in the --filter parameter and since we only have one it would not be possible to say "All tests with 'mysql' from testsuite 'db' " which would be one of the usecases I see. That could maybe solved with allowing multiple filter arguments but it would (I'm guessing) lead to a lot more false positives. Apart from that it's a BC issue that might not hit a view people but it's something to take into account. For me @jpic seems a lot cleaner, better documented, less error prone and more fitting for the use cases i see. |
I don't have preferences about either to use the new --testsuite option or including the logic in the --filter. However my main concern regarding the first commits that it's working only when testsuites configuration set in XML file.
So what do you think if I would introduce --testsuite option again but it would match testsuites like --filter option does but only in testsuite names? I would also leave the ability to filter hierarchical suites but it's not what I really need as I need the ability to filter testsuites. It's just nice to have feature so if you don't like that parent-child relations I introduced for suites then I can remove it. Also I'm not sure whether the new testsuite option should match regex as the filter option does. I'd like to do it as regex because: 1. it's more flexible, 2. it's how --filter works so they would work equally. What do you think about it? |
Good points about the xml config. The reason i didn't care is that the feature is deprecated anyways (even so we might make that clearer) but it was removed from the docs quite some time ago. Because of that i was fine with it only working for the xml config :) having --testsuites work like --filter would be great. I agree on that. |
Added --testsuite argument, allowing to filter files/directory by parent testsuite name attribute
@jpic Thanks a lot for the patch and again: sorry for how the discussion went. |
Excellent! When are you guys expecting to release a new version? I need this pretty bad. |
@grahamc The milestone for the next release is here: https://github.com/sebastianbergmann/phpunit/issues?milestone=8&page=1&state=open I'll work on all outstanding issues but I, sadly, can't make any promises. You could run this from the git checkouts or just patch your locally installed version. Apart from that there will be a 3.7-beta-phar somewhere down the line. |
Thank you! Graham Christensen On Wednesday, May 9, 2012 at 4:23 PM, Volker Dusch wrote:
|
Before, we could run the test suite of a component as such: UnitTest/src/runtests.php Database
But the new test runner does not allow this. For example, consider this phpunit.xml.dist: https://fisheye6.atlassian.com/browse/zetacomponents/trunk/phpunit.xml.dist?hb=true
Phpunit --filter Database will not behave as expected in two ways:
As a more alarming example: --filter MvcTools runs 124 tests, wheras --testsuite MvcTools runs 168.
Credit to Derick Rethans who participated in this little task. Long live the Components !
(this is a follow up to: #494)