Skip to content

Commit

Permalink
Merge pull request #10 from datashaman/develop
Browse files Browse the repository at this point in the history
Various Changes
  • Loading branch information
datashaman authored Apr 16, 2019
2 parents cbf5228 + a65912c commit ec17d74
Show file tree
Hide file tree
Showing 16 changed files with 297 additions and 157 deletions.
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ phpcheck:

phpcheck-coverage-html:
@phpcheck --coverage-html build/coverage
@xdg-open build/coverage/index.html

phpcheck-coverage-text:
phpcheck-coverage-console:
@phpcheck --coverage-text

phpcheck-coverage-text:
@phpcheck --coverage-text build/coverage.txt

phpcheck-log-junit:
@phpcheck --log-junit build/phpcheck.xml

phpcheck-log-text:
@phpcheck --log-text build/phpcheck.txt

phpcheck-no-defects:
@phpcheck -d

Expand Down
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,22 @@ The `phpcheck` program accept a number of arguments and options:
path File or folder with checks [default: "checks"]

Options:
--bootstrap[=BOOTSTRAP] A PHP script that is included before the checks run
-f, --filter[=FILTER] Filter the checks that will be run
-i, --iterations=ITERATIONS How many times each check will be run [default: 100]
-j, --log-junit[=LOG-JUNIT] Log check execution in JUnit XML format to file
-d, --no-defects[=NO-DEFECTS] Ignore previous defects [default: false]
-h, --help Display this help message
-q, --quiet Do not output any message
-s, --seed[=SEED] Seed the random number generator to get repeatable runs
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--bootstrap[=BOOTSTRAP] A PHP script that is included before the checks run
--coverage-html[=COVERAGE-HTML] Generate HTML code coverage report [default: false]
--coverage-text[=COVERAGE-TEXT] Generate text code coverage report [default: false]
-f, --filter[=FILTER] Filter the checks that will be run
-i, --iterations=ITERATIONS How many times each check will be run [default: 100]
-j, --log-junit[=LOG-JUNIT] Log check execution to JUnit XML file [default: false]
-t, --log-text[=LOG-TEXT] Log check execution to text file [default: false]
-d, --no-defects[=NO-DEFECTS] Ignore previous defects [default: false]
-h, --help Display this help message
-q, --quiet Do not output any message
-s, --seed[=SEED] Seed the random number generator to get repeatable runs
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

The `--bootstrap` parameter can be included in a _phpcheck.xml_ or _phpcheck.xml.dist_ file. See [ours](phpcheck.xml.dist) for an example.

Expand Down
5 changes: 5 additions & 0 deletions bin/phpcheck
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ foreach ($autoloaders as $file) {
unset($file);

use Datashaman\PHPCheck\CheckCommand;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use Symfony\Component\Console\Application;

$coverage = new CodeCoverage();
$coverage->filter()->addDirectoryToWhitelist('./src');
$coverage->start('phpcheck');

$application = new Application('phpcheck', CheckCommand::VERSION);
$command = new CheckCommand();
$application->add($command);
Expand Down
6 changes: 5 additions & 1 deletion phpcheck.xml.dist
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpcheck bootstrap="vendor/autoload.php">
<!-- TODO
<suites>
<suite name="Checks">
<directory suffix="Check.php">./checks</directory>
</suite>
</suites>
-->
<!--
<subscribers>
<subscriber />
<subscriber class="Datashaman\PHPCheck\Subscribers\TestSubscriber" />
</subscribers>
-->
</phpcheck>
7 changes: 4 additions & 3 deletions src/CheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ protected function configure(): void
$this
->setDescription('Run checks.')
->addOption('bootstrap', null, InputOption::VALUE_OPTIONAL, 'A PHP script that is included before the checks run')
->addOption('coverage-html', null, InputOption::VALUE_OPTIONAL, 'Generate code coverage report in HTML', false)
->addOption('coverage-text', null, InputOption::VALUE_OPTIONAL, 'Generate code coverage report in text', false)
->addOption('coverage-html', null, InputOption::VALUE_OPTIONAL, 'Generate HTML code coverage report', false)
->addOption('coverage-text', null, InputOption::VALUE_OPTIONAL, 'Generate text code coverage report', false)
->addOption('filter', 'f', InputOption::VALUE_OPTIONAL, 'Filter the checks that will be run')
->addOption('iterations', 'i', InputOption::VALUE_REQUIRED, 'How many times each check will be run', Runner::MAX_ITERATIONS)
->addOption('log-junit', 'j', InputOption::VALUE_OPTIONAL, 'Log check execution in JUnit XML format to file')
->addOption('log-junit', 'j', InputOption::VALUE_OPTIONAL, 'Log check execution to JUnit XML file', false)
->addOption('log-text', 't', InputOption::VALUE_OPTIONAL, 'Log check execution to text file', false)
->addOption('no-defects', 'd', InputOption::VALUE_OPTIONAL, 'Ignore previous defects', false)
->addOption('seed', 's', InputOption::VALUE_OPTIONAL, 'Seed the random number generator to get repeatable runs')
->addArgument('path', InputArgument::OPTIONAL, 'File or folder with checks', 'checks');
Expand Down
29 changes: 29 additions & 0 deletions src/Coverage/Coverage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php declare(strict_types=1);
/*
* This file is part of the phpcheck package.
*
* ©Marlin Forbes <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Datashaman\PHPCheck\Coverage;

use Datashaman\PHPCheck\Runner;

abstract class Coverage
{
protected $input;

public function __construct(Runner $runner)
{
$this->input = $runner->getInput();
}

public function __destruct()
{
global $coverage;

$coverage->stop();
}
}
25 changes: 25 additions & 0 deletions src/Coverage/HtmlCoverage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php declare(strict_types=1);
/*
* This file is part of the phpcheck package.
*
* ©Marlin Forbes <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Datashaman\PHPCheck\Coverage;

use SebastianBergmann\CodeCoverage\Report\Html\Facade as HtmlFacade;

class HtmlCoverage extends Coverage
{
public function __destruct()
{
global $coverage;

parent::__destruct();

$writer = new HtmlFacade();
$writer->process($coverage, $this->input->getOption('coverage-html'));
}
}
39 changes: 39 additions & 0 deletions src/Coverage/TextCoverage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php declare(strict_types=1);
/*
* This file is part of the phpcheck package.
*
* ©Marlin Forbes <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Datashaman\PHPCheck\Coverage;

use SebastianBergmann\CodeCoverage\Report\Text;

class TextCoverage extends Coverage
{
public function __destruct()
{
global $coverage;

parent::__destruct();

$writer = new Text();

if ($this->input->getOption('coverage-text')) {
$output = $writer->process($coverage, false);
\file_put_contents($this->input->getOption('coverage-text'), $output);

return;
}

$color = true;

if ($this->input->getOption('no-ansi') !== false) {
$color = false;
}

print $writer->process($coverage, $color);
}
}
57 changes: 0 additions & 57 deletions src/Reporters/HtmlCoverageReporter.php

This file was deleted.

61 changes: 0 additions & 61 deletions src/Reporters/TextCoverageReporter.php

This file was deleted.

Loading

0 comments on commit ec17d74

Please sign in to comment.