ugexe / zef

Raku Module Management
Artistic License 2.0
206 stars 44 forks source link

Zef local test (zef test . --debug) doesn't check for valid pod #560

Closed tbrowder closed 2 months ago

tbrowder commented 2 months ago

Context

Working in a new module, both mi6 and zef tests in the repo worked fine. However, upon local install (zef install .) or install on Github, a pod error was reported.

Expected Behavior

Zef should have discovered the error during the local module test.

Actual Behavior

Zef local test does not detect the pod error.

Steps to Reproduce

  1. Add a bad pod file to a repo:

=begin commemt

blah blah

=end comment

  1. In the repo run: zef test . --debug
  2. In the repo run: zef install . --debug

Your Environment

... v2024.02 Built on MoarVM version 2024.02

ugexe commented 2 months ago

You haven’t shown any tests or repos so I can’t really comment much. But it is up to module authors to properly exercise code paths in their tests. If your tests do not, for example, load the file with the bad POD then it will not be precompiled and hence not hit the precompilation error you expect to see.

tbrowder commented 2 months ago

Nick, I can't recall ever explicitly testing for pod inside code before, and I know I've had errors.

What is zef doing differently during an installation that it doesn't do when testing in the dev repo? The error is caught during installation but not in local repo testing.

ugexe commented 2 months ago

Installation requires precompiling everything. Testing does not, and that is because when developing you don't generally want to wait for your entire project to be precompiled while quickly iterating on things -- you just want it to precompile the files that were changed. It could fail during testing but you have to make a conscious effort exercise all the appropriate code paths. For modules I explicitly test for this with: https://github.com/ugexe/zef/blob/2ffe30c9947d6bd214ac0ba27658d42636b9aeb8/t/00-load.rakutest#L1-L9 For RakuDoc files you could probably do something similar, but using EVAL-FILE instead of use-ok, i.e. lives-pl { EVAL-FILE "../lib/MyDocs.rakudoc" } (untested)

ugexe commented 2 months ago

Alternatively if you want to force precompile everything when you test more closely to what happens during installation, you can use: zef install . --force-install --dry This will run the tests and precompile everything regardless of if it is going to be installed. It wont actually install (because --dry) and you wont have to keep updating the version (because --force-install)

tbrowder commented 2 months ago

On Mon, May 27, 2024 at 21:00 Nick Logan @.***> wrote:

Alternatively if you want to force precompile everything when you test more closely to what happens during installation, you can use: zef install . --force-install --dry This will run the tests and precompile everything regardless as if it is going to be installed. It wont actually install (because --dry) and you wont have to keep updating the version (because --force-install)

Excellent! Thanks, Nick, that's just what I needed to know.

Best regards,

-Tom