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

perl2lcov: unexpected data type 'time' #297

Closed
m-dango opened this issue May 25, 2024 · 6 comments
Closed

perl2lcov: unexpected data type 'time' #297

m-dango opened this issue May 25, 2024 · 6 comments

Comments

@m-dango
Copy link

m-dango commented May 25, 2024

When attempting to run perl2lcov I receive the error unexpected data type 'time'. I've encountered this on several configurations, and have created a Dockerfile to recreate an environment where the issue occurs for me:

FROM buildpack-deps:bookworm-scm

RUN apt update && apt install -y libdevel-cover-perl libcapture-tiny-perl libdatetime-perl libtest2-suite-perl libtest2-harness-perl make
RUN git clone https://github.com/linux-test-project/lcov.git /tmp/lcov && cd /tmp/lcov && make install

ENTRYPOINT ["bash"]

Using the above, I create code coverage on the following hello world example project: https://replit.com/@m-dango/Perl-DevelCover-Hello-World#t/hello-world.t

I am currently able to temporarily work around the issue by adding a next if ... eq 'time' in the relevant loop in the script.

@henry2cox
Copy link
Collaborator

Hmm.
Is datetime installed? (Check cpan).
Which lcov version? (2.1 release or TOT?)

Likely won't tell us anything, but you can also run as

$ LCOV_SHOW_LOCATION=1 per2lcov ...

Which should show the offending line number.

@m-dango
Copy link
Author

m-dango commented May 28, 2024

The offending line is

die("unexpected data type '$criteria'");

The contents of $f->items in the loop on my env is ("condition", "subroutine", "time", "branch", "statement").

lcov was built via git pull, using master at time of writing.

cover --version
/usr/bin/cover version 1.38

perl -MDateTime -E 'say DateTime->VERSION'
1.59

perl2lcov --version
perl2lcov: LCOV version 2.1-7.g3abff7c

@henry2cox
Copy link
Collaborator

henry2cox commented May 28, 2024

Thanks.
I figured out the issue - will push a fix shortly.

Meantime: the easiest workaround is to turn that 'die' into a warning or ignorable_error.
(Earlier on: I wanted to die on anything unexpected. That may no longer be a Good Idea - but, on the other hand, there are clearly parts of the Devel::Cover datastructure that I don't understand as well as I thought I did.)

henry2cox added a commit that referenced this issue May 28, 2024
Use ignorable_error rather than die if something unexpected happens.

Signed-off-by:  Henry Cox <henry.cox@medaitek.com>
@henry2cox
Copy link
Collaborator

Attempting to clean up the issue list.

I think that this bug is fixed in the above commit.
If so: please close the issue or describe the remaining problems that need to be addressed.
Thanks.

@henry2cox
Copy link
Collaborator

Meantime: the easiest workaround is to turn that 'die' into a warning or ignorable_error.

An even easier workaround may be to edit your cover command line to include only the perl cover types supported by perl2lcov: perl -MDevel::Cover=-db,$COVER_DB,-coverage,statement,branch,condition,subroutine ... (i.e., excluding pod, time and path which will hit the die, in the perl2lcov version in the lcov/2.1 release).

Not sure if it is easier to modify your regress environment or the perl code - but more options are likely better than fewer.

@henry2cox
Copy link
Collaborator

Closing this issue now. I believe it was fixed in the above commit (SHA e10f1f0)
If there is still a problem, please feel free to reopen this issue or file a new one.
Please describe the problem in detail and provide a testcase which illustrates the issue, if possible.

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

No branches or pull requests

2 participants