Skip to content

Commit bbd21f9

Browse files
committed
Merge pull request #116
Miscellaneous fixes in tests
2 parents f647999 + 342b812 commit bbd21f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+151
-137
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ perl:
2626
- "5.24"
2727
- "5.24-shrplib"
2828
- "5.26"
29+
- "5.26-shrplib"
30+
- "5.28"
2931

3032
matrix:
3133
include:
@@ -264,6 +266,8 @@ matrix:
264266
env: DB=MariaDB VERSION=10.3.10
265267
- perl: "5.22"
266268
env: DB=MariaDB VERSION=10.3.11
269+
- perl: "5.22"
270+
env: DB=MariaDB VERSION=10.4.0
267271
- perl: "5.22"
268272
env: CONC_DB=MySQL CONC_VERSION=6.0.0-beta
269273
- perl: "5.22"
@@ -377,7 +381,7 @@ before_install:
377381
elif [ "$DB" = "MariaDB" ]; then
378382
case "$VERSION" in
379383
5.*|10.[012].*) SANDBOX_URL=https://downloads.mariadb.com/MariaDB/mariadb-$VERSION/bintar-linux-x86_64/mariadb-$VERSION-linux-x86_64.tar.gz ;;
380-
10.3.*) SANDBOX_URL=https://downloads.mariadb.com/MariaDB/mariadb-$VERSION/bintar-linux-glibc_214-x86_64/mariadb-$VERSION-linux-glibc_214-x86_64.tar.gz ;;
384+
10.[34].*) SANDBOX_URL=https://downloads.mariadb.com/MariaDB/mariadb-$VERSION/bintar-linux-glibc_214-x86_64/mariadb-$VERSION-linux-glibc_214-x86_64.tar.gz ;;
381385
*) echo "Unsupported MariaDB version '$VERSION'"; exit 1 ;;
382386
esac ;
383387
SANDBOX_CACHE_FILE="$HOME/cache/$(basename "$SANDBOX_URL")" ;

MANIFEST

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ MANIFEST.SKIP
1212
MariaDB.xs
1313
README.pod
1414
socket.c
15-
testrules.yml
15+
t/testrules.yml
1616
t/00base.t
1717
t/05dbcreate.t
1818
t/10connect.t

Makefile.PL

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ if (eval { ExtUtils::MakeMaker->VERSION(5.43) }) {
409409
recommends => {
410410
'Proc::ProcessTable' => 0,
411411
'TAP::Harness' => '3.31',
412+
'CPAN::Meta::YAML' => 0,
412413
},
413414
suggests => {
414415
'Storable' => 0,

lib/DBD/MariaDB.pod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ DBD::MariaDB - MariaDB and MySQL driver for the Perl5 Database Interface (DBI)
3232
# Connect to the database.
3333
my $dbh = DBI->connect('DBI:MariaDB:database=test;host=localhost',
3434
'joe', q(joe's password),
35-
{'RaiseError' => 1});
35+
{ RaiseError => 1, PrintError => 0 });
3636

3737
# Drop table 'foo'. This may fail, if 'foo' doesn't exist
3838
# Thus we put an eval around it.
@@ -83,7 +83,8 @@ types of objects are available: database handles and statement handles. Perl
8383
returns a database handle to the connect method like so:
8484

8585
my $dbh = DBI->connect("DBI:MariaDB:database=$db;host=$host",
86-
$user, $password, {RaiseError => 1});
86+
$user, $password,
87+
{ RaiseError => 1, PrintError => 0 });
8788

8889
Once you have connected to a database, you can execute SQL statements with:
8990

@@ -366,7 +367,7 @@ I<mariadb_server_prepare> in the connect:
366367
'DBI:MariaDB:database=test;host=localhost;mariadb_server_prepare=1',
367368
'user',
368369
'password',
369-
{ RaiseError => 1, AutoCommit => 1 },
370+
{ RaiseError => 1, PrintError => 0 },
370371
);
371372

372373
or:
@@ -375,7 +376,7 @@ or:
375376
'DBI:MariaDB:database=test;host=localhost',
376377
'user',
377378
'password',
378-
{ RaiseError => 1, AutoCommit => 1, mariadb_server_prepare => 1 },
379+
{ RaiseError => 1, PrintError => 0, mariadb_server_prepare => 1 },
379380
);
380381

381382
There are many benefits to using server side prepare statements, mostly if you

t/05dbcreate.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ sub fatal_error {
3232
}
3333

3434
sub connect_to_server {
35-
return eval { DBI->connect($test_dsn_without_db, $test_user, $test_password, { RaiseError => 1, PrintError => 0, AutoCommit => 1 }) };
35+
return eval { DBI->connect($test_dsn_without_db, $test_user, $test_password, { RaiseError => 1, PrintError => 0 }) };
3636
}
3737

3838
sub connect_to_database {
39-
return eval { DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 0, AutoCommit => 1 }) };
39+
return eval { DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 0 }) };
4040
}
4141

4242
my $dbh = connect_to_database();

t/10connect.t

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use vars qw($test_dsn $test_user $test_password);
1010
use lib 't', '.';
1111
require 'lib.pl';
1212

13-
my $dbh = eval { DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 1, AutoCommit => 0 }) };
13+
my $dbh = eval { DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 0, AutoCommit => 0 }) };
1414
if (not defined $dbh) {
1515
my $err = $@;
1616
$err = "unknown error" unless $err;
@@ -92,22 +92,30 @@ foreach (sort keys %{$info_hashref}) {
9292
diag("$_ is: ". $info_hashref->{$_});
9393
}
9494

95-
ok($dbh->disconnect(), 'Disconnected');
95+
SKIP: {
96+
97+
skip $dbh->errstr(), 2 unless eval { $dbh->do('SHOW GRANTS') };
98+
skip 'Server accepts connections with invalid user/password', 2
99+
if eval { DBI->connect($test_dsn, '4yZ73s9qeECdWi', '64heUGwAsVoNqo', { RaiseError => 1, PrintError => 0 }) };
96100

97101
# dbi docs state:
98102
# The username and password can also be specified using the attributes
99103
# Username and Password, in which case they take precedence over the $username
100104
# and $password parameters.
101105
# see https://rt.cpan.org/Ticket/Display.html?id=89835
102106

103-
my $failed = not eval {$dbh= DBI->connect($test_dsn, $test_user, $test_password,
104-
{ RaiseError => 1, PrintError => 1, AutoCommit => 0,
107+
my $failed = not eval { DBI->connect($test_dsn, $test_user, $test_password,
108+
{ RaiseError => 1, PrintError => 0, AutoCommit => 0,
105109
Username => '4yZ73s9qeECdWi', Password => '64heUGwAsVoNqo' });};
106110
ok($failed, 'Username and Password attributes override');
107111

108-
my $success = eval {$dbh= DBI->connect($test_dsn, '4yZ73s9qeECdWi', '64heUGwAsVoNqo',
109-
{ RaiseError => 1, PrintError => 1, AutoCommit => 0,
112+
my $success = eval { DBI->connect($test_dsn, '4yZ73s9qeECdWi', '64heUGwAsVoNqo',
113+
{ RaiseError => 1, PrintError => 0, AutoCommit => 0,
110114
Username => $test_user, Password => $test_password });};
111-
ok($success, 'Username and Password attributes override');
115+
ok($success, 'Username and Password attributes override') or diag(DBI->errstr());
116+
117+
}
118+
119+
ok($dbh->disconnect(), 'Disconnected');
112120

113121
done_testing;

t/11data_sources.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $attributes{user} = $test_user;
1818
$attributes{password} = $test_password;
1919
delete $attributes{database};
2020

21-
my $dbh = DbiTestConnect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 1, AutoCommit => 0 });
21+
my $dbh = DbiTestConnect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 0, AutoCommit => 0 });
2222

2323
plan tests => 2;
2424

t/12embedded.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ sub connect_to_embedded_server {
3939
my $lang_arg = $ENV{DBD_MARIADB_TESTLANGDIR} ? ",--language=$ENV{DBD_MARIADB_TESTLANGDIR}" : '';
4040
my $emb_dsn = "DBI:MariaDB:host=embedded;mariadb_embedded_options=--datadir=$tmpdir$lang_arg;";
4141
$emb_dsn .= "database=$database" if defined $database;
42-
return eval { DBI->connect($emb_dsn, undef, undef, { RaiseError => 1, PrintError => 1, AutoCommit => 1 }) };
42+
return eval { DBI->connect($emb_dsn, undef, undef, { RaiseError => 1, PrintError => 0 }) };
4343
}
4444

4545
sub connect_to_real_server {
46-
my $dbh = eval { DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 1, AutoCommit => 0 }) };
46+
my $dbh = eval { DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 0, AutoCommit => 0 }) };
4747
if (not defined $dbh) {
4848
my $err = $@;
4949
$err =~ s/ at \S+ line \d+\.?\s*$//;

t/13disconnect.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ use vars qw($test_dsn $test_user $test_password);
88
use lib 't', '.';
99
require 'lib.pl';
1010

11-
my $dbh1 = DbiTestConnect($test_dsn, $test_user, $test_password, { RaiseError => 1 });
11+
my $dbh1 = DbiTestConnect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 0 });
1212

1313
plan tests => 17;
1414

1515
ok $dbh1->{Active};
1616
ok $dbh1->disconnect();
1717
ok !$dbh1->{Active};
1818

19-
ok my $dbh2 = DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1 });
20-
ok my $dbh3 = DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1 });
19+
ok my $dbh2 = DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 0 });
20+
ok my $dbh3 = DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 0 });
2121

2222
ok $dbh2->{Active};
2323
ok $dbh2->disconnect();
@@ -27,8 +27,8 @@ ok $dbh3->{Active};
2727
ok $dbh3->disconnect();
2828
ok !$dbh3->{Active};
2929

30-
ok my $dbh4 = DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1 });
31-
ok our $dbh5 = DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1 });
30+
ok my $dbh4 = DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 0 });
31+
ok our $dbh5 = DBI->connect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 0 });
3232

3333
ok $dbh4->{Active};
3434
ok $dbh5->{Active};

t/15reconnect.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ my $dbh;
1313
my $sth;
1414

1515
$dbh = DbiTestConnect($test_dsn, $test_user, $test_password,
16-
{ RaiseError => 1, AutoCommit => 1});
16+
{ RaiseError => 1, PrintError => 0 });
1717
$dbh->disconnect();
1818

1919
plan tests => 18 * 2;
2020

2121
for my $mariadb_server_prepare (0, 1) {
2222
$dbh= DBI->connect("$test_dsn;mariadb_server_prepare=$mariadb_server_prepare;mariadb_server_prepare_disable_fallback=1", $test_user, $test_password,
23-
{ RaiseError => 1, PrintError => 1, AutoCommit => 0 });
23+
{ RaiseError => 1, PrintError => 0, AutoCommit => 0 });
2424

2525
ok(defined $dbh, "Connected to database");
2626

0 commit comments

Comments
 (0)