cvs: qaweb / autogenerate.php
| From: | Zoe Slattery | Date: | Thu, 07 May 2009 09:16:49 +0000 |
| Subject: | cvs: qaweb / autogenerate.php | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-64882@lists.php.net to get a copy of this message | ||
zoe Thu May 7 09:16:49 2009 UTC
Modified files:
/qaweb autogenerate.php
Log:
Changed documenation for new version
http://cvs.php.net/viewvc.cgi/qaweb/autogenerate.php?r1=1.1&r2=1.2&diff_format=u Index: qaweb/autogenerate.php diff -u qaweb/autogenerate.php:1.1 qaweb/autogenerate.php:1.2 --- qaweb/autogenerate.php:1.1 Wed Feb 13 15:17:58 2008 +++ qaweb/autogenerate.php Thu May 7 09:16:49 2009 @@ -3,7 +3,7 @@ $TITLE = "Generating tests [PHP-QAT: Quality Assurance Team]"; $SITE_UPDATE = date("D M d H:i:s Y T", filectime(__FILE__)); -/* $Id: autogenerate.php,v 1.1 2008/02/13 15:17:58 zoe Exp $ */ +/* $Id: autogenerate.php,v 1.2 2009/05/07 09:16:49 zoe Exp $ */ common_header(); ?> @@ -12,8 +12,8 @@ Although it's not possible to generate a complete PHPT test, it's quite easy to generate the standard sections and some simple functions automatically, creating a test case "frame". To do this, you need: <ul> -<li> A copy of the PHP source (download from the <a href="http://snaps.php.net">snaps site</a> ) -</li> <li> A copy of the generate_phpt.php code in from scripts/dev +<li> A build pf PHP53 +</li> <li> The file generate-phpt.phar, located in the PHP53 source under dev/scripts </li></ul> <p /> @@ -23,40 +23,30 @@ <p /> <div class="fragment"><pre> --TEST-- -Test cos() : basic functionality +Test function cos() by calling it with its expected arguments --FILE-- <?php -<font color="green">/* Prototype : proto float cos(float number) -* Description: Returns the cosine of the number in radians -* Source code: ext/standard/math.c -* Alias to functions: -*/</font> -<font color="green">/* -* add comment here to indicate details of what this testcase is testing in particular -*/</font> -<font color="maroon">echo</font> "<font color="blue">*** Testing cos() : basic functionality ***\n</font>"; +echo "*** Test by calling method or function with its expected arguments ***\n" +$number = -<font color="green">// Initialise all required variables</font> -$number = 10.5; -<font color="green">// Calling cos() with all possible arguments</font> -var_dump( <font color="maroon">cos</font>($number) ); + +var_dump(cos( $number ) ); -<font color="maroon">echo</font> "<font color="blue">Done</font>" ?> --EXPECTF-- -Expected output goes here -Done</pre></pre></div> + +</pre></pre></div> <p /> <p /> <p /> <h3>Completing the .phpt test file: </h3> <p /> -To turn this into a complete test case, all the developer has to do is to change the value of $number to something reasonable +To turn this into a complete test case, all the developer has to do is to initialise $number to something reasonable and to add a section for the expected output. <p /> @@ -64,160 +54,28 @@ <p /> <h3> Command syntax </h3> <div class="fragment"><pre> -php generate_phpt.php -s <php_source_dir> -f <function_name> -b|-e|-v [-i <include_file>]</pre></pre></div> -<p /> -<p /> - -<p /> +php generate-phpt.php -f <function_name> |-c <class_name> -m <method_name> -b|e|v [-s skipif:ini:clean:done] [-k win|notwin|64b|not64b] [-x ext] +</pre></div> <h3> Options </h3> Use -h to list them, this is the output: <p /> <div class="fragment"><pre> --s location_of_source_code ....... Top level directory of PHP source -f function_name ................. Name of PHP function, eg cos --b ............................... Generate basic test --e ............................... Generate error test --v ............................... Generate variation test(s) --i file_containing_include_block.. Block of PHP code. If <font color="brown">this</font> option is present no code will be generated. --h ............................... Print <font color="brown">this</font> message</pre></pre></div> -<p /> -<p /> - -The following sections describe each argument: -<p /> -<p /> -<p /> -<p /> -<h3>PHP source code location ( -s <php_source_dir> ) </h3> -<p /> -The test case frame generation script depends on being able to find the function prototype in the -PHP implementation code - this is used to generate simple calls to the function. PHP source is most -easily obtained by downloading from the <a href="http://snaps.php.net/">snaps site</a>. The test generation script -expects to be given the name of the top level directory. In the following example, -the subdirectory <strong>/home/zoe/BUILDS/php524</strong> contains the complete source for php-5.2.4. - -<p /> -Example: <ul> -<li> Generate a basic test case frame for the xxx() function -</li></ul> -<div class="fragment"><pre> -php generate_phpt.php -s /home/zoe/BUILDS/php524 -f xxx -b</pre></pre></div> -<p /> -<p /> -<p /> -<p /> -<p /> -<h3>Function name ( -f <function_name> ) </h3> - -<p /> -The code will generate a test case frame for a given function. -<p /> -<p /> -Example: <ul> -<li> Generate a basic test case frame for the cos() function -</li></ul> -<div class="fragment"><pre> -php generate_phpt.php -s /home/zoe/BUILDS/php524 -f cos -b</pre></pre></div> -<p /> -<p /> -<p /> -<p /> -<p /> - -<p /> -<h3>Test Types ( -b | -e | -v ) </h3> -<p /> -<p /> -<p /> -<h6> Basic ( -b ) </h6> -<p /> -<p /> -<p /> -This will generate test case frame(s) called <function_name>_basic.phpt. They will have <ul> -<li> A title - -</li> <li> Prototype and implementation location -</li> <li> Description -</li> <li> List of any alias functions -</li> <li> Initialise the number and type of arguments that the function requires -</li> <li> var_dump (function (args)) -</li></ul> -<p /> - -Example: <ul> -<li> Generate a basic test case frame for the asin() function -</li></ul> -<div class="fragment"><pre> -php generate_phpt.php -s /home/zoe/BUILDS/php524 -f asin -b</pre></pre></div> -<p /> -<p /> -<p /> -<h6>Error ( -e ) </h6> -This will generate test case frame(s) called <function_name>_error.phpt. They will have <ul> - -<li> A title -</li> <li> Prototype and implementation location -</li> <li> Description -</li> <li> List of any alias functions -</li> <li> Initialise the number and type of arguments that the function requires -</li> <li> var_dump (function (args + 1)) - ie. tests for too many arguments - -</li> <li> var_dump (function (args - 1)) - ie. tests for too few arguments -</li></ul> -<p /> -Examples: <ul> -<li> Generate an error test case frame for the hexdec() function -</li></ul> -<div class="fragment"><pre> -php generate_phpt.php -s /home/zoe/BUILDS/php524 -f hexdec -e</pre></pre></div> -<p /> -<p /> -<p /> -<p /> - -<p /> -<h6>Variation ( -v ) </h6> -This will generate test case frame(s) called <function_name>_variation.phpt. They will have <ul> -<li> A title -</li> <li> Prototype and implementation location -</li> <li> Description -</li> <li> List of any alias functions - -</li> <li> Code to cycle through each argument in the function call setting it to a different type and then calling the function. -</li></ul> -<p /> -<p /> -Examples: <ul> -<li> Generate a variation test case frame for the cosh() function -</li></ul> -<div class="fragment"><pre> -php generate_phpt.php -s /home/zoe/BUILDS/php524 -f cosh -v</pre></pre></div> -<p /> -<p /> -<p /> - -<p /> -<p /> -<p /> -<p /> -<h6>Include blocks ( -i <include_file> ) </h6> -<p /> -It's often the case that the PHP code for the test case has already been written and tested, so all that the author needs to do is -to turn it into standard PHPT format. In this situation, generate_phpt.php should be called with the additional -i option and -given the name of a file which includes the PHP code for the relevant test-case. -<p /> -<p /> -Example: <ul> -<li> Generate a variation-type test case frame for the tan() function, and include a block of php code taken from the -file <strong>my_tan_test</strong> - -</li></ul> -<div class="fragment"><pre> -php generate_phpt.php -s /home/zoe/BUILDS/php524 -f tan -v -i my_tan_test</pre></pre></div><p /> -<h3>Known issues with generate_phpt.php</h3> -<p>The script works by looking through the PHP implementation souce (C code) and trying to -work out from the comments what sort of input a function expects. Because the C code isn't -written in a completely consistent style it's sometimes impossible to work out how -to construct the test case. However - if you think it should work please raise bugs -against it <a href="bugs.php.net">here</a> </p> +-c class name .....................Name of class, eg DOMDocument +-m method name ....................Name of method, eg createAttribute +-b ............................... Generate basic tests +-e ............................... Generate error tests +-v ............................... Generate variation tests +-s sections....................... Create optional sections, colon separated list +-k skipif key..................... Skipif option, only used if -s skipif is used. +-x extension.......................Skipif option, specify extension to check for +-h ............................... Print this message +</pre></div> +<h3>Implementation notes</h3> +<p>The source code is under scripts/dev/generate-phpt/src. The phar file is generated using the script gtPackage.php. +The script works by using Reflection to work out what arguments a function or method expects and then setting up a function/method +invocation. +The catch with generating tests this way is that the script has to be run *using the level of PHP that you want to test*, +so if your were trying to write tests before doing development this script will not help. However, for filling in test gaps +in existing extensions it works fine. <p>Return to <a href="write-test.php">write tests.</a></p> \ No newline at end of file
http://cvs.php.net/viewvc.cgi/qaweb/autogenerate.php?r1=1.1&r2=1.2&diff_format=u Index: qaweb/autogenerate.php diff -u qaweb/autogenerate.php:1.1 qaweb/autogenerate.php:1.2 --- qaweb/autogenerate.php:1.1 Wed Feb 13 15:17:58 2008 +++ qaweb/autogenerate.php Thu May 7 09:16:49 2009 @@ -3,7 +3,7 @@ $TITLE = "Generating tests [PHP-QAT: Quality Assurance Team]"; $SITE_UPDATE = date("D M d H:i:s Y T", filectime(__FILE__)); -/* $Id: autogenerate.php,v 1.1 2008/02/13 15:17:58 zoe Exp $ */ +/* $Id: autogenerate.php,v 1.2 2009/05/07 09:16:49 zoe Exp $ */ common_header(); ?> @@ -12,8 +12,8 @@ Although it's not possible to generate a complete PHPT test, it's quite easy to generate the standard sections and some simple functions automatically, creating a test case "frame". To do this, you need: <ul> -<li> A copy of the PHP source (download from the <a href="http://snaps.php.net">snaps site</a> ) -</li> <li> A copy of the generate_phpt.php code in from scripts/dev +<li> A build pf PHP53 +</li> <li> The file generate-phpt.phar, located in the PHP53 source under dev/scripts </li></ul> <p /> @@ -23,40 +23,30 @@ <p /> <div class="fragment"><pre> --TEST-- -Test cos() : basic functionality +Test function cos() by calling it with its expected arguments --FILE-- <?php -<font color="green">/* Prototype : proto float cos(float number) -* Description: Returns the cosine of the number in radians -* Source code: ext/standard/math.c -* Alias to functions: -*/</font> -<font color="green">/* -* add comment here to indicate details of what this testcase is testing in particular -*/</font> -<font color="maroon">echo</font> "<font color="blue">*** Testing cos() : basic functionality ***\n</font>"; +echo "*** Test by calling method or function with its expected arguments ***\n" +$number = -<font color="green">// Initialise all required variables</font> -$number = 10.5; -<font color="green">// Calling cos() with all possible arguments</font> -var_dump( <font color="maroon">cos</font>($number) ); + +var_dump(cos( $number ) ); -<font color="maroon">echo</font> "<font color="blue">Done</font>" ?> --EXPECTF-- -Expected output goes here -Done</pre></pre></div> + +</pre></pre></div> <p /> <p /> <p /> <h3>Completing the .phpt test file: </h3> <p /> -To turn this into a complete test case, all the developer has to do is to change the value of $number to something reasonable +To turn this into a complete test case, all the developer has to do is to initialise $number to something reasonable and to add a section for the expected output. <p /> @@ -64,160 +54,28 @@ <p /> <h3> Command syntax </h3> <div class="fragment"><pre> -php generate_phpt.php -s <php_source_dir> -f <function_name> -b|-e|-v [-i <include_file>]</pre></pre></div> -<p /> -<p /> - -<p /> +php generate-phpt.php -f <function_name> |-c <class_name> -m <method_name> -b|e|v [-s skipif:ini:clean:done] [-k win|notwin|64b|not64b] [-x ext] +</pre></div> <h3> Options </h3> Use -h to list them, this is the output: <p /> <div class="fragment"><pre> --s location_of_source_code ....... Top level directory of PHP source -f function_name ................. Name of PHP function, eg cos --b ............................... Generate basic test --e ............................... Generate error test --v ............................... Generate variation test(s) --i file_containing_include_block.. Block of PHP code. If <font color="brown">this</font> option is present no code will be generated. --h ............................... Print <font color="brown">this</font> message</pre></pre></div> -<p /> -<p /> - -The following sections describe each argument: -<p /> -<p /> -<p /> -<p /> -<h3>PHP source code location ( -s <php_source_dir> ) </h3> -<p /> -The test case frame generation script depends on being able to find the function prototype in the -PHP implementation code - this is used to generate simple calls to the function. PHP source is most -easily obtained by downloading from the <a href="http://snaps.php.net/">snaps site</a>. The test generation script -expects to be given the name of the top level directory. In the following example, -the subdirectory <strong>/home/zoe/BUILDS/php524</strong> contains the complete source for php-5.2.4. - -<p /> -Example: <ul> -<li> Generate a basic test case frame for the xxx() function -</li></ul> -<div class="fragment"><pre> -php generate_phpt.php -s /home/zoe/BUILDS/php524 -f xxx -b</pre></pre></div> -<p /> -<p /> -<p /> -<p /> -<p /> -<h3>Function name ( -f <function_name> ) </h3> - -<p /> -The code will generate a test case frame for a given function. -<p /> -<p /> -Example: <ul> -<li> Generate a basic test case frame for the cos() function -</li></ul> -<div class="fragment"><pre> -php generate_phpt.php -s /home/zoe/BUILDS/php524 -f cos -b</pre></pre></div> -<p /> -<p /> -<p /> -<p /> -<p /> - -<p /> -<h3>Test Types ( -b | -e | -v ) </h3> -<p /> -<p /> -<p /> -<h6> Basic ( -b ) </h6> -<p /> -<p /> -<p /> -This will generate test case frame(s) called <function_name>_basic.phpt. They will have <ul> -<li> A title - -</li> <li> Prototype and implementation location -</li> <li> Description -</li> <li> List of any alias functions -</li> <li> Initialise the number and type of arguments that the function requires -</li> <li> var_dump (function (args)) -</li></ul> -<p /> - -Example: <ul> -<li> Generate a basic test case frame for the asin() function -</li></ul> -<div class="fragment"><pre> -php generate_phpt.php -s /home/zoe/BUILDS/php524 -f asin -b</pre></pre></div> -<p /> -<p /> -<p /> -<h6>Error ( -e ) </h6> -This will generate test case frame(s) called <function_name>_error.phpt. They will have <ul> - -<li> A title -</li> <li> Prototype and implementation location -</li> <li> Description -</li> <li> List of any alias functions -</li> <li> Initialise the number and type of arguments that the function requires -</li> <li> var_dump (function (args + 1)) - ie. tests for too many arguments - -</li> <li> var_dump (function (args - 1)) - ie. tests for too few arguments -</li></ul> -<p /> -Examples: <ul> -<li> Generate an error test case frame for the hexdec() function -</li></ul> -<div class="fragment"><pre> -php generate_phpt.php -s /home/zoe/BUILDS/php524 -f hexdec -e</pre></pre></div> -<p /> -<p /> -<p /> -<p /> - -<p /> -<h6>Variation ( -v ) </h6> -This will generate test case frame(s) called <function_name>_variation.phpt. They will have <ul> -<li> A title -</li> <li> Prototype and implementation location -</li> <li> Description -</li> <li> List of any alias functions - -</li> <li> Code to cycle through each argument in the function call setting it to a different type and then calling the function. -</li></ul> -<p /> -<p /> -Examples: <ul> -<li> Generate a variation test case frame for the cosh() function -</li></ul> -<div class="fragment"><pre> -php generate_phpt.php -s /home/zoe/BUILDS/php524 -f cosh -v</pre></pre></div> -<p /> -<p /> -<p /> - -<p /> -<p /> -<p /> -<p /> -<h6>Include blocks ( -i <include_file> ) </h6> -<p /> -It's often the case that the PHP code for the test case has already been written and tested, so all that the author needs to do is -to turn it into standard PHPT format. In this situation, generate_phpt.php should be called with the additional -i option and -given the name of a file which includes the PHP code for the relevant test-case. -<p /> -<p /> -Example: <ul> -<li> Generate a variation-type test case frame for the tan() function, and include a block of php code taken from the -file <strong>my_tan_test</strong> - -</li></ul> -<div class="fragment"><pre> -php generate_phpt.php -s /home/zoe/BUILDS/php524 -f tan -v -i my_tan_test</pre></pre></div><p /> -<h3>Known issues with generate_phpt.php</h3> -<p>The script works by looking through the PHP implementation souce (C code) and trying to -work out from the comments what sort of input a function expects. Because the C code isn't -written in a completely consistent style it's sometimes impossible to work out how -to construct the test case. However - if you think it should work please raise bugs -against it <a href="bugs.php.net">here</a> </p> +-c class name .....................Name of class, eg DOMDocument +-m method name ....................Name of method, eg createAttribute +-b ............................... Generate basic tests +-e ............................... Generate error tests +-v ............................... Generate variation tests +-s sections....................... Create optional sections, colon separated list +-k skipif key..................... Skipif option, only used if -s skipif is used. +-x extension.......................Skipif option, specify extension to check for +-h ............................... Print this message +</pre></div> +<h3>Implementation notes</h3> +<p>The source code is under scripts/dev/generate-phpt/src. The phar file is generated using the script gtPackage.php. +The script works by using Reflection to work out what arguments a function or method expects and then setting up a function/method +invocation. +The catch with generating tests this way is that the script has to be run *using the level of PHP that you want to test*, +so if your were trying to write tests before doing development this script will not help. However, for filling in test gaps +in existing extensions it works fine. <p>Return to <a href="write-test.php">write tests.</a></p> \ No newline at end of file