Re: CPAN and XDG directories

[email protected] (Adam Kennedy)
Newsgroups perl.cpan.workers
Message-ID <[email protected]>
(b) sounds like an interesting idea.

Adam K

On Fri, Feb 19, 2010 at 2:03 AM, David Golden <[email protected]> wrote:
> On Thu, Feb 18, 2010 at 9:12 AM, Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯 <[email protected]> wrote:
>> I of course ran `perl Makefile.PL ; make ; make testdistro ; make test` on the
>> source directory before committing and encountered no problems. Tests pass, my
>> configuration below `$HOME/.config` was not overwritten, and also no
>> `$HOME/.cpan` directory appeared again once I earlier had deleted it for good.
>> So, »works on my machine«.
>>
>> Are you referring to the tests of the CPAN distro or something else?
>
> Anything *else* on CPAN that does this:
>
> (a) uses File::HomeDir->my_data
>
> (b) Overrides $ENV{HOME} to a temp directory for testing creation of
> config files (instead of, say, mocking File::HomeDir->my_data)
>
> This presumes that they don't care or don't realize that $ENV{HOME}
> doesn't affect my_data on Windows.
>
> Adam's suggestion is only a so-so answer because users might
> legitimately have reasons to set HOME and XDG_DATA_HOME differently.
>
> The handful of modules I spot check seem to either just use my_home()
> directly instead of my_data() or if they use my_data(), they mock it
> or have some other override that avoids File::HomeDir entirely.
>
> Here's my revised suggestion:  add something to the File::HomeDir
> module (or distribution) that is the "official" way to mock/override
> File::HomeDir for testing and then advertise the hell out of it.  (And
> possibly email every author that uses File::HomeDir on CPAN)
>
> That could be any of these:
>
> (a) Some global variable that takes precedence over HOME, HOMEDIR,
> XDG_*, whatever
>
> (b) A File::HomeDir::Mock module that creates a temporary directory
> and points every other call to a subdirectory of it.  E.g.
>
>    /tmp/File-HomeDir-tmp498723487/
>        my_home/
>        my_data/
>        my_documents/
>        ...
>
> I think (b) is a safer bet.  Ideally, tests would just need to load it
> early, and then it would ensure that all subsequent use of
> File::HomeDir in that process is safely segregated from real user
> data.
>
> -- David
>
> P.S. Alias++ for the pun
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.