示例#1
0
function caper_config_load($wd, $home = null, $default = false)
{
    $found = false;
    $config = null;
    $files = ["{$wd}/caper.yml", "{$wd}/caper.json"];
    if ($home) {
        $files[] = "{$home}/.caper.yml";
        $files[] = "{$home}/.caper.json";
    }
    foreach ($files as $file) {
        if (file_exists($file)) {
            $found = true;
            break;
        }
    }
    if ($found) {
        $config = \Caper\Config::fromFile($file, $wd);
    } elseif ($default) {
        $config = new \Caper\Config($wd);
    }
    return $config;
}
示例#2
0
文件: run.php 项目: shabbyrobe/caper
Run traces defined for a project in a caperfile

Usage: run [--show-class-names] [<script>...]

Reads configuration from caper.yml (see `caper help caperfile`
for more information) and runs 

DOCOPT;
$options = caper_opt_handle($usage);
$cwd = getcwd();
$configFile = "{$cwd}/caper.yml";
if (!file_exists($configFile)) {
    die("Config file not found\n");
}
$showClassNames = $options['--show-class-names'];
$config = \Caper\Config::fromYaml(file_get_contents($configFile), $cwd);
$runner = new \Caper\Trace\Runner();
$parser = new \Caper\Trace\Parser();
caper_header($cli);
scripts:
if ($options['<script>']) {
    foreach ($options['<script>'] as $script) {
        $cli->bold()->cyan()->out("Running script: {$script}")->br();
        $runner->run($config, $script);
    }
} else {
    $cli->bold()->cyan()->out("Running all scripts")->br();
    $runner->runAll($config);
}
parse:
$collector = new \Caper\Stack\Collector($config, $parser);
示例#3
0
    foreach ($options['<file>'] as $file) {
        $handle = fopen_arg($file, 'r');
        foreach ($parser->stackIterator($handle) as list($traceId, $popped, $stack)) {
            $out = (array) $popped;
            $out['trace'] = $traceId;
            $out['stack'] = $stack;
            $out['file'] = $file;
            echo json_encode($out) . "\n";
        }
    }
} elseif ($options['calls']) {
    $withSignatures = true;
    $showClassNames = $options['--show-class-names'];
    $cwd = getcwd();
    if ($options['--config']) {
        $config = \Caper\Config::fromYaml(file_get_contents($options['--config']), $cwd);
    } else {
        // TODO: config from args
        $filter = new \Caper\Filter();
        $filter->add(true, 'namespace', []);
        $config = new \Caper\Config($cwd, $filter);
        $withSignatures = false;
    }
    $traceFiles = $options['<file>'];
    parse:
    $collector = new \Caper\Stack\Collector($config, $parser);
    $cli->br()->bold()->cyan()->out("Parsing trace (this may take a while)")->br();
    foreach ($traceFiles as $file) {
        $collector->collect($file);
    }
    if ($withSignatures) {