Browse Source

make run-tests work under win32 too

# this whole thing is pretty ugly...
PHP-4.0.6
Daniel Beulshausen 25 years ago
parent
commit
3d5b27d46a
  1. 82
      run-tests.php
  2. 15
      win32/php4ts.dsw
  3. 15
      win32/php5ts.dsw
  4. 150
      win32/testsuite.dsp

82
run-tests.php

@ -73,15 +73,8 @@ function dowriteln($str)
}
function create_compiled_in_modules_list() {
global $php,$compiled_in_modules;
$ret=`$php -m`;
$compiled_in_modules=explode("\n",$ret);
foreach ($compiled_in_modules AS $key => $value) {
if (!$value
|| strchr($value,' ') ) unset($compiled_in_modules[$key]);
}
global $compiled_in_modules;
$compiled_in_modules = @get_loaded_extensions();
}
function extract_module_name_from_path($path) {
@ -127,16 +120,13 @@ function initialize()
$term_bold = $term_norm = "";
}
$windows_p = (substr(PHP_OS, 0, 3) == "WIN");
if ($windows_p) {
if (file_exists('Release_TS_inline\\php.exe')) {
$php = 'Release_TS_inline\\php.exe';
} elseif (file_exists('Release_TS\\php.exe')) {
$php = 'Release_TS\\php.exe';
} else {
$php=trim($windows_p ? `cd`:`pwd`).'\\php';
}
} else {
if((substr(PHP_OS, 0, 3) == "WIN")) {
$windows_p = true;
$term = getenv("COMSPEC");
$null = getenv("TOP_BUILDDIR");
$php = ($null ? $null : getcwd()) . "/php.exe";
unset($null);
} else {
if (isset($GLOBALS["TOP_BUILDDIR"])) {
$php = $GLOBALS["TOP_BUILDDIR"]."/php";
} else {
@ -145,8 +135,8 @@ function initialize()
}
create_compiled_in_modules_list();
if (!is_executable($php)) {
if (!is_executable($php) && !$windows_p) {
dowriteln("PHP CGI binary ($php) is not executable.");
dowriteln("Please compile PHP as a CGI executable and try again.");
exit;
@ -211,14 +201,14 @@ function do_testing($argc, &$argv)
}
} else {
// $dir = $GLOBALS["TOP_SRCDIR"]; // XXX ??? where should this variable be set?
$dir=str_replace('\\','/',trim(($windows_p ? `cd`:`pwd`)));
$dir=str_replace('\\','/',trim(($windows_p ? getenv("TEST_DIR"):`pwd`)));
}
if (isset($dir) && $dir) {
find_testdirs($dir);
create_found_tests_4_modules_list();
create_modules_2_test_list();
for ($i = 0; $i < sizeof($testdirs); $i++) {
run_tests_in_dir($testdirs[$i]);
}
@ -265,22 +255,22 @@ function find_testdirs($dir = '.', $first_pass = true)
}
while ($ent = readdir($dp)) {
$path = "$dir/$ent";
if ((isset($skip[$ent]) && $skip[$ent])
|| substr($ent, 0, 1) == "."
|| !is_dir($path)
) {
continue;
}
if (strstr("/$path/", "/tests/")) {
$testdirs[] = $path;
}
find_testdirs($path, false);
}
closedir($dp);
}
function run_tests_in_dir($dir = '.')
@ -307,13 +297,13 @@ function run_tests_in_dir($dir = '.')
if (sizeof($testfiles) == 0) {
return;
}
if ($mod_name=extract_module_name_from_path($dir)) {
if ($ext_found=in_array($mod_name,$modules_available))
dowriteln("Testing extension: $mod_name");
else $skipped_extensions[$mod_name]=TRUE;
}
if ($ext_found!==FALSE) {
dowriteln("%bRunning tests in $dir%B");
dowriteln("=================".str_repeat("=", strlen($dir)));
@ -373,7 +363,7 @@ function delete_tmpfiles()
* @return bool whether the files were "equal"
*/
function compare_results($file1, $file2)
{
{
$data1 = $data2 = "";
if (!($fp1 = @fopen($file1, "r")) || !($fp2 = @fopen($file2, "r"))) {
return false;
@ -382,12 +372,12 @@ function compare_results($file1, $file2)
while (!(feof($fp1) || feof($fp2))) {
if (!feof($fp1) && trim($line1 = fgets($fp1, 10240)) != "") {
//print "adding line1 $line1\n";
$data1 .= trim($line1);
}
if (!feof($fp2) && trim($line2 = fgets($fp2, 10240)) != "") {
//print "adding line2 $line2\n";
$data2 .= trim($line2);
}
}
@ -404,7 +394,7 @@ function compare_results($file1, $file2)
function run_test($file)
{
global $php, $tmpfile, $term_bold, $term_norm;
global $php, $tmpfile, $term_bold, $term_norm, $term, $windows_p;
$variables = array("TEST", "POST", "GET", "FILE", "EXPECT", "SKIPIF",
"OUTPUT");
@ -417,11 +407,11 @@ function run_test($file)
$tmpfile["FILE"] = tempnam($tmpdir, $tmpfix);
$tmpfile["SKIPIF"] = tempnam($tmpdir, $tmpfix);
$tmpfile["POST"] = tempnam($tmpdir, $tmpfix);
$tmpfile["EXPECT"] = tempnam($tmpdir, $tmpfix);
$tmpfile["OUTPUT"] = tempnam($tmpdir, $tmpfix);
while ($line = fgets($fp, 4096)) {
if (preg_match('/^--([A-Z]+)--/', $line, $matches)) {
$var = $matches[1];
@ -487,11 +477,19 @@ function run_test($file)
putenv("CONTENT_LENGTH=");
}
if (isset($fps["POST"])) {
// XXX Fix me, I do not work on win32 (?)
$cmd = "$php -q $tmpfile[FILE] < $tmpfile[POST]";
if(!$windows_p) {
$cmd = "$php -q $tmpfile[FILE] < $tmpfile[POST]";
}
else {
$cmd = "$term /c " . realpath($php) ." -q $tmpfile[FILE] < $tmpfile[POST]";
}
} else {
$cmd = "$php -q $tmpfile[FILE]";
if(!$windows_p) {
$cmd = "$php -q $tmpfile[FILE]";
}
else {
$cmd = "$term /c " . realpath($php) ." -q $tmpfile[FILE]";;
}
}
$ofp = @fopen($tmpfile["OUTPUT"], "w");
if (!$ofp) {
@ -563,4 +561,4 @@ function run_test($file)
return $status;
}
?>
?>

15
win32/php4ts.dsw

@ -165,6 +165,21 @@ Package=<4>
###############################################################################
Project: "testsuite"=".\testsuite.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name php4ts
End Project Dependency
}}}
###############################################################################
Global:
Package=<5>

15
win32/php5ts.dsw

@ -165,6 +165,21 @@ Package=<4>
###############################################################################
Project: "testsuite"=".\testsuite.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name php4ts
End Project Dependency
}}}
###############################################################################
Global:
Package=<5>

150
win32/testsuite.dsp

@ -0,0 +1,150 @@
# Microsoft Developer Studio Project File - Name="testsuite" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Generic Project" 0x010a
CFG=testsuite - Win32 Debug_TS
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "testsuite.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "testsuite.mak" CFG="testsuite - Win32 Debug_TS"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "testsuite - Win32 Release_TS_Inline" (based on "Win32 (x86) Generic Project")
!MESSAGE "testsuite - Win32 Release_TS" (based on "Win32 (x86) Generic Project")
!MESSAGE "testsuite - Win32 Release_TSDbg" (based on "Win32 (x86) Generic Project")
!MESSAGE "testsuite - Win32 Debug_TS" (based on "Win32 (x86) Generic Project")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
MTL=midl.exe
!IF "$(CFG)" == "testsuite - Win32 Release_TS_Inline"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release_TS_Inline"
# PROP BASE Intermediate_Dir "Release_TS_Inline"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\Release_TS_Inline"
# PROP Intermediate_Dir "..\..\"
# PROP Target_Dir ""
!ELSEIF "$(CFG)" == "testsuite - Win32 Release_TS"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release_TS"
# PROP BASE Intermediate_Dir "Release_TS"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\Release_TS"
# PROP Intermediate_Dir "..\..\"
# PROP Target_Dir ""
!ELSEIF "$(CFG)" == "testsuite - Win32 Release_TSDbg"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release_TSDbg"
# PROP BASE Intermediate_Dir "Release_TSDbg"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\Release_TSDbg"
# PROP Intermediate_Dir "..\..\"
# PROP Target_Dir ""
!ELSEIF "$(CFG)" == "testsuite - Win32 Debug_TS"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug_TS"
# PROP BASE Intermediate_Dir "Debug_TS"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\..\Debug_TS"
# PROP Intermediate_Dir "..\..\"
# PROP Target_Dir ""
!ENDIF
# Begin Target
# Name "testsuite - Win32 Release_TS_Inline"
# Name "testsuite - Win32 Release_TS"
# Name "testsuite - Win32 Release_TSDbg"
# Name "testsuite - Win32 Debug_TS"
# Begin Source File
SOURCE=..\results.txt
!IF "$(CFG)" == "testsuite - Win32 Release_TS_Inline"
# PROP Intermediate_Dir "..\Release_TS_Inline"
# PROP Ignore_Default_Tool 1
# Begin Custom Build - Running Testsuite, please wait...
IntDir=.\..\Release_TS_Inline
InputPath=..\results.txt
"..\..\results.txt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
set TOP_BUILDDIR=Release_TS_inline
set TEST_DIR=tests
$(IntDir)\php.exe -q ..\run-tests.php > ..\results.txt
# End Custom Build
!ELSEIF "$(CFG)" == "testsuite - Win32 Release_TS"
# PROP Intermediate_Dir "..\Release_TS"
# PROP Ignore_Default_Tool 1
# Begin Custom Build - Running Testsuite, please wait...
IntDir=.\..\Release_TS
InputPath=..\results.txt
"..\..\results.txt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
set TOP_BUILDDIR=Release_TS
set TEST_DIR=tests
$(IntDir)\php.exe -q ..\run-tests.php > ..\results.txt
# End Custom Build
!ELSEIF "$(CFG)" == "testsuite - Win32 Release_TSDbg"
# PROP Intermediate_Dir "..\Release_TSDbg"
# PROP Ignore_Default_Tool 1
# Begin Custom Build - Running Testsuite, please wait...
IntDir=.\..\Release_TSDbg
InputPath=..\results.txt
"..\..\results.txt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
set TOP_BUILDDIR=Release_TSDbg
set TEST_DIR=tests
$(IntDir)\php.exe -q ..\run-tests.php > ..\results.txt
# End Custom Build
!ELSEIF "$(CFG)" == "testsuite - Win32 Debug_TS"
# PROP Intermediate_Dir "..\Debug_TS"
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# End Target
# End Project
Loading…
Cancel
Save