linux-test-project / lcov

LCOV
GNU General Public License v2.0
866 stars 234 forks source link

perl2lcov: unexpected data type 'time' #297

Closed m-dango closed 3 weeks ago

m-dango commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

The offending line is https://github.com/linux-test-project/lcov/blob/3abff7c68391c5f92ba3b36a242b4e501a85646f/bin/perl2lcov#L199

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 3 weeks ago

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.