Beispiel #1
0
/**
 * Recursively scans a directory, building an array of files
 * The array of files will match the pattern $xtn. Anything begining
 * with a dot (.) will be skipped
 * @param $path string a starting path, during recursion it's current path
 * @param $xtn string a regular expression to match for files
 * @return array
 **/
function SNAP_recurse_directory($path, $xtn)
{
    if (!is_dir($path)) {
        return array($path);
    }
    $file_list = array();
    $handle = opendir($path);
    while (FALSE !== ($file = readdir($handle))) {
        if (substr($file, 0, 1) == '.') {
            continue;
        }
        if (substr($path, -1) == DIRECTORY_SEPARATOR) {
            $file = $path . $file;
        } else {
            $file = $path . DIRECTORY_SEPARATOR . $file;
        }
        // recursion on directory
        if (is_dir($file)) {
            $file_list = array_merge($file_list, SNAP_recurse_directory($file, $xtn));
            continue;
        }
        // is a file, check xtn
        if (!preg_match('#' . $xtn . '#', $file)) {
            continue;
        }
        // valid, add
        $file_list[] = $file;
    }
    return $file_list;
}
Beispiel #2
0
<?php

// getfiles module. gets a list of files and returns them
// generate list of files to test
if (is_dir(SNAP_WI_TEST_PATH)) {
    $file_list = SNAP_recurse_directory(SNAP_WI_TEST_PATH, SNAP_WI_TEST_MATCH);
} else {
    $file_list = array(SNAP_WI_TEST_PATH);
}
if (SNAP_WI_CRYPT) {
    foreach ($file_list as $idx => $file) {
        $file_list[$idx] = snap_encrypt($file, SNAP_WI_CRYPT);
    }
}
echo json_encode($file_list);
exit;
Beispiel #3
0
    $snap = new Snap_Tester('phpserializer');
    // unencode
    $test = Snap_Request::decodeTestKey($test);
    // include the file, so that all base components are there
    require_once $test['file'];
    // add the class now that it exists
    $snap->addInput('local', $test['class']);
    writelog('Doing test substep: ' . $test['class'] . '::' . $test['method']);
    // run tests with an exact match on the test name
    $snap->runTests('^' . $test['method'] . '$');
    echo SNAP_STREAM_ENDING_TOKEN;
    exit;
}
// generate list of files to test
if (is_dir($path)) {
    $file_list = SNAP_recurse_directory($path, $xtn);
} else {
    $file_list = array($path);
}
writelog('Path contains ' . count($file_list) . ' files for scanning');
// start a dispatcher for multi-processing
$dispatcher = new Snap_Dispatcher($php, __FILE__);
// build master test list
$analyzer = new Snap_FileAnalyzer();
$master_test_list = $dispatcher->dispatch(array('keys' => $file_list, 'dispatch' => array('analyze' => TRUE, 'verbose' => SNAPTEST_VERBOSE_MODE, 1 => '__KEY__'), 'onThreadComplete' => array($analyzer, 'onThreadComplete'), 'onThreadFail' => array($analyzer, 'onThreadFail'), 'onComplete' => array($analyzer, 'onComplete')));
unset($analyzer);
// build a master test key list
$master_test_key_list = array();
foreach ($master_test_list as $file => $classes) {
    if (!is_array($classes)) {
        die("File {$file} could not be read due to a fatal error:\n" . $classes . "\n");