update tests for perl 5.18
[bioperl-live.git] / t / Tools / Run / WBCommandExts.t
blob6f1930cdc2dd5298ed691ff8a95e32dc0530f75e
1 #-*-perl-*-
2 #$Id$
3 # testing CommandExts
4 use strict;
5 use warnings;
6 our $home;
7 BEGIN {
8     use Bio::Root::Test;
9     use lib '.';
10     use lib 't/Tools/Run';
11     $home = '../../..'; # set to '.' for Build use, 
12                       # '../../..' for debugging from .t file
13     unshift @INC, $home;
14     test_begin(-tests => 25,
15                -requires_modules => [qw(Bio::Tools::Run::WrapperBase
16                                         Bio::Tools::Run::WrapperBase::CommandExts)]);
19 use_ok( 'Dummy::Config' );
20 use_ok( 'Dummy' );
21 use_ok('Bio::Tools::Run::WrapperBase');
22 use_ok('Bio::Tools::Run::WrapperBase::CommandExts');
24 ok my $fac = Dummy->new( -command => 'goob',
25                          -narf => 42.0,
26                          -schlurb => 'breb',
27                          -freen => 1 ), "make factory";
28 ok $fac->parameters_changed, "parm changed flag set";
29 is $fac->program_name, 'flurb', "correct prog name";
30 ok $fac->is_pseudo, "is pseudo";
31 is $fac->narf, 42, "correct parm set";
32 ok !$fac->parameters_changed, "parm flag cleared";
33 my $param_str = join(' ',@{$fac->_translate_params});
35 like ($param_str, qr/--schlurb breb/, 'translate opts to command line');
36 like ($param_str, qr/-n 42/, 'translate opts to command line');
37 like ($param_str, qr/-f/, 'translate opts to command line');
39 TODO: {
40     local $TODO ='Determine whether the order of the parameters should be set somehow; this sporadically breaks hash randomization introduced in perl 5.17+';
41     is join(' ',@{$fac->_translate_params}), '--schlurb breb -n 42 -f', "translate opts to command line";
44 ok $fac->reset_parameters, "parm reset";
45 ok !$fac->narf, "parm cleared after reset";
47 is_deeply( [$fac->available_parameters('parameters')], [qw( command narf schlurb )], "avail parms");
48 is_deeply( [$fac->available_parameters('switches')], ['freen'], "avail switches");
49 is_deeply( [$fac->available_parameters('commands')], [qw(rpsblast cat goob blorb multiglob)], "avail commands");
51 ok $fac = Dummy->new( -command => 'multiglob',
52                      -g_freen => 1,
53                      -b_scroob => 10.5,
54                       -trud => 'sklim' ), "make composite cmd factory";
56 is $fac->trud, 'sklim', "comp cmd parm set";
58 ok my %facs = $fac->_create_factory_set, "make subfactories";
59 is $facs{goob}->freen, 1, "subfactory 1 parm correct";
60 is $facs{blorb}->scroob, 10.5, "subfactory 2 parm correct";
62 $fac->program_dir('.');
63 # ok $fac->executables('rpsblast'), "find in program_dir";
64 ok $fac->executables('cat'), "find in syspath";