Testenv : automatic find and test all needed PERL modules
I have added a search for use in suppose PERL files in TWiki and eval them to check againts the installed PERL modules without updating the list of neede modules (usefull when adding a plugin).
see attached testenv
--
PatrickNomblot - 25 Jun 2003
Thanks for the updated
testenv - seems like this is mainly intended to find modules required by installed plugins (the current code already checks for the core code's required modules), in which case it would be better to just search from the
lib/TWiki/Plugins directory. This would be much quicker, particularly when upgrading a large TWiki site, since the
data directories are not searched.
This code needs some work to improve matching of pragmas (just match
/[a-z]\w*/ after 'use', pragmas always start with lower case letter) and should also be more robust (e.g. would not work for
use Foo; use Bar;). Also, it wouldn't detect conditional
require statements, or packages that do
eval "use Foo" etc. The core code shows that modules are sometimes needed on one platform but not another, in which case simply searching the Perl code of the plugin is not enough. It would also break if someone has a customised setup using
setlib.cfg to put the TWiki
lib directory somewhere other than under the
twiki directory (see
SettingLibPath).
More generally, it might be better to have a simple plugin API for
testenv, allowing a plugin to provide a list of required modules and perhaps additional checks, callable from
testenv. I'm not sure whether plugin authors would go for this, as it adds to the requirements for a plugin, but a minimal list of required modules wouldn't be much work for each plugin.
It would be easier to review this with a context diff as mentioned in
PatchGuidelines - I'm not sure which version of testenv you have based your changes on. Also, it would be helpful if you use the coding guidelines given in
ReadmeFirst.
--
RichardDonkin - 25 Jun 2003
Thank's Richard.
Yes, this search is far from something perfect and maintaining a list of used libs / OS is better. Note that it was usefull for me for plugins, we could limit it to this area, and maybe live with the other limitations, just telling "List of supposed PERL modules needed" ;-).
--
PatrickNomblot - 26 Jun 2003
Would it be possible to add a handler to the plugins API that either returned the list of modules required or, better, asked the plugin to test that it has everything it needs and if not returns a diagnostic? (In fact, both are probably useful).
Then testenv could iterate down all modules in the system and could present the output.
Incidently, I think there perhaps should be an administrators console view in TWiki that provides easy access to:
It could also provide the ability to rotate the logs.
--
MartinCleaver - 26 Jun 2003
I agree about the plugin API, in fact I suggested this in my third paragraph

... It's best if the plugin just supplies a list of modules as the basic API - might be useful to supply a callback API for plugins that want more control (e.g. if module is needed only for some configurations).
--
RichardDonkin - 26 Jun 2003