Changeset 136

Show
Ignore:
Timestamp:
03/05/08 10:28:47 (10 months ago)
Author:
iteman
Message:

- Changed code so that the test directory is always added to the target directories for autotest.

Files:
1 modified

Legend:

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

    r134 r136  
    171171    /** 
    172172     * Watches for changes in one or more target directories and runs tests in 
    173      * the test directory recursively when changes are detected. 
     173     * the test directory recursively when changes are detected. And also the test 
     174     * directory is always added to the target directories. 
    174175     * 
    175176     * @param stdClass $config 
     
    178179    private static function _monitorAlteration($config) 
    179180    { 
    180         if (!count($config->targetDirectories)) { 
    181             $directories = (array)$config->directory; 
    182         } else { 
    183             $directories = $config->targetDirectories; 
    184         } 
    185  
    186         for ($i = 0, $count = count($directories); $i < $count; ++$i) { 
    187             if (!is_dir($directories[$i])) { 
    188                 throw new Stagehand_TestRunner_Exception("ERROR: A specified path [ {$directories[$i]} ] is not found or not a directory."); 
    189             } 
    190  
    191             $directories[$i] = realpath($directories[$i]); 
    192             if ($directories[$i] === false) { 
    193                 throw new Stagehand_TestRunner_Exception("ERROR: Cannnot get the absolute path of a specified directory [ {$directories[$i]} ]. Make sure all elements of the absolute path have valid permissions."); 
     181        $targetDirectories = array(); 
     182        foreach (array_merge($config->targetDirectories, (array)$config->directory) 
     183                 as $directory 
     184                 ) { 
     185            if (!is_dir($directory)) { 
     186                throw new Stagehand_TestRunner_Exception("ERROR: A specified path [ $directory ] is not found or not a directory."); 
     187            } 
     188 
     189            $directory = realpath($directory); 
     190            if ($directory === false) { 
     191                throw new Stagehand_TestRunner_Exception("ERROR: Cannnot get the absolute path of a specified directory [ $directory ]. Make sure all elements of the absolute path have valid permissions."); 
     192            } 
     193 
     194            if (!in_array($directory, $targetDirectories)) { 
     195                $targetDirectories[] = $directory; 
    194196            } 
    195197        } 
     
    232234        $options[] = $config->directory; 
    233235 
    234         $monitor = new Stagehand_TestRunner_AlterationMonitor($directories, 
     236        $monitor = new Stagehand_TestRunner_AlterationMonitor($targetDirectories, 
    235237                                                              "$command " . implode(' ', $options) 
    236238                                                              );