Changeset 237


Ignore:
Timestamp:
04/24/06 11:30:22 (18 years ago)
Author:
nanardon
Message:
  • fix #5 (invalid plugin code does not return an error)
  • replace exit by return, propagate the return value
  • add test case
Location:
trunk/soft/ObsData
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/soft/ObsData/ObsData.pm

    r229 r237  
    101101    } 
    102102     
    103     $self->load_plugins(); 
     103    $self->load_plugins() or return 0; 
    104104     
    105105    return 1; 
     
    134134                    $datatype, 
    135135                ); 
    136                 exit(1); 
     136                return 0; 
    137137            } 
    138138            my $sub = do $plugfilename; 
     139            if ($@) { 
     140                $self->logging(4, 
     141                    "Cannot load plugin %s for %s: %s, exiting !", 
     142                    $plugin, 
     143                    $datatype, 
     144                    $@, 
     145                ); 
     146                return 0; 
     147            } 
    139148            if ($sub && ref $sub eq 'CODE') { 
    140149                $self->{plugin}{$datatype}{$plugin} = { 
     
    158167        } 
    159168    } 
     169    return 1; 
    160170} 
    161171 
  • trunk/soft/ObsData/t/O-01.t

    r169 r237  
    44use warnings; 
    55 
    6 use Test::More tests => 4; 
     6use Test::More tests => 6; 
    77 
    88use_ok('ObsData'); 
     
    1212ok(!ObsData->new('testdata/wrongfile'), "Return an error on bad file"); 
    1313ok(!ObsData->new(undef), "Return an error w/o a config file"); 
     14 
     15ok(my $o = ObsData->new('testdata/obsdata-conf-wrongplugin'), "Can get an Obsdata object"); 
     16ok(!$o->load(), "load() return an error if an invalid plugiin is found"); 
Note: See TracChangeset for help on using the changeset viewer.