Skip to content

Commit

Permalink
Fix / improve travis output
Browse files Browse the repository at this point in the history
- Fix code coverage and php-cs-fixer colors
- Round code coverage percentage
  • Loading branch information
EvanDotPro committed Sep 15, 2012
1 parent 19199e7 commit 159fe33
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ before_install:
script:
- phpunit -c test/phpunit.xml
- ./test/coverage-checker test/clover.xml 95
- output=$(php php-cs-fixer.phar fix -v --no-interaction --dry-run --level=all .); if [[ $output ]]; then while read -r line; do echo -e "\e[1;31m$line\e[0m"; done <<< "$output"; false; fi;
- output=$(php php-cs-fixer.phar fix -v --no-interaction --dry-run --level=all .); echo ""; if [[ $output ]]; then while read -r line; do echo -e "\e[37;41m$line\e[00m"; done <<< "$output"; false; else echo -e "\e[30;42mCoding standards are OK\e[0m"; fi;
12 changes: 9 additions & 3 deletions test/coverage-checker
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ foreach ($metrics as $metric) {
$checkedElements += (int) $metric['coveredelements'];
}

$coverage = ($checkedElements / $totalElements) * 100;
$coverage = round(($checkedElements / $totalElements) * 100);

echo PHP_EOL;

if ($coverage < $percentage) {
echo "\e[1;31mCode coverage is {$coverage}%, which is below the accepted {$percentage}%\e[0m" . PHP_EOL;
echo "\x1b[37;41m";
echo "Code coverage is {$coverage}%, which is below the accepted {$percentage}";
echo "\x1b[0m" . PHP_EOL . PHP_EOL;
exit(1);
}

echo "\e[1;32mCode coverage is {$coverage}% - OK!\e[0m" . PHP_EOL;
echo "\x1b[30;42m";
echo "Code coverage is {$coverage}% - OK!";
echo "\x1b[0m" . PHP_EOL . PHP_EOL;

0 comments on commit 159fe33

Please sign in to comment.