示例#1
0
    call_user_func(function () use($runner) {
        require func_get_arg(0);
    }, $options['--setup']);
}
if ($options['--tap']) {
    ob_end_clean();
} else {
    ob_end_flush();
}
if (!$options['--watch']) {
    $result = $runner->run();
    if (preg_match('#\\.html?\\z#', $options['--coverage'])) {
        if (!$options['--tap']) {
            echo "Generating code coverage report\n";
        }
        $generator = new Tester\CodeCoverage\ReportGenerator($coverageFile, $options['--coverage-src']);
        $generator->render($coverageFile);
    }
    die($result ? 0 : 1);
}
$prev = array();
$counter = 0;
while (TRUE) {
    $state = array();
    foreach ($options['--watch'] as $directory) {
        foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
            if (substr($file->getExtension(), 0, 3) === 'php') {
                $state[(string) $file] = md5_file((string) $file);
            }
        }
    }
示例#2
0
<?php

/**
 * Code coverage HTML report generator.
 *
 * This file is part of the Nette Tester.
 */
require __DIR__ . '/CodeCoverage/ReportGenerator.php';
require __DIR__ . '/Runner/CommandLine.php';
use Tester\Runner\CommandLine as Cmd;
$cmd = new Cmd("\nCode coverage HTML report generator\n-----------------------------------\n\nUsage:\n\tphp coverage-report.php [options]\n\nOptions:\n\t-c <path>    coverage.dat file (default: coverage.dat)\n\t-s <path>    directory with source code\n\t-o <path>    output file (default: coverage.html)\n\t-t <title>   title of generated documentation\n\t-h | --help  this help\n\n", array('-c' => array(Cmd::REALPATH), '-s' => array(Cmd::REALPATH)));
$options = $cmd->parse();
if ($cmd->isEmpty()) {
    $cmd->help();
} elseif ($options['--help']) {
    $cmd->help();
    exit;
}
try {
    $generator = new Tester\CodeCoverage\ReportGenerator($options['-c'], $options['-s'], $options['-t']);
    if ($options['-o'] === '-') {
        $generator->render();
    } else {
        echo "Generating report to {$options['-o']}\n";
        $generator->render($options['-o']);
        echo "Done.\n";
    }
} catch (Exception $e) {
    echo "Error: {$e->getMessage()}\n";
    die(254);
}