Skip to content

testcover only works with Test::Harness, not TAP::Harness #62

@mephinet

Description

@mephinet

The action testcover needs to set -MDevel::Cover when tests are executed, so that coverage metrics are collected. Currently, it tries to achieve this by these lines of code:
(https://github.com/Perl-Toolchain-Gang/Module-Build/blob/master/lib/Module/Build/Base.pm#L2805)

local $Test::Harness::switches    =
local $Test::Harness::Switches    =
local $ENV{HARNESS_PERL_SWITCHES} = "-MDevel::Cover";

This is broken in two ways:

  • Test::Harness::switches will be overwritten in run_test_harness, so setting it here has no effect whatsoever.
  • HARNESS_PERL_SWITCHES is only valued by Test::Harness, but not TAP::Harness.

The result is that testcover only works with Test::Harness:

$ rm -rf cover_db; ./Build testcover
...
Result: PASS
HTML output written to .../cover_db/coverage.html

but not in TAP::Harness:

$ rm -rf cover_db; ./Build testcover use_tap_harness=1
...
Result: PASS
Can't open database .../cover_db

IMHO, the correct way for testcover to work would be to add -MDevel::Cover to the harness_switches, as they are passed on correctly to both Test::Harness and TAP::Harness.

Seen on Gentoo Linux amd64, Perl 5.20.2 and Module::Build from git master, as well as 0.4214.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions