Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Writing Tests for PHP Source - php[tek] 2017

Writing Tests for PHP Source - php[tek] 2017

This talk was given at php[tek] 2017.

This isn’t a talk about adding tests to your PHP codebase, but adding tests to the PHP language itself. And the best part is, all the tests are written in PHP, so you don’t even have to dust off your old C book from college. In this talk, I will show you how to find untested parts of the PHP source code, how to write a test, and how to submit your tests to PHP internals. Just think, even without any C programming, you’ll be able to call yourself an internals contributor.

"TDD is dead": http://david.heinemeierhansson.com/2014/tdd-is-dead-long-live-testing.html
PHP source code on GitHub: https://github.com/php/php-src
runt-tests.php source code: https://github.com/php/php-src/blob/master/run-tests.php
PHP test naming conventions: http://qa.php.net/write-test.php#naming-conventions
Full list of section names: http://qa.php.net/phpt_details.php
PHP source code coverage: http://gcov.php.net/
ext/readline docs: http://php.net/readline
run-tests refactor audit: https://github.com/SammyK/run-tests
Internals discussion on run-tests refactor: https://externals.io/thread/888

Sammy Kaye Powers

May 25, 2017
Tweet

More Decks by Sammy Kaye Powers

Other Decks in Programming

Transcript

  1. $ less test-dt.diff 001+ Boy you know I'm from Europe/Oslo

    001- Boy you know I'm from America/Chicago
  2. joind.in/talk/6c2ad @SammyK #phptek $ less ext/readline/tests/readline_basic.out Fatal error: Uncaught Error:

    Call to undefined function readline() in /Users/SammyK/Developer/php-src/ ext/readline/tests/ readline_basic.php:2
  3. joind.in/talk/6c2ad @SammyK #phptek $ ./configure \ --enable-debug \ --enable-phpdbg \

    --enable-cli \ --enable-cgi \ --with-zlib \ --with-readline
  4. joind.in/talk/6c2ad @SammyK #phptek $ ./configure \ --enable-debug \ --enable-phpdbg \

    --enable-cli \ --enable-cgi \ --with-zlib \ --with-libedit