44 $path =
'/usr/local/simpletest' . PATH_SEPARATOR;
45 set_include_path(get_include_path() . PATH_SEPARATOR . $path);
46 if (!defined(
'SIMPLE_TEST'))
47 define(
'SIMPLE_TEST',
'/usr/local/simpletest/');
50 require_once SIMPLE_TEST .
'unit_tester.php';
51 require_once SIMPLE_TEST .
'reporter.php';
52 require_once SIMPLE_TEST .
'web_tester.php';
54 require_once (
'TestEnvironment.php');
55 if(defined(
'TESTROOT'))
58 require_once(TESTROOT .
'/testClasses/timer.php');
62 echo
"ERROR! cannot load /testClasses/timer.php, is TESTROOT defined?\n";
66 $Usage =
"Usage: $argv[0] options... 68 [ {<test-file.php> || a single test or 69 [-l 'list of tests'}] a list of tests, space seperated 70 [ -n <suite-name>] optional test suite name 71 [ -t 'A Title'] optional title\n 72 To run everything in a directory $argv[0] -l \"`ls`\"\n" ;
85 $options = getopt(
"l:n:t:");
96 if (empty($options)) {
106 $len = strspn($argv[1],
'-');
107 if(strspn($argv[1],
'-') == 0) {
111 if (array_key_exists(
"l",$options)) {
113 $RunList = preg_split(
'/\s|\n/',$options[
'l']);
116 if (array_key_exists(
"n",$options)) {
117 $suite = $options[
'n'];
121 if (!is_null($aTest)) {
122 if(file_exists($aTest)) {
124 $RunList = array($aTest);
128 print
"Error! File $aTest does not exist!\n";
133 if(is_null($suite)) {
134 $suite =
'Generic FOSSology Test Suite';
137 if (array_key_exists(
"t",$options)) {
138 $Title = $options[
't'];
143 $start =
new timer();
144 $date = date(
'Y-m-d');
145 $time = date(
'h:i:s-a');
146 print
"Starting $suite on: " . $date .
" at " . $time .
"\n";
148 $Runtest =
new TestSuite(
"Fossology tests $Title");
155 foreach($RunList as $ptest) {
156 if(preg_match(
'/^.*?\.php/',$ptest)) {
160 $test = $ptest .
".php";
162 $Runtest->addTestFile(
"$test");
170 if (TextReporter::inCli()) {
171 $results = $Runtest->run(
new TextReporter()) ? 0 : 1;
172 print
"Ending $suite at: " . date(
'r') .
"\n";
173 $elapseTime = $start->TimeAgo($start->getStartTime());
174 print
"The suite $suite took {$elapseTime}to run\n\n";
178 $Runtest->run(
new HtmlReporter());
179 print
"<pre>Ending $suite at: " . date(
'r') .
"</pre>\n";
180 $elapseTime = $start->TimeAgo($start->getStartTime());
181 print
"<pre>The suite $suite took {$elapseTime}to run</pre>\n";