cvs: qaweb / write-test.php
| From: | Derick Rethans | Date: | Sat, 05 Apr 2008 12:17:11 +0000 |
| Subject: | cvs: qaweb / write-test.php | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-64154@lists.php.net to get a copy of this message | ||
derick Sat Apr 5 12:17:11 2008 UTC
Modified files:
/qaweb write-test.php
Log:
- Added some notes by Chris Jones.
http://cvs.php.net/viewvc.cgi/qaweb/write-test.php?r1=1.18&r2=1.19&diff_format=u
Index: qaweb/write-test.php
diff -u qaweb/write-test.php:1.18 qaweb/write-test.php:1.19
--- qaweb/write-test.php:1.18 Wed Feb 13 15:17:58 2008
+++ qaweb/write-test.php Sat Apr 5 12:17:11 2008
@@ -3,7 +3,7 @@
$TITLE = "Writing Tests [PHP-QAT: Quality Assurance Team]";
$SITE_UPDATE = date("D M d H:i:s Y T", filectime(__FILE__));
-/* $Id: write-test.php,v 1.18 2008/02/13 15:17:58 zoe Exp $ */
+/* $Id: write-test.php,v 1.19 2008/04/05 12:17:11 derick Exp $ */
common_header();
?>
@@ -181,6 +181,78 @@
the PHP QA group will review your test and reply to you. They may ask for some changes
or suggest better ways to do things, or they may commit it to PHP.
+
+<h3>Writing Portable PHP Tests</h3>
+
+<p>Writing portable tests can be hard if you don't have access to all
+the many platforms that PHP can run on. Do your best. If in doubt,
+don't disable a test. It is better that the test runs in as many
+environments as possible.</p>
+
+<p>If you know a new test won't run in a specific environment, try to
+write the complementary test for that environment.</p>
+
+<p>Make sure sets of data are consistently ordered. SQL queries are
+not guaranteed to return results in the same order unless an ORDER BY
+clause is used. Directory listings are another example that can vary:
+use an appropriate PHP function to sort them befor printing. Both of
+these examples have affected PHP tests in the past.</p>
+
+<p>Make sure that any test touching parsing or display of dates uses a
+hard-defined timezone - preferable 'UTC':</p>
+
+<pre>
+--INI--
+date.timezone=UTC
+</pre>
+
+<p>Tests that run, or only have have matching EXPECT output, on 32bit
+platforms can use a SKIPIF section like:</p>
+
+<pre>
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only");
+?>
+<pre>
+
+<p>Tests for 64bit platforms can use:</p>
+
+<pre>
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only");
+?>
+</pre>
+
+<p>To run a test only on Windows</p>
+
+<pre>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') die("skip this test is for Windows platforms
only");
+?>
+</pre>
+
+<p>To run a test only on Linux</p>
+
+<pre>
+--SKIPIF--
+<?php
+if (!stristr(PHP_OS, "Linux")) die("skip this test is Linux platforms only");
+?>
+</pre>
+
+
+<p>To skip a test on Mac OS X Darwin</p>
+
+<pre>
+--SKIPIF--
+<?php
+if (!stristr(PHP_OS, "Darwin")) die("skip this test is for Mac OS X platforms
only");
+?>
+</pre>
+
<h2>Examples</h2>
<h3>EXPECTF</h3>