Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devel::Cover: request more reasonable error message when mistakenly imported #130

Open
jkeenan opened this issue Jul 5, 2015 · 1 comment

Comments

@jkeenan
Copy link
Contributor

jkeenan commented Jul 5, 2015

Most of the time, when something goes wrong with the use of a library, we want to have as much information as possible so that we can diagnose the problem and correct it.

Sometimes, however, less but more to-the-point information would be preferable. Consider:

$ perl -MDevel::Cover -E 'say q{hello world};'
Can't read /home/jkeenan/gitwork/list-compare/cover_db/digests with Sereal 
Sereal: Error in srl_decoder.c line 701 and char 1 of input: Bad Sereal header: 
Not a valid Sereal document. at 
/home/jkeenan/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Devel/Cover/DB/IO/Sereal.pm 
line 38, <$fh> chunk 1.
BEGIN failed--compilation aborted.
Devel::Cover 1.19: Collecting coverage data for branch, condition, statement, subroutine and time.
    Pod coverage is unavailable.  Please install Pod::Coverage from CPAN.
Selecting packages matching:
Ignoring packages matching:
    /Devel/Cover[./]
    ^t/
    \.t$
    ^test\.pl$
Ignoring packages in:
    /home/jkeenan/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux
    /home/jkeenan/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0
    /home/jkeenan/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/x86_64-linux
    /home/jkeenan/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0
Devel::Cover: Oops, it looks like something went wrong writing the coverage.
              It's possible that more bad things may happen but we'll try to
              carry on anyway as if nothing happened.  At a minimum you'll
              probably find that you are missing coverage.  If you're
              interested, the problem was:

Can't read /home/jkeenan/gitwork/list-compare/cover_db/structure/5b9809facece586b982e7bbf25f1818b with Sereal Sereal: Error in srl_decoder.c line 701 and char 1 of input: 
Bad Sereal header: Not a valid Sereal document. at 
/home/jkeenan/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Devel/Cover/DB/IO/Sereal.pm line 38, <$fh> chunk 1.

[Some lines rebroken for readability.]

In this case, all I did was to user the perl command-line to run a program for which I wanted to 'use Devel::Cover;' -- but I didn't have any tests in that program.

Wouldn't it be better if we said something like: "Were you trying to run some tests? If so, please add them to the program." Granted, by the time you get down to about line 19 of the output, you get something more human-friendly. But perhaps that could be moved up.

Thank you very much.
Jim Keenan

@pjcj
Copy link
Owner

pjcj commented Aug 3, 2015

Thanks very much for reporting this. You are correct that good error messages are important. And they are also difficult.

I suspect that the real cause of the problem here is not that you have no tests - Devel::Cover should still "work" in that case. But rather, my guess is that you had previously run Devel::Cover in the same directory with another version of perl and that this version of perl could not read the cover_db database.

Your main point is still valid though, if that is the problem then the error message should really say that.

This probably points to having more metadata stored in the cover_db and checking that for compatability. I will leave this ticket open as a reminder to do just that.

Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants