Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...) http://blog.slucas.fr/en/oss/calibre-opds-php-server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2KB

  1. <?php
  2. /**
  3. * Code coverage checker. Analyzes a given `clover.xml` report produced
  4. * by PHPUnit and checks if coverage fits expected ratio
  5. *
  6. * Usage:
  7. * php coverage-checker <path-to-clover> <pass-percentage>
  8. *
  9. * @author Marco Pivetta <ocramius@gmail.com>
  10. * @see http://ocramius.github.io/blog/automated-code-coverage-check-for-github-pull-requests-with-travis/
  11. */
  12. $inputFile = $argv[1];
  13. $percentage = min(100, max(0, (int) $argv[2]));
  14. if (!file_exists($inputFile)) {
  15. echo 'Invalid input file provided';
  16. exit (0);
  17. }
  18. if (!$percentage) {
  19. throw new InvalidArgumentException('An integer checked percentage must be given as second parameter');
  20. }
  21. $xml = new SimpleXMLElement(file_get_contents($inputFile));
  22. $metrics = $xml->xpath('//metrics');
  23. $totalElements = 0;
  24. $checkedElements = 0;
  25. foreach ($metrics as $metric) {
  26. $totalElements += (int) $metric['elements'];
  27. $checkedElements += (int) $metric['coveredelements'];
  28. }
  29. $coverage = ($checkedElements / $totalElements) * 100;
  30. if ($coverage < $percentage) {
  31. echo 'Code coverage is ' . $coverage . '%, which is below the accepted ' . $percentage . '%' . PHP_EOL;
  32. exit(1);
  33. }
  34. echo 'Code coverage is ' . $coverage . '% - OK!' . PHP_EOL;