UPHPU had a successful PHP TestFest meetup last night. Here are some of my
notes from the meetup.
- I spent quite a bit of time ahead of the meetup prepping, including
watching and following along with Sammy Powers excellent videos at
- I made sure I had a fully working environment and posted my PR prior to
the meetup, which freed me up to help others and helped me know what to do.
I was also able to run lcov for others who had setup issues to confirm
their tests covered what they expected.
- Make sure to clone from and post PRs to
https://github.com/phpcommunity/phptestfest-php-src/ instead of the main
php source repo
- The hardest thing was to find areas needing tests added. Using
http://gcov.php.net/PHP_7_1/lcov_html/ was very helpful, and searching the
c files for 'php_function(' helped find function definitions and identify
where tests were missing.
- We had people with different expertise who helped others out. For
example, those who regularly contributed to open source projects helped
others interacting with the github repos and creating pull requests. This
was really helpful and made things go much smoother.
- We used a slack channel during the meetup to pass around commands, urls,
etc., which turned out to be very useful.
- Look at existing pull requests at
https://github.com/phpcommunity/phptestfest-php-src/pulls and look at other
existing phpt files in the repo to get direction on branch naming, file
naming, test file contets, etc.
- Make sure 'make' and other commands complete successfully when setting up
or else things won't work
At the bottom of this email are my command notes. Using https://puphpet.com/
to build a very basic Ubuntu VM, and with VirtualBox and Vagrant already
installed, I was able to use these commands to get attendees up and running
quickly, which saved an immense amount of time during the meetup. Others in
our group used Docker similar to what Clinton emailed a how-to earlier
about. Our meetup ran for a bit over 2 hours, but people were still working
on things (either lingered longer or went home) for a couple of extra hours.
Thanks Ben, Sammy, and others who helped organize this event and put time
and resources into doing the prep work!
- phpt test files: qa.php.net/phpt_details.php
- Code coverage/finding where to write tests: gcov.php.net
- Github repo for test fest and PRs:
- Sammy's videos:
- Sammy's contributing blog:
After unzipping a puphpet file for a basic Ubuntu VM, run this from
sudo apt-get update
git clone https://github.com/phpcommunity/phptestfest-php-src.git
sudo apt-get install autoconf -y
sudo apt-get install libxml2-dev -y
sudo apt-get install valgrind -y
sudo apt-get install lcov -y
./configure --enable-maintainer-zts --enable-debug --enable-cli-sapi
Running tests with either:
- sapi/cli/php run-tests.php -P path/to/test/some_function001.phpt
- make test TESTS="--show-out path/to/test/some_function001.phpt"
Running lcov to verify tests cover lines expected:
make lcov TESTS=path/to/test/some_function001.phpt
You can just run the "make lcov TESTS=..." for new tests instead of "make
clean" and "make" multiple times. This generates html files locally at
lcov_html/ and then open the index.html page in a browser.
Creating a PR on Github (after setting up ssh keys):
1. Go to https://github.com/phpcommunity/phptestfest-php-src
2. Fork the repo, choose your account
3. git remote set-url origin firstname.lastname@example.org:
4. git remote add upstream email@example.com:
5. git checkout master
6. git checkout -b test-some_function_error
7. git add path/to/test/some_function001.phpt
8. git commit -m "Add test for some_function for some error"
9. git push origin test-some_function_error
10. Go to your fork URL https://github.com/mbniebergall/phptestfest-php-src
11. Click "Compare & Pull Request" button
12. Add a description, including what lines did not have tests and the user
group the tests are from
13. Create the pull request
Hope that helps!