Search code examples
perltestingmojolicious

Module::Build test looks in different directories on different systems


I'm trying to install a Perl Mojolicious project from a development system onto a staging system. On the staging system (Centos), the tests are looking in the wrong place for the config file. That is, eg,

./Build test --test-files t/001_basic.t

errors out with

t/001_basic.t .. 1/? Configuration file "/home/randall/git/Project/blib/project.json" missing, maybe you need to create it?

On the development system (Ubuntu), the same Build test command is reading the config file out of the parent directory (ie, /home/randall/git/Project/project.json) which is what I want.

I've already ruled out the working directory as a possible culprit, and reran perl Build.PL, regenerating the Build script.

What am I missing that would cause only the staging system to be looking in the blib directory?

Edit: Added that dev is Ubuntu and staging is Centos, though I don't expect that to be a factor


Solution

  • Generally speaking, you can't make assumptions about the current work directory you're given.

    use Cwd            qw( abs_path );
    use File::Basename qw( dirname );
    
    use constant PROJ_DIR => dirname(abs_path(__FILE__)) . '/..';
    
    my $config_qfn = PROJ_DIR.'/project.json';