]> granicus.if.org Git - php/commitdiff
make run-tests work under win32 too
authorDaniel Beulshausen <dbeu@php.net>
Wed, 2 May 2001 16:39:04 +0000 (16:39 +0000)
committerDaniel Beulshausen <dbeu@php.net>
Wed, 2 May 2001 16:39:04 +0000 (16:39 +0000)
# this whole thing is pretty ugly...

run-tests.php
win32/php4ts.dsw
win32/php5ts.dsw
win32/testsuite.dsp [new file with mode: 0644]

index cf05f025a4763e3dbadb83e8e49aa6383e671cac..dc1fe1fc99aa7793094be4fe54a0a01478906f56 100755 (executable)
@@ -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;
 }
 
-?>
+?>
\ No newline at end of file
index 43a78eaaea8a514695dddb9b9869e362ff3fbc1a..fb9346c2e4ee97d79dc2b9a237b94aa357f452d6 100644 (file)
@@ -165,6 +165,21 @@ Package=<4>
 \r
 ###############################################################################\r
 \r
+Project: "testsuite"=".\testsuite.dsp" - Package Owner=<4>\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<4>\r
+{{{\r
+    Begin Project Dependency\r
+    Project_Dep_Name php4ts\r
+    End Project Dependency\r
+}}}\r
+\r
+###############################################################################\r
+\r
 Global:\r
 \r
 Package=<5>\r
index 43a78eaaea8a514695dddb9b9869e362ff3fbc1a..fb9346c2e4ee97d79dc2b9a237b94aa357f452d6 100644 (file)
@@ -165,6 +165,21 @@ Package=<4>
 \r
 ###############################################################################\r
 \r
+Project: "testsuite"=".\testsuite.dsp" - Package Owner=<4>\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<4>\r
+{{{\r
+    Begin Project Dependency\r
+    Project_Dep_Name php4ts\r
+    End Project Dependency\r
+}}}\r
+\r
+###############################################################################\r
+\r
 Global:\r
 \r
 Package=<5>\r
diff --git a/win32/testsuite.dsp b/win32/testsuite.dsp
new file mode 100644 (file)
index 0000000..5cd6562
--- /dev/null
@@ -0,0 +1,150 @@
+# Microsoft Developer Studio Project File - Name="testsuite" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Generic Project" 0x010a\r
+\r
+CFG=testsuite - Win32 Debug_TS\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "testsuite.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "testsuite.mak" CFG="testsuite - Win32 Debug_TS"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "testsuite - Win32 Release_TS_Inline" (based on "Win32 (x86) Generic Project")\r
+!MESSAGE "testsuite - Win32 Release_TS" (based on "Win32 (x86) Generic Project")\r
+!MESSAGE "testsuite - Win32 Release_TSDbg" (based on "Win32 (x86) Generic Project")\r
+!MESSAGE "testsuite - Win32 Debug_TS" (based on "Win32 (x86) Generic Project")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""\r
+# PROP Scc_LocalPath ""\r
+MTL=midl.exe\r
+\r
+!IF  "$(CFG)" == "testsuite - Win32 Release_TS_Inline"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release_TS_Inline"\r
+# PROP BASE Intermediate_Dir "Release_TS_Inline"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "..\..\Release_TS_Inline"\r
+# PROP Intermediate_Dir "..\..\"\r
+# PROP Target_Dir ""\r
+\r
+!ELSEIF  "$(CFG)" == "testsuite - Win32 Release_TS"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release_TS"\r
+# PROP BASE Intermediate_Dir "Release_TS"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "..\..\Release_TS"\r
+# PROP Intermediate_Dir "..\..\"\r
+# PROP Target_Dir ""\r
+\r
+!ELSEIF  "$(CFG)" == "testsuite - Win32 Release_TSDbg"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release_TSDbg"\r
+# PROP BASE Intermediate_Dir "Release_TSDbg"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "..\..\Release_TSDbg"\r
+# PROP Intermediate_Dir "..\..\"\r
+# PROP Target_Dir ""\r
+\r
+!ELSEIF  "$(CFG)" == "testsuite - Win32 Debug_TS"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug_TS"\r
+# PROP BASE Intermediate_Dir "Debug_TS"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "..\..\Debug_TS"\r
+# PROP Intermediate_Dir "..\..\"\r
+# PROP Target_Dir ""\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "testsuite - Win32 Release_TS_Inline"\r
+# Name "testsuite - Win32 Release_TS"\r
+# Name "testsuite - Win32 Release_TSDbg"\r
+# Name "testsuite - Win32 Debug_TS"\r
+# Begin Source File\r
+\r
+SOURCE=..\results.txt\r
+\r
+!IF  "$(CFG)" == "testsuite - Win32 Release_TS_Inline"\r
+\r
+# PROP Intermediate_Dir "..\Release_TS_Inline"\r
+# PROP Ignore_Default_Tool 1\r
+# Begin Custom Build - Running Testsuite, please wait...\r
+IntDir=.\..\Release_TS_Inline\r
+InputPath=..\results.txt\r
+\r
+"..\..\results.txt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       set TOP_BUILDDIR=Release_TS_inline \r
+       set TEST_DIR=tests \r
+       $(IntDir)\php.exe -q ..\run-tests.php > ..\results.txt \r
+       \r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "testsuite - Win32 Release_TS"\r
+\r
+# PROP Intermediate_Dir "..\Release_TS"\r
+# PROP Ignore_Default_Tool 1\r
+# Begin Custom Build - Running Testsuite, please wait...\r
+IntDir=.\..\Release_TS\r
+InputPath=..\results.txt\r
+\r
+"..\..\results.txt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       set TOP_BUILDDIR=Release_TS \r
+       set TEST_DIR=tests \r
+       $(IntDir)\php.exe -q ..\run-tests.php > ..\results.txt \r
+       \r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "testsuite - Win32 Release_TSDbg"\r
+\r
+# PROP Intermediate_Dir "..\Release_TSDbg"\r
+# PROP Ignore_Default_Tool 1\r
+# Begin Custom Build - Running Testsuite, please wait...\r
+IntDir=.\..\Release_TSDbg\r
+InputPath=..\results.txt\r
+\r
+"..\..\results.txt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       set TOP_BUILDDIR=Release_TSDbg \r
+       set TEST_DIR=tests \r
+       $(IntDir)\php.exe -q ..\run-tests.php > ..\results.txt \r
+       \r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "testsuite - Win32 Debug_TS"\r
+\r
+# PROP Intermediate_Dir "..\Debug_TS"\r
+# PROP Exclude_From_Build 1\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# End Target\r
+# End Project\r