Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Commit

Permalink
Update script file for coverallskit
Browse files Browse the repository at this point in the history
  • Loading branch information
holyshared committed Sep 16, 2014
1 parent 01a8a80 commit 2eb0d7e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 53 deletions.
8 changes: 8 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
service: travis-ci
reportFile:
input:
type: lcov
file: script/report.lcov
output: script/coveralls.json
repositoryDirectory: .

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ before_install:
- composer self-update
- composer install
script:
- ./vendor/bin/pho --stop
- php script/coverage.php
after_script: php script/coveralls.php
3 changes: 0 additions & 3 deletions coveralls.yml

This file was deleted.

54 changes: 5 additions & 49 deletions script/coveralls.php
Original file line number Diff line number Diff line change
@@ -1,56 +1,12 @@
<?php

namespace cloak\example;
namespace cloak\reporter;

require_once __DIR__ . '/../vendor/autoload.php';

use coverallskit\ConfigurationLoader;
use coverallskit\ReportBuilderFactory;
use coverallskit\entity\Coverage;
use coverallskit\entity\Repository;
use coverallskit\entity\SourceFile;
use coverallskit\exception\LineOutOfRangeException;

/**
* Get the code coverage
*/
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);

$argv = ['../vendor/bin/pho'];

require_once __DIR__ . "/../vendor/bin/pho";

$result = xdebug_get_code_coverage();
xdebug_stop_code_coverage();

/**
* Generate a json file
*/
$factory = new ReportBuilderFactory(new ConfigurationLoader());

$builder = $factory->createFromConfigurationFile(__DIR__ . '/../coveralls.yml');

foreach ($result as $file => $coverage) {
if (preg_match('/vendor/', $file) || preg_match('/spec/', $file)) {
continue;
}

$source = new SourceFile($file);

foreach ($coverage as $line => $status) {
try {
if ($status === 1) {
$source->addCoverage(Coverage::executed($line));
} else if ($status === -1) {
$source->addCoverage(Coverage::unused($line));
}
} catch (LineOutOfRangeException $exception) {
echo $source->getName() . PHP_EOL;
echo $exception->getMessage() . PHP_EOL;
}
}

$builder->addSource($source);
}
use coverallskit\Configuration;
use coverallskit\ReportBuilder;

$configuration = Configuration::loadFromFile('.coveralls.yml');
$builder = ReportBuilder::fromConfiguration($configuration);
$builder->build()->save()->upload();

0 comments on commit 2eb0d7e

Please sign in to comment.