User:MarkAHershberger/Weekly reports/2010-W05

= Testing =

At the beginning of week 5, it was becoming obvious that I needed to get other people involved in the unit testing framework I was building. I wondered aloud in my “Raw Notes” — How to do it?

Whether that was the cause or not, by the next weekend, I had a couple of people working on the unit tests and giving me feedback. The TAP-format tests under t/* were all converted to PHPUnit (thanks ialex, maxsem, and demon) and the tests directory had been moved under maintenance/tests. With other people getting more involved, I'm feeling much better about my work there.

I also spent a fair amount of time adding cookie support to HttpFunctions.php so that I could write some automated tests for the Chunked Uploading API (see that section below). This involved tracking down RFCs and blog posts talking about cookie security. I was 2/3rds of the way done with this work when the week ended, so I didn't get to finishing the Chunked Uploading API.

I also spent some time looking at Perl::Critic and thinking about writing or finding a similar tool for PHP. It seems like it would really help in code reviews.

= Parser Tests =

In order to have a single place which would execute all the tests, I also worked on getting PHPUnit to execute each parser test as an individual test. Prior to Week05, the tests were executed as one big blob. This meant that PHPUnit sat quietly for several seconds while all 500+ tests were executed.

To get around this, I borrowed heavily from PHPUnit's Data Driven test example and wrote my own test suite.

However, because of bugs in PHPUnit, bugs in my code, or just my lack of familiarity with PHPUnit, this change caused the tests to consume up to 1 to 2 GB of memory when they were run. (Perhaps this was the problem that got people working on the tests?)

That problem still needs to be fixed although I suspect I won't have much time to spend on it in Week06

= Chunked Uploading API =

I started off the week working on adapting the code to TimStarling's and other commentators. A couple of commentators saw that I hadn't tested the code — even though I tried to make that clear in my commit message — but they saw that the way I was using dieUsageMsg incorrectly.

I did end up getting HttpFunctions.php far enough along to allow API testing, at least API login — as shown with ApiTest.php — but I didn't get any farther than that. I expect to spend this week getting the tests and chunked uploading in shape.

I also sent an email to dale asking what was needed. Thankfully, he told me, only the Chunked Uploading API is needed. The mwEmbed client can be used even if it isn't in the main trunk.

I feel a small reprieve!

= Raw Notes =

1

 * Becoming obvious that I need to get others involved in UnitTesting. How to do it?
 * Worked on dealing with Tim's notes on chunked API
 * Trying to understand if it is PHPUnit messing with global or if it is something re: globals that I just don't understand yet.
 * Currently the parser tests run under phpunit as one big test. Need to do something with a data-driven TestRunner to make each parser test an individual phpunit test.
 * Got lots more comments on my chunked uploading work. I obviously need to get the code tested.  (Look! an emperor without clothes!)
 * Looked at Perl::Critic -- would love to have PHP_Critic to help with Code Reviews.

2

 * Spent time getting HttpFunctions so that it could parse HTTP response headers and maintain a cookie jar. Think I'm ready to start testing the API stuff again.

3

 * Got cookie functions working. Added Cookie tests.
 * Got HttpFunctions capable of testing the API functions -- login at least!

4

 * Worked on making PHPUnit see the parser tests as individual tests. Broke test file parsing into two phases -- read the parser tests, run the tests -- to make this happen, but it broke one test that depended on articles that are also included in the test file ordering.  If I take this a step farther and create an Iterator to read the tests, it should work.