[Bioperl-l] hardcoded paths in test scripts (II)

Todd Richmond todd@andrew2.stanford.edu
Wed, 28 Feb 2001 14:49:18 -0800

On 2/27/01 7:04 PM, "Hilmar Lapp" <lapp@gnf.org> wrote:

> Todd Richmond wrote:
>> Meanwhile the fix for cross-compatibility completely broke things on a Mac
>> :)
>> Here's a fix for Bio::Root::IO->catfile
>> sub catfile {
>>     my ($self, @args) = @_;
>>     if ($^O =~ /macos/i) {
>>         my $file = ':'. File::Spec->catfile(@args);
> So this means that even File::Spec is doing it wrong. What's the
> meaning of the initial ':'? The root dir? (I somewhere read that there
> is no such thing as a root dir on Macs ... :o )

After a bit of testing, this is a bad idea. Just use:

    if ($^O =~ /macos/i) {
        my $file = File::Spec->catfile(@args);

Mac users will have to do a global search and replace on the test files to
change "t" to ":t". The earlier fix works fine for some cases but then
requires clean-up when someone does something like:

$currentfile = 
open (FILEHANDLE, ">$currentfile")

When that happens, $currentfile has an extra ':' which prevents the opening
of the file.

One other thing with the tempfile/tempdir issue. When you're creating a
temporary directory, you should check to see whether or not the directory
exists first, or return an error if the creation fails. Right now, the
directory is created with a bare "mkdir($tdir, 0755)".

Dr Todd Richmond                 http://cellwall.stanford.edu/todd
Carnegie Institution             email: todd@andrew2.stanford.edu
Department of Plant Biology      fax: 1-650-325-6857
260 Panama Street                phone: 1-650-325-1521 x431
Stanford, CA 94305