rinceWind has asked for the wisdom of the Perl Monks concerning the following question:

First a point of clarification I don't mean portable modules; these are not a problem. For general purpose modules I advocate trying to make them as portable as possible. The test suite should run on all platforms, and the module should be useable on all platforms.

What I mean by portability modules are those which enable the caller to write portable code. Such modules need to do things which behave differently on different platforms, and involve testing $^O etc.

My question concerns how to get good test coverage of such modules. Devel::Cover only seems able to report on the test suite for a single platform, and not an aggregate coverage across multiple platforms (correct me if I'm wrong). Faking $^O would be tricky, and faking another operating system's behaviour even more so.

I am currently looking at my module Filesys::Type, which uses Module::Pluggable to access plug-ins for the guts of the code. Any suggestions for how to achieve this would be welcome.

--

Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)

2005-09-27 Retitled by g0n, as per Monastery guidelines
Original title: 'Best practice for portability modules'

  • Comment on Best practice for testing portability modules

Replies are listed 'Best First'.
Re: Best practice for testing portability modules
by sauoq (Abbot) on Sep 26, 2005 at 15:49 UTC
    My question concerns how to get good test coverage of such modules.

    Test it on the platforms you have available, then release it to CPAN and wait for the bug reports (and hopefully some fixes) to come flowing in!

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: Best practice for testing portability modules
by eyepopslikeamosquito (Archbishop) on Sep 26, 2005 at 22:53 UTC

    Devel::Cover only seems able to report on the test suite for a single platform, and not an aggregate coverage across multiple platforms (correct me if I'm wrong)
    Paul Johnson describes how to do it here. This has come up a number of times on the perl-qa@perl.org mailing list. On Paul's to do list is to set up a database to collect coverage data from decentralised machines (running different versions of Perl on different platforms) along with a web interface to view this data. I think he is looking for volunteers, so you might like to contact him. ;-)

    Oh, and though I'm sure you've thought of this already, one can employ mock objects (for example, Test::MockObject) to improve coverage on all platforms (and make the overall design more "testable").

      Thanks! That was the pointer I was looking for. I need to get into how the database side of Devel::Cover works, and whether this is directly portable.

      --

      Oh Lord, won’t you burn me a Knoppix CD ?
      My friends all rate Windows, I must disagree.
      Your powers of persuasion will set them all free,
      So oh Lord, won’t you burn me a Knoppix CD ?
      (Missquoting Janis Joplin)