UEXPECTF is gone: any way to write "portable" tests?

From: Date: Tue, 22 Jul 2008 20:00:35 +0000
Subject: UEXPECTF is gone: any way to write "portable" tests?
Groups: php.qa 
Request: Send a blank email to php-qa+get-64387@lists.php.net to get a copy of this message
Hi, as far as I know UEXPECT[F] is history. run-tests.php does not support it any more as PHP 6 always returns unicode strings and not binary strings. UEXPECT[F] has been introduced to handle the formerly two different run modes of PHP 6: unicode and non-unicode. However, I used it to write portable tests: tests that can be run with PHP 5 and PHP 6. PHP 5 (and PHP 6 when run in non-unicode mode) did check the EXPECT[F] sections and PHP 6 did check the UEXPECT[F] sections. One test file for both PHP 5 and PHP 6 - cool thing. mytest.phpt EXPECT[F] ---> PHP 5: string(3) "PHP" (= earlier PHP 6 non-unicode mode) UEXPECT[F] ---> PHP 6: unicode(3) "PHP" (= todays PHP 6 unicode only mode) Meanwhile UEXPECT[F] is gone. For every test that uses print_r()/var_dump() etc. we now need two copies of the test as the output of the test runs will differ: PHP 5 mytest.phpt
    EXPECT[F]
    string(3) "PHP"
PHP 6 mytest.phpt
    EXPECT[F]
    unicode(3) "PHP"
I wonder if it wouldn't be easier to have just one version of a test, one file. It seems that there's no way to write one test and I have to keep two only marginally different versions in sync. I'm asking because: nixnutz@ulflinux:~/php6> ls -la ext/mysql/tests/*.phpt ext/mysqli/tests/*.phpt ext/pdo_mysql/tests/*.phpt | wc -l 480 That's 480 * 2 = 960 files to keep in sync. And some of them do already have proper UEXPECT[F] sections: nixnutz@ulflinux:~/php6> ls -la ext/mysql/tests/*.phpt ext/mysqli/tests/*.phpt | wc -l 393 Any chance to make run-tests.php (HEAD) check if a UEXPECT[F] section is there and if so, let PHP 6 use UEXPECT[F] instead of EXPECT[F]? Such a change should not hurt any existing tests. But test writers would be given a tool to create "portable" tests that run with PHP 5 and PHP 6. This means maintaining just one file and not two. It makes "MFH" a thing you can do without turning your brain on. Ulf

« previous php.qa (#64387) next »