cov-exclude 745 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/perl -p -i
  2. use warnings;
  3. use strict;
  4. our $excluding;
  5. # This script is meant to post-process a .gcov file for an input source
  6. # that was annotated with LCOV_EXCL_START, LCOV_EXCL_STOP, and LCOV_EXCL_LINE
  7. # entries. It doesn't understand the LCOV_EXCL_BR* variations.
  8. #
  9. # It replaces unreached reached lines with x:, and reached excluded lines
  10. # with !!!num:.
  11. BEGIN { our $excluding = 0; }
  12. if (m/LCOV_EXCL_START/) {
  13. $excluding = 1;
  14. }
  15. if ($excluding and m/LCOV_EXCL_STOP/) {
  16. $excluding = 0;
  17. }
  18. my $exclude_this = (m/LCOV_EXCL_LINE/);
  19. if ($excluding or $exclude_this) {
  20. s{^\s*\#\#+:}{ x:};
  21. s{^ (\s*)(\d+):}{$1!!!$2:};
  22. }
  23. if (eof and $excluding) {
  24. warn "Runaway LCOV_EXCL_START in $ARGV";
  25. $excluding = 0;
  26. }