> Thanks for your write-up Michael, it was really helpful.
>
> I would definitely like to see this published.

I will try to release this eventually, but in the meantime, I just
learned something else pretty cool.

Getting PersistentPerl to reload a module is as simple as deleting the
module's entry from %INC.  So I added this method to Test::PerPerHelper:

    use Module::Load;

    sub refresh {
        my $class = shift;
        foreach my $module (@_) {
            my $filename = Module::Load::_to_file($module, 1);

            my $message = "Refreshing: $module ($filename)...";
            if (delete $INC{$filename}) {
                $message .= "[ok]\n";
            }
            else {
                $message .= "[not found]\n";
            }
            Test::More::diag $message;
        }
    }

And then each test script can declare the modules it wants to reload:

    Test::PerPerlHelper->refresh(qw(
        Some::Module
        Some::Other::Module
        Yet::Another::Module
    ));


This is mostly useful during Test-Driven Development: it saves you
from having to restart PersistentPerl every time you make a change to
a module you're testing.  Once your modules and your test script are
relatively stable, you can comment out these lines.


Michael


---
Michael Graham <[EMAIL PROTECTED]>

Reply via email to