示例#1
0
$test = $options['test'];
$klass = $options['klass'];
// decrypt if required
if (SNAP_WI_CRYPT) {
    $file = snap_decrypt($file, SNAP_WI_CRYPT);
}
// ensure file path matches test path prefix
$file = str_replace(array('..', '//'), array('.', '/'), $file);
if (!is_file($file)) {
    echo '';
    exit;
}
if (strpos($file, SNAP_WI_TEST_PATH) !== 0 || !preg_match('#' . SNAP_WI_TEST_MATCH . '#', $file)) {
    echo '';
    exit;
}
// file is safe, check test and klass
if (!$test || !$klass) {
    echo '';
    exit;
}
// now, test
// new reporter in phpserializer mode
$snap = new Snap_Tester('json');
// include the file, so that all base components are there
require_once $file;
// add the class now that it exists
$snap->addInput('local', $klass);
// run tests with an exact match on the test name
$snap->runTests('^' . $test . '$');
exit;
示例#2
0
    echo SNAPTEST_TOKEN_START;
    echo serialize($results);
    echo SNAPTEST_TOKEN_END;
    echo SNAP_STREAM_ENDING_TOKEN;
    exit;
}
// test subprocess
if ($test) {
    // new reporter in phpserializer mode
    $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__);