function load_tests($dir, &$test) { $d = dir($dir); while (false !== ($entry = $d->read())) { if($entry != '.' && $entry != '..' && $entry[0] != '.' && $entry[0] != '_') { $entry = $dir.DS.$entry; if(is_dir($entry)) { load_tests($entry, $test); } else { $test->addTestFile($entry); } } } $d->close(); }
function load_tests($dir, &$test) { $d = dir($dir); while (false !== ($entry = $d->read())) { if ($entry != '.' && $entry != '..' && $entry[0] != '.' && $entry[0] != '_') { $entry = $dir . DS . $entry; if (is_dir($entry)) { load_tests($entry, $test); } else { if (!strstr(file_get_contents($entry), 'ALL_TESTS_RUNNER')) { $test->addTestFile($entry); } else { require_once $entry; } } } } $d->close(); }
$options = getopt('f:hi:'); if (isset($options['h'])) { help(); exit; } if (!empty($options['f'])) { $csv_file = $options['f']; if (preg_match('/[.]csv$/i', $csv_file) <= 0) { $csv_file .= '.csv'; } } if (!empty($options['i']) && is_numeric($options['i'])) { $base = $options['i']; } if ($base < MIN_BASE) { die('Min iterations = ' . MIN_BASE . "\n"); } if (empty($options)) { help(); } echo 'Starting the benchmark with ' . $base . ' iterations.' . "\n\n"; $tests_list = array(); $results = array(); if (load_tests($TESTS_DIRS, $tests_list) === FALSE) { die('Unable to load tests'); } echo "\n"; do_tests($base, $tests_list, $results); echo "\n"; show_summary($base, $results, $csv_file); echo "\n";