CVS update: php3/regtests

From: Date: Sun, 23 Aug 1998 12:05:15 +0000
Subject: CVS update: php3/regtests
Groups: php.dev 
Request: Send a blank email to php-dev+get-525@lists.php.net to get a copy of this message
Date: Sunday August 23, 1998 @ 8:05 Author: rocky Update of /repository/php3/regtests In directory asf:/tmp/cvs-serv7246 Modified Files: testphp.pl Log Message: Now have a short usage. And a longer long usage. New option --url to override what's given in the test-control file. Section names can be mixed case. Index: php3/regtests/testphp.pl diff -c php3/regtests/testphp.pl:1.3 php3/regtests/testphp.pl:1.4 *** php3/regtests/testphp.pl:1.3 Sat Aug 22 22:59:42 1998 --- php3/regtests/testphp.pl Sun Aug 23 08:05:14 1998 *************** *** 1,13 **** #!/bin/perl -w ! $vcid='$Id: testphp.pl,v 1.3 1998/08/23 02:59:42 rocky Exp $'; sub usage { ! print " usage: $program [OPTIONS] server *php-test-control-file* ! Used to test php3 programs. ! A URL is constructed and requested. For example it might be something ! like myserver.org:${serverport}${prefix}001.phtml. The output is compared against the results found in php-control-file. --- 1,17 ---- #!/bin/perl -w ! $vcid='$Id: testphp.pl,v 1.4 1998/08/23 12:05:14 rocky Exp $'; sub usage { ! my($terse)=@_; ! print " usage: $program [OPTIONS] server *php-test-control-file* ! Used in regression testing to run a php3 program and compare its output ! against previously saved expected results. ! "; ! if (!$terse) { ! print " A URL is constructed and requested. For example it might be something ! like myserver.org:${serverport}/regtests/basic/001.phtml. The output is compared against the results found in php-control-file. *************** *** 36,46 **** The TITLE section can contain a number of lines and merely describes the name of the test. It is not used in validation, but is manditory. ! It is printed before the test is run. ! The URL section gives the name of the test to run, and is manditory. The servername, port and an optional prefix are all prepended ! to the URL. The POST section is optional, but if given, a POST method will be used. It is followed by a number of lines, possibly empty which contain --- 40,55 ---- The TITLE section can contain a number of lines and merely describes the name of the test. It is not used in validation, but is manditory. ! It is printed before the test is run. It can be ! several lines long. ! The URL section gives the name of the test to run, and is manditory ! unless the command-line option --url is specified. If there are any ! GET parameters to pass along, it would be done here. ! The servername, port and an optional prefix are all prepended ! to the URL. Only the first line after --URL-- is used. Subsequent ! lines are tacitly ignored. The POST section is optional, but if given, a POST method will be used. It is followed by a number of lines, possibly empty which contain *************** *** 48,53 **** --- 57,65 ---- If there is no POST section, only a GET method will be used. + Note that both the POST section and the parameter part of the URL section + need to have their data in url-encoded format. + The HEAD section is optional too, but if given the header from the HTTP server will be checked againt the perl pattern that is in this section. *************** *** 55,61 **** The EXPECT section contains the desired output to check against. The section is manditory, although there my be no lines (no output). ! Here is a complete testfile: --TITLE-- Trivial 'Hello World' test ... --URL-- --- 67,78 ---- The EXPECT section contains the desired output to check against. The section is manditory, although there my be no lines (no output). ! A simple example which takes one argument through the POST method ! and one through the GET and displays these would be: ! ! Here is a complete test file which uses the GET method but sends ! no data. ! --TITLE-- Trivial 'Hello World' test ... --URL-- *************** *** 63,78 **** --EXPECT-- Hello World OPTIONS: ! help -- display this help ! version -- print version string and exit ! quiet -- don't print the Description seciton. ! diff *prog* -- specify diff program and options for use in comparison. Default is: $diff ! port *n* -- specify port number to connect to in HTTP server default is: $serverport ! prefix *str* -- Specify URL prefix. default is: $prefix "; exit 100; } --- 80,111 ---- --EXPECT-- Hello World + ============= + "; + } + print " OPTIONS: ! --help display detailed help ! --version print version string and exit ! --quiet don't print the Description seciton. ! --diff *prog* specify diff program and options for use in comparison. Default is: $diff ! --port *n* specify port number to connect to in HTTP server default is: $serverport ! --prefix *str* Specify URL prefix. default is: $prefix ! --url *str* Specify the URL suffix. Note that you don't ! put a hostname and port in here or http://, ! as these are added automatically. If --prefix ! is given, it to is prepended. ! "; + if ($terse) { + print " + For a detailed description of the test-control file format, type: + $program --help + " + } + exit 100; } *************** *** 108,126 **** 'diff=s' => \$diff, 'port=i' => \$serverport, 'prefix=s' => \$prefix, ); show_version() if $show_version; ! usage() if $help || !$result; if (@ARGV!=2) { print STDERR "Expecting 2 arguments: server & php-test-program name\n"; ! usage(); } $serverhost =$ARGV[0]; $php_testfile=$ARGV[1]; } # Reads the PHP test file spec, and creates the expected output file ! # to compare results against. Save the output in string $Expect too. sub read_test_info { my($test_control_file) = @_; --- 141,161 ---- 'diff=s' => \$diff, 'port=i' => \$serverport, 'prefix=s' => \$prefix, + 'url=s' => \$url, ); show_version() if $show_version; ! usage(0) if $help || !$result; if (@ARGV!=2) { print STDERR "Expecting 2 arguments: server & php-test-program name\n"; ! usage(1); } $serverhost =$ARGV[0]; $php_testfile=$ARGV[1]; } # Reads the PHP test file spec, and creates the expected output file ! # to compare results against. Save the output in string $Expect too ! # in case we want to use an internally-defined "diff". sub read_test_info { my($test_control_file) = @_; *************** *** 143,162 **** my($lineno); for ($lineno=1; <CONTROL_FILE>; $lineno++) { # See if we've hit a new section header. ! if (/^--TITLE--/) { $in_section='title'; next; ! } elsif (/^--URL--/) { $in_section='url'; next; ! } elsif (/^--POST--/) { $in_section='post'; $Post = ''; next; ! } elsif (/^--HEAD--/) { $in_section='head'; next; ! } elsif (/^--EXPECT--/) { $in_section='expect'; $Expect=''; next; --- 178,197 ---- my($lineno); for ($lineno=1; <CONTROL_FILE>; $lineno++) { # See if we've hit a new section header. ! if (/^--TITLE--/i) { $in_section='title'; next; ! } elsif (/^--URL--/i) { $in_section='url'; next; ! } elsif (/^--POST--/i) { $in_section='post'; $Post = ''; next; ! } elsif (/^--HEAD--/i) { $in_section='head'; next; ! } elsif (/^--EXPECT--/i) { $in_section='expect'; $Expect=''; next; *************** *** 171,177 **** $Expect .= $_; } elsif ($in_section eq 'url') { chomp; ! $url = "${prefix}$_"; } elsif ($in_section eq 'title') { $desc .= $_; } elsif ($in_section eq 'post') { --- 206,216 ---- $Expect .= $_; } elsif ($in_section eq 'url') { chomp; ! # --url command-line option takes precidence over section ! # Also we take only the first line. Subsequent lines are ignored ! # silently. ! # Perhaps we should give a warning? ! $url = "${prefix}$_" if !defined($url); } elsif ($in_section eq 'title') { $desc .= $_; } elsif ($in_section eq 'post') { *************** *** 198,204 **** # Now do some basic error checking of the test file. if (!$url) { ! myerr("URL section not found", 20); } elsif (!defined($Expect)) { myerr("Didn't see --EXPECT--", 30); } --- 237,244 ---- # Now do some basic error checking of the test file. if (!$url) { ! myerr("URL section not found and command option override not given", ! 20); } elsif (!defined($Expect)) { myerr("Didn't see --EXPECT--", 30); } -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#525) next »