コード例 #1
0
ファイル: tester.php プロジェクト: petrparolek/web_cms
if ($options['--info']) {
    $job = new Tester\Runner\Job(__DIR__ . '/Runner/info.php', $php);
    $job->run();
    echo $job->getOutput();
    exit;
}
if ($options['--coverage']) {
    if (!$php->hasXdebug()) {
        throw new Exception("Code coverage functionality requires Xdebug extension (used {$php->getCommandLine()})");
    }
    file_put_contents($options['--coverage'], '');
    $coverageFile = realpath($options['--coverage']);
    putenv(Tester\Environment::COVERAGE . '=' . $coverageFile);
    echo "Code coverage: {$coverageFile}\n";
}
$runner = new Tester\Runner\Runner($php);
$runner->paths = $options['paths'];
$runner->threadCount = max(1, (int) $options['-j']);
$runner->stopOnFail = $options['--stop-on-fail'];
$runner->outputHandlers[] = $options['--tap'] ? new Tester\Runner\Output\TapPrinter($runner) : new Tester\Runner\Output\ConsolePrinter($runner, $options['-s']);
if ($options['--log']) {
    echo "Log: {$options['--log']}\n";
    $runner->outputHandlers[] = new Tester\Runner\Output\Logger($runner, $options['--log']);
}
if ($options['--setup']) {
    call_user_func(function () use($runner) {
        require func_get_arg(0);
    }, $options['--setup']);
}
if ($options['--tap']) {
    ob_end_clean();
コード例 #2
0
ファイル: tester.php プロジェクト: jakuborava/walletapp
Tester\Environment::setup();
$cmd = new Cmd("\nNette Tester (v0.9.5)\n---------------------\nUsage:\n\ttester.php [options] [<test file> | <directory>]...\n\nOptions:\n\t-p <path>            Specify PHP executable to run (default: php-cgi).\n\t-c <path>            Look for php.ini in directory <path> or use <path> as php.ini.\n\t-log <path>          Write log to file <path>.\n\t-d <key=value>...    Define INI entry 'key' with value 'val'.\n\t-s                   Show information about skipped tests.\n\t--tap                Generate Test Anything Protocol.\n\t-j <num>             Run <num> jobs in parallel.\n\t-w | --watch <path>  Watch directory.\n\t--colors [1|0]       Enable or disable colors.\n\t-h | --help          This help.\n\n", array('-c' => array(Cmd::REALPATH => TRUE), '--watch' => array(Cmd::REPEATABLE => TRUE, Cmd::REALPATH => TRUE), 'paths' => array(Cmd::REPEATABLE => TRUE, Cmd::VALUE => getcwd()), '--debug' => array()));
$options = $cmd->parse();
Tester\Environment::$debugMode = (bool) $options['--debug'];
if (isset($options['--colors'])) {
    Tester\Environment::$useColors = (bool) $options['--colors'];
}
if ($cmd->isEmpty() || $options['--help']) {
    $cmd->help();
    exit;
}
$phpArgs = $options['-c'] ? '-n -c ' . escapeshellarg($options['-c']) : '-n';
foreach ($options['-d'] as $item) {
    $phpArgs .= ' -d ' . escapeshellarg($item);
}
$runner = new Tester\Runner\Runner(new Tester\Runner\PhpExecutable($options['-p'], $phpArgs));
$runner->paths = $options['paths'];
$runner->jobCount = max(1, (int) $options['-j']);
$runner->outputHandlers[] = $options['--tap'] ? new Tester\Runner\Output\TapPrinter($runner) : new Tester\Runner\Output\ConsolePrinter($runner, $options['-s']);
if ($options['-log']) {
    echo "Log: {$options['-log']}\n";
    $runner->outputHandlers[] = new Tester\Runner\Output\Logger($runner, $options['-log']);
}
@unlink(__DIR__ . '/coverage.dat');
// @ - file may not exist
if (!$options['--watch']) {
    die($runner->run() ? 0 : 1);
}
$prev = array();
$counter = 0;
while (TRUE) {