Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test coverage over Mojolicious Template

In writing Galileo I have put some bits of logic into the template (.html.ep), nothing much, but some. To that end I am wondering if I can include these files in the test coverage analysis.

I have tried some things, the most promising was

HARNESS_PERL_SWITCHES='-MDevel::Cover=+select,\.ep$' prove -l t && cover

but these files are still not being included. Perhaps its not possible, but maybe someone has some ideas.

like image 302
Joel Berger Avatar asked Nov 13 '22 01:11

Joel Berger


1 Answers

Devel::Cover uses the file and line information which perl itself uses, so in order to get coverage of the templates the template compilation process would need to set the file and line information correctly. I had a quick look at the Mojo source and didn't see that happening, but I might have been looking in the wrong place.

I don't know much about Mojolicious, but I saw that syntax errors in .ep templates get reported correctly, which is a good sign. If that information comes from perl's usual error reporting then Devel::Cover should also be able to provide coverage information, but I didn't manage to get any either.

If you'd like to open a ticket in github I'll be reminded to look further into it when I have some time.

like image 148
pjcj Avatar answered Feb 01 '23 06:02

pjcj