Show
Ignore:
Timestamp:
05/11/08 13:58:49 (5 years ago)
Author:
dom
Message:

Add missing prereq of DBI (caught by the CPAN testers) and don't
use DBI in Makefile.PL

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • wiki-toolkit/trunk/lib/Wiki/Toolkit/TestLib.pm

    r427 r429  
    55use Wiki::Toolkit; 
    66use Wiki::Toolkit::TestConfig; 
     7use DBI; 
    78 
    89use vars qw( $VERSION @wiki_info ); 
     
    4344 
    4445my %datastore_info; 
     46 
     47my %dsn_prefix = ( MySQL  => "dbi:mysql:", 
     48                   Pg     => "dbi:Pg:dbname=", 
     49                   SQLite => "dbi:SQLite:dbname="); 
     50 
    4551foreach my $dbtype (qw( MySQL Pg SQLite )) { 
    4652    if ( $configured{$dbtype}{dbname} ) { 
     
    4854        my $store_class = "Wiki::Toolkit::Store::$dbtype"; 
    4955        my $setup_class = "Wiki::Toolkit::Setup::$dbtype"; 
     56        my $dsn = $dsn_prefix{$dbtype}.$config{dbname}; 
     57        my $err; 
     58        if ($err = _test_dsn( $dsn, $config{dbuser}, $config{dbpass}, $config{dbhost})) { 
     59            warn "connecting to test $dbtype database failed: $err\n"; 
     60            warn "will skip $dbtype tests\n"; 
     61            next; 
     62        } 
    5063        $datastore_info{$dbtype} = { 
    5164                                     class  => $store_class, 
     
    258271} 
    259272 
     273sub _test_dsn { 
     274    my ( $dsn, $dbuser, $dbpass, $dbhost ) = @_; 
     275    $dsn .= ";host=$dbhost" if $dbhost; 
     276    my $dbh = eval { 
     277        DBI->connect($dsn, $dbuser, $dbpass, {RaiseError => 1}); 
     278    }; 
     279    return $@; 
     280} 
     281 
     282 
    260283=back 
    261284 
     
    271294 
    272295     Copyright (C) 2003-2004 Kake Pugh.  All Rights Reserved. 
     296     Copyright (C) 2008 the Wiki::Toolkit team. All Rights Reserved. 
    273297 
    274298This module is free software; you can redistribute it and/or modify it