Previously I had a kludge to allow coverage testing on v5.8 through Travis CI. I used cpanm to install exactly Devel::Cover 1.23 because it supported v5.8. The problem now is that it doesn’t support v5.26 and my automated testing fails.
My Travis config can be a bit more complicated. I can create a matrix of tests and apply different setting to them. I make one for v5.8 and create set NO_DEVEL_COVER=1
. That overrides the global NO_DEVEL_COVER=1
.
At each command line I can test that variable and decide what to do based on its value. I thought about installing different versions of Devel::Cover in each case but that’s a bit too much I think. I’m already getting the coverage data from several other versions already.
sudo: false language: perl perl: - "5.10" - "5.12" - "5.14" - "5.16" - "5.18" - "5.20" - "5.22" - "5.24" - "5.26" env: - NO_DEVEL_COVER=0 matrix: include: - perl: 5.8 env: NO_DEVEL_COVER=1 before_install: - git clone git://github.com/travis-perl/helpers ~/travis-perl-helpers - source ~/travis-perl-helpers/init --auto install: - cpanm --quiet --installdeps --notest . - if [ "$NO_DEVEL_COVER" = "0" ]; then cpanm --quiet --notest Devel::Cover; fi - if [ "$NO_DEVEL_COVER" = "0" ]; then cpanm --quiet --notest Devel::Cover::Report::Coveralls; fi script: - if [ "$NO_DEVEL_COVER" = "0" ]; then cover -delete && cover -test; fi - if [ "$NO_DEVEL_COVER" = "1" ]; then perl Makefile.PL && make test; fi after_success: - if [ "$NO_DEVEL_COVER" = "0" ]; then cover -report coveralls; fi
But, then I couldn’t help myself and I thought maybe I could do it another way and get both of them. Instead of turning off coverage testing I’ll use the environment variable to decide which version of Devel::Cover to install. That means there’s only one command line that might do something different.
I think I like my first solution (and maybe should extend it to only do coverage testing on the latest version). This one looks prettier though:
sudo: false language: perl perl: - "5.10" - "5.12" - "5.14" - "5.16" - "5.18" - "5.20" - "5.22" - "5.24" - "5.26" env: - OLD_DEVEL_COVER=0 matrix: include: - perl: 5.8 env: OLD_DEVEL_COVER=1 before_install: - git clone git://github.com/travis-perl/helpers ~/travis-perl-helpers - source ~/travis-perl-helpers/init --auto install: - cpanm --quiet --installdeps --notest . - if [ "$OLD_DEVEL_COVER" = "0" ]; then cpanm --quiet --notest Devel::Cover; fi - if [ "$OLD_DEVEL_COVER" = "1" ]; then cpanm --quiet --notest Devel::[email protected]; fi - cpanm --quiet --notest Devel::Cover::Report::Coveralls script: - cover -delete && cover -test after_success: - cover -report coveralls