33 $path =
'/usr/local/simpletest' . PATH_SEPARATOR;
34 set_include_path(get_include_path() . PATH_SEPARATOR . $path);
35 if (!defined(
'SIMPLE_TEST'))
36 define(
'SIMPLE_TEST',
'/usr/local/simpletest/');
39 require_once SIMPLE_TEST .
'unit_tester.php';
40 require_once SIMPLE_TEST .
'reporter.php';
41 require_once SIMPLE_TEST .
'web_tester.php';
43 require_once (
'TestEnvironment.php');
44 if(defined(
'TESTROOT'))
47 require_once(TESTROOT .
'/testClasses/timer.php');
51 echo
"ERROR! cannot load /testClasses/timer.php, is TESTROOT defined?\n";
55 $Usage =
"Usage: $argv[0] options...
57 [ {<test-file.php> || a single test or
58 [-l 'list of tests'}] a list of tests, space seperated
59 [ -n <suite-name>] optional test suite name
60 [ -t 'A Title'] optional title\n
61 To run everything in a directory $argv[0] -l \"`ls`\"\n" ;
74 $options = getopt(
"l:n:t:");
85 if (empty($options)) {
95 $len = strspn($argv[1],
'-');
96 if(strspn($argv[1],
'-') == 0) {
100 if (array_key_exists(
"l",$options)) {
102 $RunList = preg_split(
'/\s|\n/',$options[
'l']);
105 if (array_key_exists(
"n",$options)) {
106 $suite = $options[
'n'];
110 if (!is_null($aTest)) {
111 if(file_exists($aTest)) {
113 $RunList = array($aTest);
117 print
"Error! File $aTest does not exist!\n";
122 if(is_null($suite)) {
123 $suite =
'Generic FOSSology Test Suite';
126 if (array_key_exists(
"t",$options)) {
127 $Title = $options[
't'];
132 $start =
new timer();
133 $date = date(
'Y-m-d');
134 $time = date(
'h:i:s-a');
135 print
"Starting $suite on: " . $date .
" at " . $time .
"\n";
137 $Runtest =
new TestSuite(
"Fossology tests $Title");
144 foreach($RunList as $ptest) {
145 if(preg_match(
'/^.*?\.php/',$ptest)) {
149 $test = $ptest .
".php";
151 $Runtest->addTestFile(
"$test");
159 if (TextReporter::inCli()) {
160 $results = $Runtest->run(
new TextReporter()) ? 0 : 1;
161 print
"Ending $suite at: " . date(
'r') .
"\n";
162 $elapseTime = $start->TimeAgo($start->getStartTime());
163 print
"The suite $suite took {$elapseTime}to run\n\n";
167 $Runtest->run(
new HtmlReporter());
168 print
"<pre>Ending $suite at: " . date(
'r') .
"</pre>\n";
169 $elapseTime = $start->TimeAgo($start->getStartTime());
170 print
"<pre>The suite $suite took {$elapseTime}to run</pre>\n";