Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Struggle with Test::CPAN::Meta

by szabgab (Priest)
on Feb 20, 2021 at 01:06 UTC ( [id://11128584]=perlquestion: print w/replies, xml ) Need Help??

szabgab has asked for the wisdom of the Perl Monks concerning the following question:

I just got co-maintainer rights to Test::Class that has a failing release test using Test::CPAN::Meta. That Test module is supposed to verify META.yml, but META.yml is not in the repository as it is going to be generated in the "make dist" phase. So it is not available yet in the "make test" phase.

I tried to figure out how others use Test::CPAN::Meta but the reverse dependencies list is full of modules using Minilla that seems to magically be able to run the tests.

How do you, who is using plain old ExtUtils::MakeMaker use this test? Do I even need to have this test given that the META files are generated automatically?

Replies are listed 'Best First'.
Re: Struggle with Test::CPAN::Meta
by kcott (Archbishop) on Feb 20, 2021 at 09:54 UTC

    G'day szabgab,

    I encountered a similar issue recently where I was adding META.yml and META.json to MANIFEST. My tests using ExtUtils::Manifest failed because those files weren't present. Like you, I realised that the files were generated by make dist, added to the tarball, then distdir was deleted: still no META.* in the development directory — either before or after make test is run.

    I took a very pragmatic approach to this. make dist not only creates those files, but also adds their names to MANIFEST. So I removed my hand-crafted entries from MANIFEST and make test ran successfully. Anyone unpacking the tarball, has both the files present and the entries in MANIFEST: again, make test runs successfully.

    That doesn't directly help you, as you actually want those files to be available in your development directory when you run make test.

    I had a look through the test-class/t in your git repo. I couldn't see anything that looked like test_meta.t — and wasn't prepared to look through several screenfuls of *.t files — so I'll just make a general suggestion.

    In test_meta.t (or whatever it's called) add a SKIP: {...} block that tests for the presence for META.*: now make test should run successfully. After make dist, unpack the tarball, which should give you a directory with the META.* files and entries for them in MANIFEST. Now run the standard incantation, perl Makefile.PL; make; make test, and hopefully tests are either successful or point to something you need to fix. When everything is good; post the tarball to CPAN.

    There's potentially a more elegant solution which involves adding a sub MY::postamble {...} to Makefile.PL to generate a local_metafile (or similar) make target. That seems like a lot of work, but may be worth it depending on your requirements. My expertise with ExtUtils::MakeMaker is not at a level that I feel I can usefully provide you with any substantial help — perhaps another monk can offer advice.

    A bit of bonus humour. When typing the first paragraph, my finger clipped the 'E' when aiming for the 'S': I ended up writing "My testes ...". I'm very glad I spotted that. 😌

    Update: I've made multiple, extremely minor changes to last sentence of the penultimate paragraph. None of these change the intended meaning; they're just better English. As there's been no responses, at the time of writing, these do not affect anyone's reply. It'd be great if there was a "Preview" option for this. I'll post separately about that. Update: Done - see "Preview for Post Editing"

    — Ken

      Thanks Ken. It is actually in the xt/ directory, now the only one that was left there. The others were already moved to the t/ directory.
Re: Struggle with Test::CPAN::Meta
by hippo (Bishop) on Feb 20, 2021 at 12:21 UTC

    I have a couple of modules which use Test::CPAN::Meta in release tests. I run them using perl Makefile.PL && make disttest. These just use ExtUtils::MakeMaker with no Minilla or dzil or anything like that. You will find that the distdir which this creates includes the META.* files.


    🦛

      Thanks, that can be an idea. Now if I knew your PAUSE handle or could get links to some of these modules, that would be awesome :)

        Private message sent. 🥸


        🦛

Re: Struggle with Test::CPAN::Meta
by no longer just digit (Beadle) on Feb 20, 2021 at 04:39 UTC

    ExtUtils::MakeMaker should be generating MYMETA.yml though as you run perl Makefile.PL.

    Can you not run the test on MYMETA.yml if META.yml doesn't exist?

Re: Struggle with Test::CPAN::Meta
by jcb (Parson) on Feb 22, 2021 at 01:39 UTC

    A few days after first seeing this, I realized that there may be another option: simply skip the test if running in the repository working tree. As an untested example using Test::More and if:

    use if (-d '.git'), Test::More => skip_all => 'in dev tree; distributi +on metadata not present'; use Test::More tests => #... # Your original "use Test::More" line g +oes here...

    This assumes that you are using Git and that the tests are run with the repository root as the current directory. The test for the .git directory will be true if the current directory is the repository root, but false when building from a release file set. With this approach, make disttest should still run the test, since it checks the actual release file set instead of the development tree.

    Edit 2021-02-22 by jcb: Quote bareword, oops. Thanks to choroba for noticing the error. I said it was untested! :-D

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11128584]
Approved by toolic
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (1)
As of 2024-04-25 01:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found