Utah PHP User Group TestFest Notes

34 views
Skip to first unread message

Mark Niebergall

unread,
Sep 22, 2017, 11:07:02 AM9/22/17
to test...@phpcommunity.org
Hey All,

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 https://phptestfest.org/tutorials/writing-tests-for-php-source/

- 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!

Mark Niebergall
UPHPU President


------------------------
Notes
------------------------

Helpful URLs:

- 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: https://github.com/phpcommunity/phptestfest-php-src/


------------------------

After unzipping a puphpet file for a basic Ubuntu VM, run this from terminal:

vagrant ssh
sudo apt-get update

cd /var/www/html
cd php-src

sudo apt-get install autoconf -y
./buildconf

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 --enable-gcov
make

------------------------

Running tests with either:

- sapi/cli/php run-tests.php -P path/to/test/some_function001.phpt

or better

- make test TESTS="--show-out path/to/test/some_function001.phpt"

------------------------

Running lcov to verify tests cover lines expected:

make clean
make
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):

2. Fork the repo, choose your account
3. git remote set-url origin g...@github.com:mbniebergall/phptestfest-php-src.git
4. git remote add upstream g...@github.com:phpcommunity/phptestfest-php-src.git
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
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!

Chris Spruck

unread,
Sep 22, 2017, 2:13:53 PM9/22/17
to test...@phpcommunity.org
Hi Mark!

Thanks so much for your extensive notes. They'll definitely be a big help!

Chris

--
You received this message because you are subscribed to the Google Groups "PHP TestFest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testfest+unsubscribe@phpcommunity.org.
To post to this group, send email to test...@phpcommunity.org.
Visit this group at https://groups.google.com/a/phpcommunity.org/group/testfest/.
To view this discussion on the web visit https://groups.google.com/a/phpcommunity.org/d/msgid/testfest/CAKWdMuhHSLZN862XL8%3Dg4KrPOdKBvtpTdrDEN1Zx1SirbxWzQQ%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages