Changeset 150

Show
Ignore:
Timestamp:
04/26/08 00:29:38 (9 months ago)
Author:
iteman
Message:

- Fixed a defect that caused tests to be run every time if fileperms()/filemtime() fails when using autotest.

Location:
trunk/src/Stagehand/TestRunner
Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/Stagehand/TestRunner/AlterationMonitor.php

    r144 r150  
    3838require_once 'Stagehand/TestRunner/Exception.php'; 
    3939require_once 'Stagehand/TestRunner/DirectoryScanner.php'; 
     40require_once 'Stagehand/TestRunner/DirectoryScanner/Exception.php'; 
    4041 
    4142// {{{ Stagehand_TestRunner_AlterationMonitor 
     
    140141     * @param string $element 
    141142     * @throws Stagehand_TestRunner_Exception 
     143     * @throws Stagehand_TestRunner_DirectoryScanner_Exception 
    142144     */ 
    143145    public function detectChanges($element) 
    144146    { 
    145147        if (!$this->_isFirstTime) { 
     148            $perms = fileperms($element); 
     149            if ($perms === false) { 
     150                throw new Stagehand_TestRunner_DirectoryScanner_Exception(); 
     151            } 
     152 
    146153            if (!array_key_exists($element, $this->_previousElements)) { 
    147154                throw new Stagehand_TestRunner_Exception(); 
    148155            } 
    149156 
     157            if ($this->_previousElements[$element]['perms'] != $perms) { 
     158                throw new Stagehand_TestRunner_Exception(); 
     159            } 
     160 
    150161            if (!is_dir($element)) { 
    151162                $mtime = filemtime($element); 
     163                if ($mtime === false) { 
     164                    throw new Stagehand_TestRunner_DirectoryScanner_Exception(); 
     165                } 
     166 
    152167                if ($this->_previousElements[$element]['mtime'] != $mtime) { 
    153168                    throw new Stagehand_TestRunner_Exception(); 
    154169                } 
    155170            } 
    156  
    157             $perms = fileperms($element); 
    158             if ($this->_previousElements[$element]['perms'] != $perms) { 
    159                 throw new Stagehand_TestRunner_Exception(); 
    160             } 
    161         } 
    162  
     171        } 
     172 
     173        $perms = fileperms($element); 
     174        if ($perms === false) { 
     175            throw new Stagehand_TestRunner_DirectoryScanner_Exception(); 
     176        } 
     177 
     178        $this->_currentElements[$element]['perms'] = $perms; 
    163179        if (!is_dir($element)) { 
    164             $this->_currentElements[$element]['mtime'] = filemtime($element); 
    165         } 
    166  
    167         $this->_currentElements[$element]['perms'] = fileperms($element); 
     180            $mtime = filemtime($element); 
     181            if ($mtime === false) { 
     182                throw new Stagehand_TestRunner_DirectoryScanner_Exception(); 
     183            } 
     184 
     185            $this->_currentElements[$element]['mtime'] = $mtime; 
     186        } 
    168187    } 
    169188 
  • trunk/src/Stagehand/TestRunner/DirectoryScanner.php

    r134 r150  
    3535 * @since      File available since Release 2.1.0 
    3636 */ 
     37 
     38require_once 'Stagehand/TestRunner/DirectoryScanner/Exception.php'; 
    3739 
    3840// {{{ Stagehand_TestRunner_DirectoryScanner 
     
    123125 
    124126            $element = $directory . DIRECTORY_SEPARATOR . $files[$i]; 
    125             call_user_func($this->_callback, $element); 
     127            try { 
     128                call_user_func($this->_callback, $element); 
     129            } catch (Stagehand_TestRunner_DirectoryScanner_Exception $e) { 
     130                continue; 
     131            } 
    126132 
    127133            if (is_dir($element) && $this->_isRecursive) {