[limb-svn] r6896 - 3.x/trunk/limb

svn at limb-project.com svn at limb-project.com
Thu Apr 3 01:20:41 MSD 2008


Author: pachanga
Date: 2008-04-03 01:20:41 +0400 (Thu, 03 Apr 2008)
New Revision: 6896
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6896

Modified:
   3.x/trunk/limb/runtests.php
Log:
-- adding experimental ability of forking process for each test with --fork option

Modified: 3.x/trunk/limb/runtests.php
===================================================================
--- 3.x/trunk/limb/runtests.php	2008-04-02 13:49:22 UTC (rev 6895)
+++ 3.x/trunk/limb/runtests.php	2008-04-02 21:20:41 UTC (rev 6896)
@@ -6,28 +6,85 @@
 require_once(dirname(__FILE__) . '/tests_runner/src/lmbTestTreeFilePathNode.class.php');
 require_once(dirname(__FILE__) . '/tests_runner/src/lmbTestTreeGlobNode.class.php');
 
+$fork = false;
+$quiet = false;
 $tests = array();
+$failed_tests = array();
+
+function out($msg)
+{
+  global $quiet;
+
+  if(!$quiet)
+    echo $msg;
+}
+
+function process_argv(&$argv)
+{
+  global $quiet;
+  global $fork;
+
+  $new_argv = array();
+  foreach($argv as $arg)
+  {
+    if($arg == '-q')
+      $quiet = true;
+    else if($arg == '--fork')
+      $fork = true;
+    else
+      $new_argv[] = $arg;
+  }
+  $argv = $new_argv;
+}
+
+process_argv($argv);
+
 if(sizeof($argv) > 1)
   $tests = array_splice($argv, 1);
 
+if(!$tests)
+  $tests = glob("*/tests/cases");
 
-if($tests)
+if($fork)
+  out("=========== Forking procees for each test ===========\n");
+
+$res = true;
+foreach($tests as $test)
 {
-  $paths = array();
-  $res = true;
-  foreach($tests as $test)
+  if(file_exists($test) || is_dir($test))
   {
-    $runner = new lmbTestRunner();
-    if(file_exists($test) || is_dir($test))
-      $res &= $runner->run(new lmbTestTreeFilePathNode($test));
+    out("=========== Running tests from '$test' ===========\n");
+
+    if($fork)
+    {
+      //TODO: get rid of hardocoded php call here
+      system("php " . __FILE__ . " -q $test", $ret);
+      if($ret != 0)
+      {
+        $res = false;
+        $failed_tests[] = $test;
+      }
+    }
     else
-      echo "Test path '$test' is not valid, skipping\n";
+    {
+      $runner = new lmbTestRunner();
+      if(!$runner->run(new lmbTestTreeFilePathNode($test)))
+      {
+        $res = false;
+        $failed_tests[] = $test;
+      }
+    }
   }
+  else
+    out("=========== Test path '$test' is not valid, skipping ==========\n");
 }
-else
+
+if(!$res)
 {
-  $runner = new lmbTestRunner();
-  $res = $runner->run(new lmbTestTreeGlobNode(dirname(__FILE__) . '/*/tests/cases/'));
+  out("=========== TESTS HAD ERRORS ===========\n");
+  out("Failed tests: [" . implode(", ", $failed_tests) . "]\n");
 }
+else
+  out("=========== ALL TESTS PASSED ===========\n");
 
 exit($res ? 0 : 1);



More information about the limb-svn mailing list