Extension testing fun and games

Hello,

I’ve spent several evenings banging my head against the problem of running
the test suite of an RT extension against the installed version of RT,
in the context of Debian packaging. I’ve been down various ugly paths
and now I now have something which works, but it still needs a bit more work.

There are three patches involved:

Patch one (to RT):

http://anonscm.debian.org/cgit/pkg-request-tracker/request-tracker4.git/commit/?h=dom/extension-testing&id=2c5db8d00625b312422ea35e2c904d41edc361ed

(Load RT::Generated from @INC rather than hard-coding the location from
RT.pm)

This seems sane enough, although I suspect it may break in some
installations. Maybe it should be wrapped in an

if ($ENV{‘INSTALLED_TESTING’) {

}

or some such. I’m not quite sure why it was originally done this way,
but given it is this way, breakage is likely.

Patch two (to RT):

http://anonscm.debian.org/cgit/pkg-request-tracker/request-tracker4.git/commit/?h=dom/extension-testing&id=33f14b541751b7da03542ec524179cae02af71bd

(RT::Test: add $RTDatabaseType from the environment to the generated
RT_SiteConfig.pm if set).

Seems non-controversial.

Patch three (to the extension):

http://anonscm.debian.org/cgit/pkg-request-tracker/rt-extension-assets.git/commit/?h=dom/run_test_suite&id=c8b57fa9fe83ad0afc3adb25f17d4e376177890a

The most ugly. In particular this patch masks the real value of
$RT::VERSION. This could be hacked around with more layers of module
loading (to extra just $RT::VERSION from the installed RT::Generated)
and is clearly Debian-specific. I suspect a better solution would be to
find the installed RT::Generated, and then mangle it automatically to
change $VarPath, $MasonDataDir and $MasonSessionDir. Such an approach
could be moved out into RTx::Module::Install and then reused in a generic
fashion (obviously, enabled via an environment variable).

After all that, the test suite of RT-Extension-Assets passes when
invoked as:

perl Makefile.PL
RT_TEST_DB_TYPE=SQLite make test-parallel

I’d certainly be keen to see the test suites being run as a matter of
course in extensions, and this work looks as though it would be useful
outside the Debian contexts. At the moment unless I’m mistaken it appears
the test suites aren’t really usable unless you’ve also got an installed
version of RT the test suite whose database the test suite is allowed to
poke at directly.

I’d be grateful for any thoughts people have about whether I’m going
down the right path, and whether patches with the modifications
suggested would be likely to be accepted upstream.

Cheers,
Dominic.