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

Todd Richmond todd@andrew2.stanford.edu
Tue, 27 Feb 2001 18:22:37 -0800

On 2/27/01 12:39 PM, "Hilmar Lapp" <hilmarl@yahoo.com> wrote:

> Gave it a second pass, and now hopefully none of these escaped
> anymore. Blast.t, Index.t, Variation_IO.t needed manual tuning,
> but now all tests pass.
> If you're testing on a non-Unix platform (Todd, Shelly?), please
> make sure you get a fresh CVS update (allow 2 hrs for the next
> sync between anonymous cvs and development tree, if you use
> anonymous cvs for checkouts). Cross-platform problems due to a
> test script not finding its input file should be gone by now.

Rooting around in the Root::IO.pm ...

    eval {
    require File::Spec;
    $TEMPDIR = File::Spec->tmpdir();
    $ROOTDIR = File::Spec->rootdir();
    require File::Temp; # tempfile creation

This is a bad idea for now. File::Spec works just fine on MacOS so $TEMPDIR
and $ROOTDIR are set properly. File::Temp on the other hand, doesn't work
and so probably shouldn't be lumped into this eval.

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);
        return $file;
    return File::Spec->catfile(@args) if(exists($INC{"File/Spec.pm"}));
    # this is clumsy and not very appealing, but how do we specify the
    # root directory?
    if($args[0] eq '/') {
    $args[0] = $ROOTDIR;
    return join($PATHSEP, @args);

By the way, does if(exists($INC{"File/Spec.pm"})) actually work on Unix? In
certainly doesn't work on Macs - even if you change the '/' to ':' or '::'
I didn't worry about it because I'm pretty sure File::Spec is standard on

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