in reply to Re: Running tests on modules generated by Module::Starter still in /lib directory
in thread Running tests on modules generated by Module::Starter still in /lib directory

I am running the tests using a nifty keystroke shortcut ;t from within VIM when editing MyModule/lib/MyModule.pm. The shortcut triggers a VIM script which automatically runs the tests found at MyModule/*.t.

So if I follow you correctly, are you saying I should run make install before I run every test? Is that something I should automate as part of the VIM script. Please bear with me, I never got the whole Makefile thing (did I tell you I was lame?)

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re^3: Running tests on modules generated by Module::Starter still in /lib directory
by haukex (Archbishop) on Feb 12, 2017 at 18:40 UTC

    Hi nysus,

    Did you try what choroba suggested? The way I run my tests for all my (pure-Perl) modules is prove -l from the command line from the base directory of the module. make should not be necessary unless you've got XS code that you need to compile, but even then, prove should be able to run all the tests (AFAIK you need prove -lb in that case).

    Hope this helps,
    -- Hauke D

      I'm attempting to automate the process and run the tests from VIM with a shortcut command. See my comment further down for details.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
      $nysus = $PM . ' ' . $MCF;
      Click here if you love Perl Monks

        I don't do vim. Can it cd in shortcuts?

        ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re^3: Running tests on modules generated by Module::Starter still in /lib directory
by stevieb (Canon) on Feb 12, 2017 at 18:40 UTC

    What exactly does the Vim shortcut run when executed? fwiw, tests should reside in MyModule/t/*.t. Also, you never specified which directory you are in when running the test command. You should be in the distribution's root dir.

    You don't need to make install to run tests. make test is a common way to run your suite (all tests), and it automatically knows where to look for your libraries. You only need to do things differently when running individual test files. make install works, but as haukex stated in an earlier reply, it isn't necessary. Both of the below will work all the same, without installing (granted you're in the dist's root dir as I've said):

    "perl -Ilib t/foo.t should be enough. Update: or prove -l t/foo.t."

      It's a nifty little VIM script in that goes in .vimrc file:

      "=====[ Run a Perl module's test suite ]========================= let g:PerlTests_program = 'perltests' " ...What to call let g:PerlTests_search_height = 5 " ...How far up to searc +h let g:PerlTests_test_dir = '/t' " ...Where to look for t +ests augroup Perl_Tests autocmd! autocmd BufEnter *.p[lm] nmap <buffer> ;t :call RunPerlTests()<CR +> autocmd BufEnter *.t nmap <buffer> ;t :call RunPerlTests()<CR +> augroup END function! RunPerlTests () " Start in the current directory... let dir = expand('%:h') " Walk up through parent directories, looking for a test directory +... for n in range(g:PerlTests_search_height) " When found... if isdirectory(dir . g:PerlTests_test_dir) " Go there... silent exec 'cd ' . dir " Run the tests... exec ':!' . g:PerlTests_program " Return to the previous directory... silent cd - return endif " Otherwise, keep looking up the directory tree... let dir = dir . '/..' endfor " If not found, report the failure... echohl WarningMsg echomsg "Couldn't find a suitable" g:PerlTests_test_dir '(tried' g +:PerlTests_search_height 'levels up)' echohl None endfunction

      The VIM script makes use of a perltests script in ~/bin which finds the tests and executes them via TAP::Harness which itself can take a lib argument when creating a new object. So it seems like I should be able to put something in there to make this work. The beauty of it is I can do ;t keystroke and run tests.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
      $nysus = $PM . ' ' . $MCF;
      Click here if you love Perl Monks