'file', 'h' => 'help', 'v' => 'verbose', ); // It's important that this does not call the autoloader. Not a problem // with a function, but could be if we put this in a class. htmlpurifier_parse_args($AC, $aliases); if ($AC['help']) { ?>HTML Purifier test suite Allowed options: --flush --standalone --file (-f) HTMLPurifier/NameOfTest.php --xml --txt --dry --php /path/to/php --type ( htmlpurifier | configdoc | fstools | htmlt | vtest | phpt ) --disable-phpt --verbose (-v) addDecorator('Memory'); // since we deal with a lot of config objects if (!$AC['disable-phpt']) { $phpt = PHPT_Registry::getInstance(); $phpt->php = $AC['php']; } // load tests require 'test_files.php'; $FS = new FSTools(); // handle test dirs foreach ($test_dirs as $dir) { $raw_files = $FS->globr($dir, '*Test.php'); foreach ($raw_files as $file) { $file = str_replace('\\', '/', $file); if (isset($test_dirs_exclude[$file])) continue; $test_files[] = $file; } } // handle vtest dirs foreach ($vtest_dirs as $dir) { $raw_files = $FS->globr($dir, '*.vtest'); foreach ($raw_files as $file) { $test_files[] = str_replace('\\', '/', $file); } } // handle phpt files foreach ($phpt_dirs as $dir) { $phpt_files = $FS->globr($dir, '*.phpt'); foreach ($phpt_files as $file) { $test_files[] = str_replace('\\', '/', $file); } } // handle htmlt dirs foreach ($htmlt_dirs as $dir) { $htmlt_files = $FS->globr($dir, '*.htmlt'); foreach ($htmlt_files as $file) { $test_files[] = str_replace('\\', '/', $file); } } array_unique($test_files); sort($test_files); // for the SELECT $GLOBALS['HTMLPurifierTest']['Files'] = $test_files; // for the reporter $test_file_lookup = array_flip($test_files); // determine test file if ($AC['file']) { if (!isset($test_file_lookup[$AC['file']])) { echo "Invalid file passed\n"; exit; } } if ($AC['file']) { $test = new TestSuite($AC['file']); htmlpurifier_add_test($test, $AC['file']); } else { $standalone = ''; if ($AC['standalone']) $standalone = ' (standalone)'; $test = new TestSuite('All HTML Purifier tests on PHP ' . PHP_VERSION . $standalone); foreach ($test_files as $test_file) { htmlpurifier_add_test($test, $test_file); } } if ($AC['dry']) $reporter->makeDry(); $test->run($reporter); // vim: et sw=4 sts=4