So, as I said at YAPC::EU 2012, one thing that remains to be done before Dancer
2 can be released : migrating the plugins, making sure they work with it.
To be able to do that, what’s best than an automatic testing facility ?
The goal is to get all Dancer plugins, test them with Dancer1, and Dancer2, and
produce a report, to check which one fails and need fixing.
Step 1. Get the list of Dancer plugins.
Easy ! let’s use Metacpan. After searching, I finally
got a way to get the list of all modules that depend on Dancer. Then filtering
out the ones that don’t contain "Plugin" will do the trick.
Cool, let’s save this script as get_modules_list.pl.
Step 2. Prepare two Perl environments
We want two instance of Perl, without polluting anything. We’ll use
perlbrew for that. Easy. The small trick is to have
PERLBREW_ROOT initialized to a local directory to not polute existing ~/perl5
Step 3. Have a way to test modules
Well, let’s use cpanm, which has an option --test-only
to only test a module without installing it. Oh but plugin modules that we’ll
test may require dependances. We’ll install them using cpanm --installdeps,
which does just that.
Step 4. Create a result file
I was lazy and just output to a .csv text file, but I may store the results
somewhere else later.
Step 5. Let’s glue all that in a Makefile
The beauty of this is that by writing a proper Makefile, we can install this
auto-tester anywhere. The requirements are minimal : bash, curl, and
perl, with ElasticSearch and Modern::Perl installed.
( This post is intentionally named the same as
the one from Yannick,
because he proposed a different implementation. We’ll try to merge the good
ideas together )
It’s really cool to see what you can do with modern tools of the Perl ecosystem !