miyagawa / cpanminus

cpanminus - get, unpack, build and install modules from CPAN
http://cpanmin.us
746 stars 213 forks source link

Installable tests #664

Open Ovid opened 11 months ago

Ovid commented 11 months ago

This is very speculative, but it would be nice to have an "opt-in" feature to allow tests to be installed. For a module like Foo::Bar::Baz, we could install tests under foo-bar-baz (lc and then s/::/-/g), though it's less clear what path they would be installed under.

With that, when I install a new version of a module, having a feature that would allow me to run installed tests for regressions would be lovely.

Of course, that means cpanminus would have to track what it installed (maybe it does and I don't know about that?) and which modules have "installable" tests. In the meta spec, having an extra key like x-install-tests would trigger the behavior (it would need to be "opt-in" instead of "opt-out" because not all tests can be easily installed and run).

However, while installing tests seems desirable, running installed tests seems outside the scope of cpanminus.

miyagawa commented 11 months ago

My first instinct is that this doesn't belong to cpanminus, or any other installer. Installer software only sets some environment variables and command line options and runs perl Makefile.PL; make; make install or perl Build.PL; perl ./Build; perl ./Build install. It has no knowledge about which subdirectories to copy files to, and which files actually need to be installed. It's all controlled by ExtUtils::Install and other build tools.

I suggest you to take a look at Module::Build::Tiny if you want to implement the behavior using the Build spec.

cpanminus would have to track what it installed (maybe it does and I don't know about that?)

perllocal.pod has the list of installed modules (not just cpanminus), and for each install, there's install.json under arch specific subdirectories.

Ovid commented 10 months ago

Thank you for that very helpful reply, @miyagawa !