Changeset 2189

Show
Ignore:
Timestamp:
05/01/08 22:10:37 (7 months ago)
Author:
mpaschal
Message:

Shorten config file/plan discovery

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-37/t/driver-tests.pl

    r2186 r2189  
    1818 
    1919BEGIN { 
    20     my $driver = __FILE__;      #   /path/to/99-driver.t  =>  driver 
    21     $driver =~ s!.+[\\/]!!; 
    22     $driver =~ s/^\d+-//; 
    23     $driver =~ s/\.t$//; 
    24     $ENV{MT_CONFIG} = "$driver-test.cfg"; 
    25 
    26  
    27 use constant TESTS => 187; 
     20    # Set config to driver-test.cfg when run as /path/to/99-driver.t 
     21    $ENV{MT_CONFIG} = "$1-test.cfg" 
     22        if __FILE__ =~ m{ [\\/] \d+- ([^\\/]+) \.t \z }xms; 
     23
    2824 
    2925use Test::More; 
    3026use lib 't/lib'; 
    3127use MT::Test qw(:testdb :time); 
     28 
     29BEGIN { 
     30    plan skip_all => "Configuration file $ENV{MT_CONFIG} not found" 
     31        if !-r $ENV{MT_CONFIG}; 
     32} 
     33 
     34plan tests => 187; 
    3235 
    3336package Zot; 
     
    4346 
    4447package main; 
    45  
    46 if (-r $ENV{MT_CONFIG}) { 
    47     plan tests => TESTS(); 
    48 } 
    49 else { 
    50     print "Please configure for this test by creating $ENV{MT_CONFIG} with your database, username, and password\n"; 
    51     plan skip_all => "$ENV{MT_CONFIG} configuration not found"; 
    52 } 
    5348 
    5449my(@foo, @bar);