Changeset 429


Ignore:
Timestamp:
May 11, 2008, 1:58:49 PM (14 years ago)
Author:
Dominic Hargreaves
Message:

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

Location:
wiki-toolkit/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wiki-toolkit/trunk/Changes

    r427 r429  
    1313        Fix test suite's incorrect passing of DBIxFTSMySQL connection
    1414          parameters
     15        Add missing prereq of DBI (caught by the CPAN testers) and don't
     16          use DBI in Makefile.PL
    1517
    16180.74    9  June 2007
  • wiki-toolkit/trunk/Makefile.PL

    r428 r429  
    11use ExtUtils::MakeMaker;
    2 use DBI;
    32use Data::Dumper;
    43use strict;
     
    7675
    7776    # Finally ask questions; then check the settings work.
    78     my %dsn_prefix = ( MySQL => "dbi:mysql:",
    79                        Pg    => "dbi:Pg:dbname=" );
    8077    my %driver = ( MySQL => "DBD::mysql",
    8178                   Pg    => "DBD::Pg" );
     
    106103            undef $dbhost unless ($dbhost and $dbhost ne "undef");
    107104
    108             # Check that these connection parameters actually work.
    109             my $dsn = $dsn_prefix{$store_type}.$dbname;
    110             $dsn .= ";host=$dbhost" if $dbhost;
    111             my $dbh = eval { DBI->connect($dsn,
    112                                           $dbuser, $dbpass, {PrintError => 1})
    113                                  or die DBI->errstr;
    114                            };
    115             die "\nCan't connect to $store_type with those parameters:"
    116                      . "\n" . $@ . "\n\n"
    117                      . "Please re-run 'perl Makefile.PL' and supply correct "
    118                      . "parameters.\n\n" if $@;
    119             $dbh->disconnect;
    120 
    121             # Save them if they do.
    122105            $config{$store_type}{dbname} = $dbname;
    123106            $config{$store_type}{dbuser} = $dbuser;
  • 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
Note: See TracChangeset for help on using the changeset viewer.