/** * Collect files under configured directories * @param boolean $recursive whether to get files recursively * @param boolean $new_only only get new files * @return boolean * @throws epExceptionCompiler */ protected function getConfiguredInputFiles($recursive = false, $new_only = false) { // check input directories and collect files to compile if (!($source_dirs = $this->getConfigOption('source_dirs'))) { throw new epExceptionCompiler('No input directories specified'); return false; } // clean up existing collection $input_files = array(); // collect files in each input dir $source_dirs = explode(',', $source_dirs); foreach ($source_dirs as $input_dir) { // if input dir is a relative path, make is absolute $input_dir = $this->getAbsolutePath($input_dir); // check if path is dir if (!is_dir($input_dir)) { throw new epExceptionCompiler('Input path [' . $input_dir . '] is not a direcotry. Ignored.'); continue; } // check if dir exists if (!file_exists($input_dir)) { throw new epExceptionCompiler('Input path [' . $input_dir . '] does not exist. Ignored.'); continue; } // collect all files in dir $files_in_dir = epFilesInDir($input_dir, $recursive, true); // true: absolute path if ($files_in_dir) { $input_files = array_merge($input_files, $files_in_dir); } } // weed out non-source files $input_files = $this->getOnlySourceFiles($input_files); // if force_compile is disabled, only parse new files if ($new_only) { $input_files = $this->getNewFiles($input_files); } return $input_files; }
/** * Get all files (w/ full path) under directory * @param string directcory * @param bool true for recursive get * @param bool true for absolute path * @return array */ function epFilesInDir($dir = '.', $recursive = true, $absolute_path = true) { $files_in_dir = array(); // done if dir does not exist or is not a dir if (!file_exists($dir) || !is_dir($dir)) { return $files_in_dir; } // scan directory for files $entities = scandir($dir); if (!is_array($entities)) { return $files_in_dir; } // go through each file/dir foreach ($entities as $entity) { // ignore . and .. if ($entity == '.' || $entity == '..') { continue; } // get the path of the entity $path = $dir . '/' . $entity; // check if path is a file if (is_file($path)) { // rest is treated as a file if ($absolute_path) { $files_in_dir[] = realpath($path); } else { $files_in_dir[] = $path; } continue; } // check if path is a dir if (is_dir($path) && $recursive) { $files_in_dir = array_merge($files_in_dir, epFilesInDir($path, $recursive)); } } return $files_in_dir; }
/** * Test function epFilesInDir() in epUtils.php */ function test_epFilesInDir() { // make sure method exists $this->assertTrue(function_exists('epFilesInDir')); // get all files under EP_ROOT $files = epFilesInDir(EP_ROOT); $this->assertTrue(count($files) > 0); }
include_once EP_SRC_BASE . '/epUtils.php'; /**#@+ * need simpletest */ include_once EP_LIBS_SIMPLETEST . '/unit_tester.php'; include_once EP_LIBS_SIMPLETEST . '/reporter.php'; /**#@-*/ /** * Includes coveverage test */ if (EP_COVERAGE_TEST) { include_once dirname(__FILE__) . '/coverage.php'; } $t = new GroupTest('All ezpdo tests'); // get all epTestXxxx files $files = epFilesInDir(); // add each test file into group foreach ($files as $file) { // get file base name $filename = basename($file); // exclude this script if ($filename == basename(__FILE__)) { continue; } // exclude epTestCase.php if ($filename == 'epTestCase.php') { continue; } // exclude epTestRuntime.php if ($filename == 'epTestRuntime.php') { continue;