[Python-modules-commits] [webpy] 01/02: add test script by Thomas Goirand <zigo at debian.org>, see #767509

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Jul 23 08:47:46 UTC 2016


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

debacle pushed a commit to branch bug-767453
in repository webpy.

commit 826952580c3e6de8a4bd236a986f350eaea99870
Author: W. Martin Borgert <debacle at debian.org>
Date:   Sat Jul 23 10:29:35 2016 +0200

    add test script by Thomas Goirand <zigo at debian.org>, see #767509
---
 debian/control      |   9 +++++
 debian/rules        |   8 ++++
 debian/run_tests.sh | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 128 insertions(+)

diff --git a/debian/control b/debian/control
index c016180..597c5f6 100644
--- a/debian/control
+++ b/debian/control
@@ -4,6 +4,15 @@ Priority: optional
 Maintainer: Debian Python Modules Team <python-modules-team at lists.alioth.debian.org>
 Uploaders: W. Martin Borgert <debacle at debian.org>
 Build-Depends: debhelper (>= 7), python-all (>= 2.6.6-3~),
+Build-Depends-Indep: mysql-client,
+                     mysql-server,
+                     postgresql,
+                     postgresql-client,
+                     python-dbutils,
+                     python-mysqldb,
+                     python-pygresql,
+                     python-sqlite,
+                     locales-all | language-pack-en
 Standards-Version: 3.9.3.1
 Homepage: http://webpy.org/
 Vcs-Git: https://anonscm.debian.org/git/python-modules/packages/webpy.git
diff --git a/debian/rules b/debian/rules
index ea3fbe9..7352400 100755
--- a/debian/rules
+++ b/debian/rules
@@ -5,3 +5,11 @@
 
 %:
 	dh $@ --with python2
+
+override_dh_auto_test:
+ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
+	chmod +x debian/run_tests.sh
+	set -e ; for pyvers in $(PYTHONS) $(PYTHON3S); do \
+		pyvers=$${pyvers} debian/run_tests.sh ; \
+	done
+endif
diff --git a/debian/run_tests.sh b/debian/run_tests.sh
new file mode 100755
index 0000000..f8ea8ef
--- /dev/null
+++ b/debian/run_tests.sh
@@ -0,0 +1,111 @@
+#!/bin/sh
+#
+# test_mysql.sh - runs libdbi test suite for mysql driver using a temporary
+# mysql server environment that doesn't distrubs any running MySQL server.
+#
+# Copyright (C) 2010 Clint Byrum <clint at ubuntu.com>
+# Copyright (C) 2010 Thomas Goirand <zigo at debian.org>
+#
+# This script is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; either version 2.1 of the License, or (at your option)
+# any later version.
+#
+# This script is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to:
+# The Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301 USA
+
+set -e
+set -x
+
+###############################
+### RUN THE MYSQLD INSTANCE ###
+###############################
+MYTEMP_DIR=`mktemp -d`
+ME=`whoami`
+
+# --force is needed because buildd's can't resolve their own hostnames to ips
+mysql_install_db --no-defaults --datadir=${MYTEMP_DIR} --force --skip-name-resolve --user=${ME}
+/usr/sbin/mysqld --no-defaults --skip-grant --user=${ME} --socket=${MYTEMP_DIR}/mysql.sock --datadir=${MYTEMP_DIR} --skip-networking &
+
+# This sets the path of the MySQL socket for any libmysql-client users, which includes
+# the ./tests/test_dbi client
+export MYSQL_UNIX_PORT=${MYTEMP_DIR}/mysql.sock
+
+echo -n pinging mysqld.
+attempts=0
+while ! /usr/bin/mysqladmin --socket=${MYTEMP_DIR}/mysql.sock ping ; do
+	sleep 3
+	attempts=$((attempts+1))
+	if [ ${attempts} -gt 10 ] ; then
+		echo "skipping test, mysql server could not be contacted after 30 seconds"
+		exit 0
+	fi
+done
+
+# Create the db
+mysql --socket=${MYTEMP_DIR}/mysql.sock --execute="CREATE DATABASE webpy;"
+
+##############################
+### RUN THE PGSQL INSTANCE ###
+##############################
+MYUSER=`whoami`
+# initdb refuses to run as root
+if [ "${MYUSER}" = "root" ] ; then
+	echo dropping root privs..
+	exec /bin/su postgres -- "$0" "$@"
+fi
+
+PG_MYTMPDIR=`mktemp -d`
+BINDIR=`pg_config --bindir`
+
+# depends on language-pack-en | language-pack-en
+# because initdb acquires encoding from locale
+export LC_ALL="en_US.UTF-8"
+${BINDIR}/initdb -D ${PG_MYTMPDIR}
+${BINDIR}/postgres -D ${PG_MYTMPDIR} -h '' -k ${PG_MYTMPDIR} &
+attempts=0
+while ! [ -e ${PG_MYTMPDIR}/postmaster.pid ] ; do
+	attempts=$((attempts+1))
+	if [ "${attempts}" -gt 10 ] ; then
+		echo "Exiting test: postgres pid file was not created after 30 seconds"
+		exit 1
+	fi
+	sleep 3
+        echo `date`: retrying..
+done
+
+# Set the env. var so that pgsql client doesn't use networking
+# libpq uses this for all host params if not explicitly passed
+export PGHOST=${PG_MYTMPDIR}
+
+# Create a new test db
+createdb webpy
+
+#####################
+### RUN THE TESTS ###
+#####################
+# Launch the tests
+PYTHONPATH=. python$pyvers test/alltests.py
+ecode=$?
+
+###############################################
+### SHUTDOWN MYSQL AND CLEAN ITS TMP FOLDER ###
+###############################################
+/usr/bin/mysqladmin --socket=${MYTEMP_DIR}/mysql.sock shutdown
+rm -rf ${MYTEMP_DIR}
+
+###############################################
+### SHUTDOWN PGSQL AND CLEAN ITS TMP FOLDER ###
+###############################################
+$BINDIR/pg_ctl stop -D ${PG_MYTMPDIR}
+wait
+rm -rf ${PG_MYTMPDIR}
+
+exit ${ecode}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/webpy.git



More information about the Python-modules-commits mailing list