<commit_before><?php
class GroupTest extends UnitTestCase
{
    protected $_testCases = array();

    public function __construct()
    {
        if (extension_loaded('xdebug')) {
            //xdebug_start_code_coverage(XDEBUG_CC_DEAD_CODE | XDEBUG_CC_UNUSED);
        }
    }

    public function addTestCase(UnitTestCase $testCase)
    {
        if($testCase instanceOf GroupTest) {
            $this->_testCases = array_merge($this->_testCases, $testCase->getTestCases());
         } else {
            $this->_testCases[get_class($testCase)] = $testCase;
         }
    }

    public function shouldBeRun($testCase, $filter){
        if( ! is_array($filter)) {
            return true;
         }
        foreach($filter as $subFilter) {
            $name = strtolower(get_class($testCase));
            $pos = strpos($name, strtolower($subFilter));
            //it can be 0 so we have to use === to see if false
            if ($pos === false) {
                return false;
             }
        }
        return true;
    }
    public function run(HtmlReporter $reporter = null, $filter = null)
    {
        $reporter->paintHeader();
        foreach ($this->_testCases as $k => $testCase) {
            if ( ! $this->shouldBeRun($testCase, $filter)) {
                continue;
            }
            $testCase->run();
            $this->_passed += $testCase->getPassCount();
            $this->_failed += $testCase->getFailCount();
            $this->_messages = array_merge($this->_messages, $testCase->getMessages());

            $this->_testCases[$k] = null;
            if(PHP_SAPI === "cli"){
                echo ".";
            }
            set_time_limit(900);
        }
        $reporter->setTestCase($this);
        
        $reporter->paintFooter();
    }


    public function getTestCaseCount()
    {<commit_msg>Added a try/catch block around the running of each test to catch unexpected exceptions and log them. <commit_after><?php
class GroupTest extends UnitTestCase
{
    protected $_testCases = array();

    public function __construct()
    {
        if (extension_loaded('xdebug')) {
            //xdebug_start_code_coverage(XDEBUG_CC_DEAD_CODE | XDEBUG_CC_UNUSED);
        }
    }

    public function addTestCase(UnitTestCase $testCase)
    {
        if($testCase instanceOf GroupTest) {
            $this->_testCases = array_merge($this->_testCases, $testCase->getTestCases());
         } else {
            $this->_testCases[get_class($testCase)] = $testCase;
         }
    }

    public function shouldBeRun($testCase, $filter){
        if( ! is_array($filter)) {
            return true;
         }
        foreach($filter as $subFilter) {
            $name = strtolower(get_class($testCase));
            $pos = strpos($name, strtolower($subFilter));
            //it can be 0 so we have to use === to see if false
            if ($pos === false) {
                return false;
             }
        }
        return true;
    }
    public function run(HtmlReporter $reporter = null, $filter = null)
    {
        $reporter->paintHeader();
        foreach ($this->_testCases as $k => $testCase) {
            if ( ! $this->shouldBeRun($testCase, $filter)) {
                continue;
            }
            try{
                $testCase->run();
            }catch(Exception $e){
                $this->_failed += 1;
                $this->_messages[] = "Unexpected exception thrown with message [" . $e->getMessage() . "] in " . get_class($testCase) . " on line " . $e->getLine();
            }
            $this->_passed += $testCase->getPassCount();
            $this->_failed += $testCase->getFailCount();
            $this->_messages = array_merge($this->_messages, $testCase->getMessages());

            $this->_testCases[$k] = null;
            if(PHP_SAPI === "cli"){
                echo ".";
            }
            set_time_limit(900);
        }
        $reporter->setTestCase($this);
        
        $reporter->paintFooter();
    }


    public function getTestCaseCount()
    {
{'fraction_non_alphanumeric': 0.13392636520879664, 'fraction_numerical': 0.002223869532987398, 'mean_word_length': 1.8729595457771469, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3572167', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1133, 'n_words': 234}