This is an automated email from the git hooks/post-receive script.

gregoa pushed a commit to branch gregoa/tests
in repository libdbd-mysql-perl.

commit eff299bb5a89f17c667a5d33ae243cdd04780717
Author: gregor herrmann <gre...@debian.org>
Date:   Tue Oct 4 19:58:31 2016 +0200

    Enable tests during build and autopkgtest.
---
 debian/control                      |  5 ++++-
 debian/patches/series               |  1 +
 debian/patches/test-user.patch      | 25 +++++++++++++++++++++++++
 debian/rules                        | 17 ++++++++++++++++-
 debian/tests/pkg-perl/smoke-cleanup |  7 +++++++
 debian/tests/pkg-perl/smoke-env     |  7 +++++++
 debian/tests/pkg-perl/smoke-files   |  2 --
 debian/tests/pkg-perl/smoke-setup   | 22 ++++++++++++++++++++++
 debian/tests/pkg-perl/smoke-skip    |  2 ++
 9 files changed, 84 insertions(+), 4 deletions(-)

diff --git a/debian/control b/debian/control
index 2429dc0..062a085 100644
--- a/debian/control
+++ b/debian/control
@@ -8,9 +8,12 @@ Section: perl
 Testsuite: autopkgtest-pkg-perl
 Priority: optional
 Build-Depends: debhelper (>= 9.20120312),
-               libdbi-perl,
                default-libmysqlclient-dev,
+               default-mysql-server,
+               libdbi-perl,
+               libtest-deep-perl,
                perl,
+               procps,
                zlib1g-dev
 Standards-Version: 3.9.8
 Vcs-Browser: 
https://anonscm.debian.org/cgit/pkg-perl/packages/libdbd-mysql-perl.git
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..888c730
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+test-user.patch
diff --git a/debian/patches/test-user.patch b/debian/patches/test-user.patch
new file mode 100644
index 0000000..46e68cb
--- /dev/null
+++ b/debian/patches/test-user.patch
@@ -0,0 +1,25 @@
+Description: mark a test as TODO
+ which fails in our test setup because we have no users
+ (besides the password-less socket-using root)
+ in our test database
+Origin: vendor
+Forwarded: not-needed
+Author: gregor herrmann <gre...@debian.org>
+Last-Update: 2016-10-04
+
+--- a/t/10connect.t
++++ b/t/10connect.t
+@@ -68,10 +68,13 @@ ok($dbh->disconnect(), 'Disconnected');
+ # and $password parameters.
+ # see https://rt.cpan.org/Ticket/Display.html?id=89835
+ 
++TODO: {
++local $TODO = "We don't have a user in our test database.";
+ eval {$dbh= DBI->connect($test_dsn, $test_user, $test_password,
+    { RaiseError => 1, PrintError => 1, AutoCommit => 0,
+      Username => '4yZ73s9qeECdWi', Password => '64heUGwAsVoNqo' });};
+ ok($@, 'Username and Password attributes override');
++}
+ 
+ eval {$dbh= DBI->connect($test_dsn, '4yZ73s9qeECdWi', '64heUGwAsVoNqo',
+    { RaiseError => 1, PrintError => 1, AutoCommit => 0,
diff --git a/debian/rules b/debian/rules
index be3553c..934ec44 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,11 +6,26 @@ ARCHLIB := $(shell perl -MConfig -e 'print 
$$Config{vendorarch}')
 
 export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow
 
+export MYSQL_DIR=$(CURDIR)/t/testdb
+export MYSQL_UNIX_PORT=$(MYSQL_DIR)/mysql.sock
+export MYSQL_PIDFILE=$(MYSQL_DIR)/mysql.pid
+export MYSQL_USER=$(shell whoami)
+export MYSQL_PASS=
+export MYSQL_DBNAME=test
+
 %:
        dh $@ --with perl_dbi
 
 override_dh_auto_test:
-       dh_auto_test -- TEST_FILES='t/00base.t'
+ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
+       # prepare mysql
+       sh $(CURDIR)/debian/tests/pkg-perl/smoke-setup
+
+       dh_auto_test
+
+       # tear down mysql
+       sh $(CURDIR)/debian/tests/pkg-perl/smoke-cleanup
+endif
 
 override_dh_auto_install:
        dh_auto_install
diff --git a/debian/tests/pkg-perl/smoke-cleanup 
b/debian/tests/pkg-perl/smoke-cleanup
new file mode 100755
index 0000000..9de249e
--- /dev/null
+++ b/debian/tests/pkg-perl/smoke-cleanup
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+[ -z "$ADTTMP" ] || cd $TDIR
+
+/usr/bin/mysqladmin --socket=${MYSQL_UNIX_PORT} shutdown 2>&1
+[ ! -s "${MYSQL_PIDFILE}" ] || /bin/kill $(cat "${MYSQL_PIDFILE}") || true
+rm -rf ${MYSQL_DIR}
diff --git a/debian/tests/pkg-perl/smoke-env b/debian/tests/pkg-perl/smoke-env
new file mode 100644
index 0000000..8531fc3
--- /dev/null
+++ b/debian/tests/pkg-perl/smoke-env
@@ -0,0 +1,7 @@
+# mysql setup
+MYSQL_DIR=$(pwd)/t/testdb
+MYSQL_UNIX_PORT=$(pwd)/t/testdb/mysql.sock
+MYSQL_PIDFILE=$(pwd)/t/testdb/mysql.pid
+MYSQL_USER=$(whoami)
+MYSQL_PASS=
+MYSQL_DBNAME=test
diff --git a/debian/tests/pkg-perl/smoke-files 
b/debian/tests/pkg-perl/smoke-files
deleted file mode 100644
index 88cb629..0000000
--- a/debian/tests/pkg-perl/smoke-files
+++ /dev/null
@@ -1,2 +0,0 @@
-t/00base.t
-t/lib.pl
diff --git a/debian/tests/pkg-perl/smoke-setup 
b/debian/tests/pkg-perl/smoke-setup
new file mode 100755
index 0000000..7d083f4
--- /dev/null
+++ b/debian/tests/pkg-perl/smoke-setup
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+[ -z "$ADTTMP" ] || cd $TDIR
+
+# redirect STDERR to STDIN, autopkgtest fails otherwise
+
+mysql_install_db --no-defaults --datadir=${MYSQL_DIR} --force 
--skip-name-resolve --user=${MYSQL_USER} 2>&1
+/usr/sbin/mysqld --no-defaults --user=${MYSQL_USER} 
--socket=${MYSQL_UNIX_PORT} --datadir=${MYSQL_DIR} --pid-file=${MYSQL_PIDFILE} 
--skip-networking  --skip-grant-tables 2>&1 &
+attempts=0
+while ! /usr/bin/mysqladmin --socket=${MYSQL_UNIX_PORT} ping 2>&1 ; do
+       sleep 3
+       attempts=$((attempts+1))
+       if [ ${attempts} -gt 10 ] ; then
+               echo "skipping test, mysql server could not be contacted after 
30 seconds"
+               exit 1
+       fi
+done
+mysql --socket=${MYSQL_UNIX_PORT} --execute "CREATE DATABASE ${MYSQL_DBNAME};" 
2>&1
+
+# fails because mysqld is started with --skip-grant-tables
+# (without there's only a passwordless unix-sockety root account
+#mysql --socket=${MYSQL_UNIX_PORT} --execute "GRANT ALL PRIVILEGES ON 
${MYSQL_DBNAME}.* TO '${MYSQL_USER}'@'localhost' IDENTIFIED BY 
'${MYSQL_PASS}';" 2>&1
diff --git a/debian/tests/pkg-perl/smoke-skip b/debian/tests/pkg-perl/smoke-skip
new file mode 100644
index 0000000..7ace699
--- /dev/null
+++ b/debian/tests/pkg-perl/smoke-skip
@@ -0,0 +1,2 @@
+# checks for Bundle::DBD::mysql which is not installed in the Debian package
+t/version.t

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libdbd-mysql-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to