コード例 #1
0
ファイル: coverage-report.php プロジェクト: redhead/mockyll
<?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 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);
}