コード例 #1
0
 function perform($path)
 {
     $runner = new lmbTestRunner();
     $runner->setReporter($this->_getReporter());
     $runner->run($this->root_node, $path);
     if (isset($_GET['back'])) {
         $postfix = '';
     } else {
         $postfix = '/..';
     }
     echo '<small>' . $runner->getRunTime() . '</small>';
     echo '<p>' . $this->_createBrowseLink($path . $postfix, 'Back') . '</p>';
 }
コード例 #2
0
 function run($root_node, $path = '/')
 {
     require_once dirname(__FILE__) . '/../simpletest.inc.php';
     self::$current = $this;
     $this->_startStats();
     $this->_startCoverage();
     $res = $this->_doRun($root_node, $path);
     $this->_endCoverage();
     return $res;
 }
コード例 #3
0
 function paintFooter($test_name)
 {
     parent::paintFooter($test_name);
     $runner = lmbTestRunner::getCurrent();
     print 'Tests time: ' . $runner->getRuntime() . " sec.\n";
     if ($memory = $runner->getMemoryUsage()) {
         print 'Tests memory usage: ' . $memory . " Mb.\n";
     }
     if ($this->failed_tests) {
         print "=========== FAILED TESTS  ===========\n";
         print implode("\n", $this->failed_tests) . "\n";
     }
 }
コード例 #4
0
ファイル: runtests.php プロジェクト: vasiatka/sitemap
#!/usr/bin/env php
<?php 
require_once dirname(__FILE__) . '/lib/tests_runner/common.inc.php';
require_once dirname(__FILE__) . '/lib/tests_runner/src/lmbTestRunner.class.php';
require_once dirname(__FILE__) . '/lib/tests_runner/src/lmbTestTreeFilePathNode.class.php';
$runner = new lmbTestRunner();
$res = $runner->run(new lmbTestTreeFilePathNode(dirname(__FILE__) . '/cases/'));
exit($res ? 0 : 1);
コード例 #5
0
ファイル: runtests.php プロジェクト: knevcher/limb
    $tests = glob("*", GLOB_ONLYDIR);
}
$tests = array_diff($tests, $skipped);
if ($fork) {
    $php_bin = get_php_bin();
    out("=========== Forking processes for each test path(PHP cmdline '{$php_bin}') ===========\n");
}
$res = true;
foreach ($tests as $test) {
    if (file_exists($test) || is_dir($test)) {
        if ($fork) {
            system($php_bin . " " . __FILE__ . " -q --no-fork " . implode(" ", $defines) . " {$test}", $ret);
            if ($ret != 0) {
                $res = false;
            }
        } else {
            $runner = new lmbTestRunner();
            if (!$runner->run(new lmbTestTreeFilePathNode($test))) {
                $res = false;
            }
        }
    } else {
        out("=========== Test path '{$test}' is not valid, skipping ==========\n");
    }
}
if (!$res) {
    out("=========== TESTS HAD ERRORS(see above) ===========\n");
} else {
    out("=========== ALL TESTS PASSED ===========\n");
}
exit($res ? 0 : 1);
コード例 #6
0
 protected function _doRun()
 {
     $short_opts = self::getShortOpts();
     $long_opts = self::getLongOpts();
     lmbTestGetopt::defineAndExtractConstants($this->argv);
     try {
         if ($this->posix_opts) {
             $options = lmbTestGetopt::getopt($this->argv, $short_opts, $long_opts);
         } else {
             $options = lmbTestGetopt::getopt2($this->argv, $short_opts, $long_opts);
         }
     } catch (Exception $e) {
         $this->_help(1);
     }
     $config_file = null;
     $cover_include = '';
     $cover_exclude = '';
     $cover_report_dir = null;
     foreach ($options[0] as $option) {
         switch ($option[0]) {
             case 'h':
             case '--help':
                 $this->_help(0);
                 break;
             case 'V':
             case '--verbose':
                 lmbTestOptions::set('verbose', true);
                 break;
             case 'v':
             case '--version':
                 $this->_version();
                 break;
             case 'c':
             case '--config':
                 $config_file = $option[1];
                 break;
             case 'I':
             case '--include':
                 lmbTestOptions::set('file_filter', $option[1]);
                 break;
             case 'G':
             case '--groups':
                 lmbTestOptions::set('groups_filter', array_map('trim', explode(',', trim($option[1]))));
                 break;
             case 'T':
             case '--tests':
                 lmbTestOptions::set('tests_filter', array_map('trim', explode(',', trim($option[1]))));
                 break;
             case 'M':
             case '--methods':
                 lmbTestOptions::set('methods_filter', array_map('trim', explode(',', trim($option[1]))));
                 break;
             case 'C':
             case '--cover':
                 $cover_include = $option[1];
                 break;
             case '--cover-report':
                 $cover_report_dir = $option[1];
                 break;
             case '--cover-exclude':
                 $cover_exclude = $option[1];
                 break;
         }
     }
     if (!$config_file) {
         $config_file = getenv('LIMB_TESTS_RUNNER_CONFIG');
     }
     if ($config_file) {
         if (!($php = @file_get_contents(realpath($config_file)))) {
             $this->_error("Could not read configuration file '{$config_file}'\n");
         }
         if (!$this->_phpLint($php, $error)) {
             $this->_error("Configuration file '{$config_file}' is invalid(check syntax)\n{$error}");
         }
         if (!(include_once realpath($config_file))) {
             $this->_error("Could not include configuration file '{$config_file}'\n");
         }
     }
     if (!is_array($options[1]) || !count($options[1])) {
         $paths = array('.');
     } else {
         $paths = $options[1];
     }
     if (!$cover_report_dir && defined('LIMB_TESTS_RUNNER_COVERAGE_REPORT_DIR')) {
         $cover_report_dir = LIMB_TESTS_RUNNER_COVERAGE_REPORT_DIR;
     }
     require_once dirname(__FILE__) . '/lmbTestRunner.class.php';
     $runner = new lmbTestRunner();
     if ($this->reporter) {
         $runner->setReporter($this->reporter);
     }
     if ($cover_include) {
         $runner->useCoverage($cover_include, $cover_exclude, $cover_report_dir);
     }
     try {
         require_once dirname(__FILE__) . '/lmbTestTreeGlobNode.class.php';
         $node = new lmbTestTreeGlobNode($paths);
         $res = $runner->run($node);
     } catch (lmbTestUserException $e) {
         $this->_error($e->getMessage());
     } catch (Exception $e) {
         $this->_error($e->__toString());
     }
     return $res;
 }
コード例 #7
0
ファイル: runtests.php プロジェクト: snowjobgit/limb
}
$tests = array_diff($tests, $skipped);
if ($fork) {
    $php_bin = get_php_bin();
    out("=========== Forking processes for each test path(PHP cmdline '{$php_bin}') ===========\n");
}
$res = true;
foreach ($tests as $test) {
    if (file_exists($test) || is_dir($test)) {
        if ($fork) {
            system($php_bin . " " . __FILE__ . " -q --no-fork " . implode(" ", $defines) . " {$test}", $ret);
            if ($ret != 0) {
                $res = false;
            }
        } else {
            $runner = new lmbTestRunner();
            if ($cover) {
                $runner->useCoverage($test . '/src', '', '');
            }
            if (!$runner->run(new lmbTestTreeFilePathNode($test))) {
                $res = false;
            }
        }
    } else {
        out("=========== Test path '{$test}' is not valid, skipping ==========\n");
    }
}
if (!$res) {
    out("=========== TESTS HAD ERRORS(see above) ===========\n");
} else {
    out("=========== ALL TESTS PASSED ===========\n");