perltravis-cidevel-cover

How to force Devel::Cover to ignore a folder when using perl-helpers via Travis CI


The MetaCPAN Travis CI coverage builds are quite slow. See https://travis-ci.org/metacpan/metacpan-web/builds/238884497 This is likely in part because we're not successfully ignoring the /local folder that gets created by Carton as part of our build. See https://coveralls.io/builds/11809290

We're using perl-helpers to help with our Travis configuration. I thought I should be able to use the DEVEL_COVER_OPTIONS environment variable in order to fix this, but I guess I don't have the correct incantation. I've included the entire config below because a few snippets out of context seemed misleading.

language: perl
perl:
  - "5.22"

matrix:
  fast_finish: true
  allow_failures:
    - env: COVERAGE=1 USE_CPANFILE_SNAPSHOT=true
    - env: USE_CPANFILE_SNAPSHOT=false HARNESS_VERBOSE=1
env:
  global:
    # Carton --deployment only works on the same version of perl
    # that the snapshot was built from.
    - DEPLOYMENT_PERL_VERSION=5.22
    - DEVEL_COVER_OPTIONS="-ignore ^local/"
  matrix:

    # Get one passing run with coverage and one passing run with Test::Vars
    # checks.  If run together they more than double the build time.
    - COVERAGE=1 USE_CPANFILE_SNAPSHOT=true
    - USE_CPANFILE_SNAPSHOT=false HARNESS_VERBOSE=1
    - USE_CPANFILE_SNAPSHOT=true

before_install:
  - git clone git://github.com/travis-perl/helpers ~/travis-perl-helpers
  - source ~/travis-perl-helpers/init

  - npm install -g less js-beautify
  # Pre-install from backpan to avoid upgrade breakage.
  - cpanm -n http://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/common-sense-3.6.tar.gz
  - cpanm -n App::cpm Carton

install:
  - cpan-install --coverage   # installs converage prereqs, if enabled
  - 'cpm install `test "${USE_CPANFILE_SNAPSHOT}" = "false" && echo " --resolver metadb" || echo " --resolver snapshot"`'

before_script:
  - coverage-setup

script:
  # Devel::Cover isn't in the cpanfile
  # but if it's installed into the global dirs this should work.
  - carton exec prove -lr -j$(test-jobs) t

after_success:
  - coverage-report

notifications:
  email:
    recipients:
      - olaf@seekrit.com
    on_success: change
    on_failure: always
  irc: "irc.perl.org#metacpan-travis"

# Use newer travis infrastructure.
sudo: false
cache:
  directories:
    - local

Solution

  • The syntax for the Devel::Cover options on the command line is weird. You need to put stuff comma-separated. At least when you use PERL5OPT.

    DEVEL_COVER_OPTIONS="-ignore,^local/"
    

    See for example https://github.com/simbabque/AWS-S3/blob/master/.travis.yml#L26, where it's a whole lot of stuff with commas.

    PERL5OPT=-MDevel::Cover=-ignore,"t/",+ignore,"prove",-coverage,statement,branch,condition,path,subroutine prove -lrs t