diff options
author | hfuecks <hfuecks@gmail.com> | 2005-10-12 10:10:13 +0200 |
---|---|---|
committer | hfuecks <hfuecks@gmail.com> | 2005-10-12 10:10:13 +0200 |
commit | cbf6ced732cfa27bdf7d492604696e01d7657da9 (patch) | |
tree | b6e342ba944e5adea69dfadba82fff3ea183f770 /test/lib | |
parent | 6222040c35d547dc99f13bd2bb8222165aa4ce2c (diff) | |
download | rpg-cbf6ced732cfa27bdf7d492604696e01d7657da9.tar.gz rpg-cbf6ced732cfa27bdf7d492604696e01d7657da9.tar.bz2 |
test_suite_tuning
darcs-hash:20051012081013-e96b6-df581e5b94bb5e5ea1ed8693e754fd5877fbd164.gz
Diffstat (limited to 'test/lib')
-rw-r--r-- | test/lib/cli_reporter.php | 1 | ||||
-rw-r--r-- | test/lib/rss_writer_class.php | 1 | ||||
-rw-r--r-- | test/lib/testmanager.php | 111 | ||||
-rw-r--r-- | test/lib/web.inc.php | 1 | ||||
-rw-r--r-- | test/lib/xml_writer_class.php | 1 |
5 files changed, 73 insertions, 42 deletions
diff --git a/test/lib/cli_reporter.php b/test/lib/cli_reporter.php index e5eb76697..a65112a34 100644 --- a/test/lib/cli_reporter.php +++ b/test/lib/cli_reporter.php @@ -89,4 +89,3 @@ class CLIReporter extends SimpleReporter { } } } -?> diff --git a/test/lib/rss_writer_class.php b/test/lib/rss_writer_class.php index 7b9beae5f..684acfcfa 100644 --- a/test/lib/rss_writer_class.php +++ b/test/lib/rss_writer_class.php @@ -367,4 +367,3 @@ class rss_writer_class extends xml_writer_class }; } -?>
\ No newline at end of file diff --git a/test/lib/testmanager.php b/test/lib/testmanager.php index 6ad53b00d..abfef440f 100644 --- a/test/lib/testmanager.php +++ b/test/lib/testmanager.php @@ -2,12 +2,14 @@ /** * Lots TODO here... */ + +define('TEST_GROUPS',realpath(dirname(__FILE__).'/../cases')); +define('TEST_CASES',realpath(dirname(__FILE__).'/../cases')); + class TestManager { var $_testcase_extension = '.test.php'; var $_grouptest_extension = '.group.php'; - var $_webtest_extension = '.webtest.php'; - var $_webgrouptest_extension = '.webgroup.php'; - + function setup() { $ini_file = realpath(dirname(__FILE__).'/../tests.ini'); @@ -21,7 +23,7 @@ class TestManager { } TestManager::_installSimpleTest(); } - + function _installSimpleTest() { require_once SIMPLE_TEST . 'unit_tester.php'; require_once SIMPLE_TEST . 'web_tester.php'; @@ -39,9 +41,28 @@ class TestManager { $test->run($reporter); } - function runTestCase($testcase_file, &$reporter) { + function runTestCase($testcase_name, $test_case_directory, &$reporter) { $manager =& new TestManager(); + + $testcase_name = preg_replace('/[^a-zA-Z_:]/','',$testcase_name); + $testcase_name = str_replace(':',DIRECTORY_SEPARATOR,$testcase_name); + + $testcase_file = $test_case_directory . DIRECTORY_SEPARATOR . + strtolower($testcase_name) . $manager->_testcase_extension; + + if (! file_exists($testcase_file)) { + trigger_error("Test case {$testcase_file} cannot be found", + E_USER_ERROR); + } + $test =& new GroupTest("Individual test case: " . $testcase_name); + $test->addTestFile($testcase_file); + $test->run($reporter); + } + + function runTestFile($testcase_file, &$reporter) { + $manager =& new TestManager(); + if (! file_exists($testcase_file)) { trigger_error("Test case {$testcase_file} cannot be found", E_USER_ERROR); @@ -54,7 +75,8 @@ class TestManager { function runGroupTest($group_test_name, $group_test_directory, &$reporter) { $manager =& new TestManager(); - + $group_test_name = preg_replace('/[^a-zA-Z_:]/','',$group_test_name); + $group_test_name = str_replace(':',DIRECTORY_SEPARATOR,$group_test_name); $file_path = $group_test_directory . DIRECTORY_SEPARATOR . strtolower($group_test_name) . $manager->_grouptest_extension; @@ -85,10 +107,14 @@ class TestManager { } function &_getTestCaseList($directory = '.') { + $base = TEST_GROUPS . DIRECTORY_SEPARATOR; $file_list =& $this->_getTestFileList($directory); $testcases = array(); foreach ($file_list as $testcase_file) { - $testcases[$testcase_file] = str_replace($directory . '/', '', $testcase_file); + $case = str_replace($this->_testcase_extension, '',$testcase_file); + $case = str_replace($base, '', $case); + $case = str_replace(DIRECTORY_SEPARATOR, ':', $case); + $testcases[$testcase_file] = $case; } return $testcases; } @@ -109,11 +135,14 @@ class TestManager { } function &_getTestGroupList($directory = '.') { + $base = TEST_GROUPS . DIRECTORY_SEPARATOR; $file_list =& $this->_getTestGroupFileList($directory); $grouptests = array(); foreach ($file_list as $grouptest_file) { - $grouptests[$grouptest_file] = str_replace($this->_grouptest_extension, '', - basename($grouptest_file)); + $group = str_replace($this->_grouptest_extension, '',$grouptest_file); + $group = str_replace($base, '', $group); + $group = str_replace(DIRECTORY_SEPARATOR, ':', $group); + $grouptests[$grouptest_file] = $group; } sort($grouptests); return $grouptests; @@ -190,8 +219,8 @@ class CLITestManager extends TestManager { $test_cases =& $manager->_getTestCaseList($directory); $buffer = "Available test cases:\n"; - foreach ($test_cases as $test_case_file => $test_case) { - $buffer .= " " . $test_case_file . "\n"; + foreach ($test_cases as $test_case) { + $buffer .= " " . $test_case . "\n"; } return $buffer . "\n"; } @@ -211,7 +240,6 @@ class HTMLTestManager extends TestManager { function &getGroupTestList($directory = '.') { $manager =& new HTMLTestManager(); $group_tests =& $manager->_getTestGroupList($directory); - if (1 > count($group_tests)) { return "<p>No test groups set up!</p>"; } @@ -232,9 +260,9 @@ class HTMLTestManager extends TestManager { return "<p>No test cases set up!</p>"; } $buffer = "<p>Available test cases:</p>\n<ul>"; - foreach ($testcases as $testcase_file => $testcase) { + foreach ($testcases as $testcase) { $buffer .= "<li><a href='" . $manager->getBaseURL() . - "?case=" . urlencode($testcase_file) . "'>" . + "?case=" . urlencode($testcase) . "'>" . $testcase . "</a></li>\n"; } return $buffer . "</ul>\n"; @@ -278,8 +306,9 @@ class XMLTestManager extends HTMLTestManager { $rss->additem($properties); } - - $rss->writeRss($output); + if ( !$rss->writeRss($output) ) { + die ( $rss->error ); + } return $output; } @@ -296,15 +325,15 @@ class XMLTestManager extends HTMLTestManager { return $output; } - foreach ($testcases as $testcase_file => $testcase) { + foreach ($testcases as $testfile => $testcase) { $properties["title"]=$testcase; $properties["description"]=$testcase; $properties["link"]='http://'.$_SERVER['SERVER_NAME']. $manager->getBaseURL()."?case=" . - urlencode($testcase_file) . "&output=xml"; + urlencode($testcase) . "&output=xml"; // Comment this out for performance? - $properties["dc:date"]=gmdate("Y-m-d\TH:i:sO",filemtime($testcase_file)); + $properties["dc:date"]=gmdate("Y-m-d\TH:i:sO",filemtime($testfile)); $rss->additem($properties); } @@ -315,29 +344,29 @@ class XMLTestManager extends HTMLTestManager { function &_getRssWriter() { - $wact_url = 'http://'.$_SERVER['SERVER_NAME'].str_replace('index.php','',$_SERVER['PHP_SELF']); + $url = 'http://'.$_SERVER['SERVER_NAME'].str_replace('index.php','',$_SERVER['PHP_SELF']); require_once TEST_ROOT . '/lib/xml_writer_class.php'; require_once TEST_ROOT . '/lib/rss_writer_class.php'; $rss_writer_object=& new rss_writer_class(); $rss_writer_object->specification="1.0"; - $rss_writer_object->about=$wact_url."index.php?output=xml"; - $rss_writer_object->stylesheet=$wact_url."rss2html.xsl"; + $rss_writer_object->about=$url."index.php?output=xml"; + $rss_writer_object->stylesheet=$url."rss2html.xsl"; $rss_writer_object->rssnamespaces["dc"]="http://purl.org/dc/elements/1.1/"; // Channel Properties $properties=array(); - $properties["title"]="WACT Unit Test Cases"; - $properties["description"]="WACT Unit Test Cases"; - $properties["link"]="http://wact.sourceforge.net/"; + $properties["title"]="Dokuwiki Unit Test Cases"; + $properties["description"]="Dokuwiki Unit Test Cases"; + $properties["link"]="http://wiki.splitbrain.org/"; $properties["dc:date"]=gmdate("Y-m-d\TH:i:sO"); $rss_writer_object->addchannel($properties); // Logo like this (if we had one) /* $properties=array(); - $properties["url"]="http://www.phpclasses.org/graphics/logo.gif"; + $properties["link"]="http://www.phpclasses.org/"; $properties["title"]="PHP Classes repository logo"; $properties["description"]="Repository of components and other resources for PHP developers"; @@ -355,31 +384,39 @@ class XMLTestManager extends HTMLTestManager { class RemoteTestManager extends TestManager { function RemoteTestManager() { - parent::TestManager(); + RemoteTestManager::_installSimpleTest(); } function _installSimpleTest() { - parent::_installSimpleTest(); require_once SIMPLE_TEST . 'remote.php'; } function runAllTests(&$reporter, $url = FALSE) { $groups = RemoteTestManager::getGroupTestList($url); - $T = &new RemoteTestCase($groups['All Tests']); $T->run($reporter); } + + function runTestUrl($case_url,& $reporter, $url = FALSE) { + RemoteTestManager::_installSimpleTest(); + $T = &new RemoteTestCase($case_url); + $T->run($reporter); + } - function runTestCase($case_file,& $reporter, $url = FALSE) { + function runTestCase($case_id,& $reporter, $url = FALSE) { $cases = RemoteTestManager::getTestCaseList($url); - - $T = &new RemoteTestCase($cases[$case_file]); + if ( !array_key_exists($case_id, $cases) ) { + trigger_error("Unknown test id $case_id\n",E_USER_ERROR); + } + $T = &new RemoteTestCase($cases[$case_id]); $T->run($reporter); } function runGroupTest($group_name, &$reporter, $url = FALSE) { $groups = RemoteTestManager::getGroupTestList($url); - + if ( !array_key_exists($group_name, $groups) ) { + trigger_error("Unknown group $group_name\n",E_USER_ERROR); + } $T = &new RemoteTestCase($groups[$group_name]); $T->run($reporter); } @@ -387,11 +424,11 @@ class RemoteTestManager extends TestManager { function & getGroupTestList($url = FALSE) { if ( !$url ) { - $url = REMOTE_TEST_HTTP_PATH; + $url = REMOTE_TEST_URL; } $url .= '?output=xml'; - + $manager =& new RemoteTestManager(); $rss = & $manager->_getRssReader($url); @@ -406,11 +443,10 @@ class RemoteTestManager extends TestManager { function &getTestCaseList($url = FALSE) { if ( !$url ) { - $url = REMOTE_TEST_HTTP_PATH; + $url = REMOTE_TEST_URL; } $url .= '?show=cases&output=xml'; - $manager =& new RemoteTestManager(); $rss = & $manager->_getRssReader($url); @@ -438,4 +474,3 @@ class RemoteTestManager extends TestManager { } } -?> diff --git a/test/lib/web.inc.php b/test/lib/web.inc.php index 88020bd2a..7ca70f204 100644 --- a/test/lib/web.inc.php +++ b/test/lib/web.inc.php @@ -45,4 +45,3 @@ class DWWebTestCase extends WebTestCase { } } -?> diff --git a/test/lib/xml_writer_class.php b/test/lib/xml_writer_class.php index d82637e9b..97fb1bee0 100644 --- a/test/lib/xml_writer_class.php +++ b/test/lib/xml_writer_class.php @@ -290,4 +290,3 @@ class xml_writer_class }; } -?>
\ No newline at end of file |