zhutoulala zhutoulala - 4 months ago 31
Perl Question

"Devel::Cover: Can't open test.pl for MD5 digest: No such file or directory" after switching user

I'm using Devel::Cover to collect my perl coverage on linux but i got a problem when i tried to switch users. Following are steps to reproduce:


  1. having 2 users : user1 and user2 and set
    $PERL5OPT=-MDevel::Cover=-db,
    [path to coverage folder]

  2. login as user1 and place a test.pl at
    /home/user1/

  3. run perl
    /home/user1/test.pl

  4. switch to user2 by run
    "sudo su - user2"



error message
"Devel::Cover: Can't open test.pl for MD5 digest: No such file or directory"
is seen right after the user is changed

I tried getting it work by setting the arguments in PERL5OPT like:

export PERL5OPT=-MDevel::Cover=-db,[path to coverage folder],+inc,/var/home,/home


But it didn't work, can anyone help?

Answer

well, finally i figured out a solution by myself - to only include the folder i wanted to collect the coverage information using "-dir":

export PERL5OPT=-MDevel::Cover=-db,[path to coverage folder],-dir,[Paths of perl scripts to cover]