From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5C64D1382C5 for ; Thu, 11 Jun 2020 20:33:15 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8C5A1E0831; Thu, 11 Jun 2020 20:33:13 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 723CFE0831 for ; Thu, 11 Jun 2020 20:33:13 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 34FE134F133 for ; Thu, 11 Jun 2020 20:33:11 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id CA8B19C for ; Thu, 11 Jun 2020 20:33:06 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1591907582.0e2e2731b6f02a900bf2ab99b03496c10e5da089.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/pymysql/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-python/pymysql/pymysql-0.9.3.ebuild X-VCS-Directories: dev-python/pymysql/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 0e2e2731b6f02a900bf2ab99b03496c10e5da089 X-VCS-Branch: master Date: Thu, 11 Jun 2020 20:33:06 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 76b070dd-5136-48ce-857a-f8ad0053a988 X-Archives-Hash: b255e45ebc52a97442c491f550b8571f commit: 0e2e2731b6f02a900bf2ab99b03496c10e5da089 Author: Michał Górny gentoo org> AuthorDate: Thu Jun 11 20:18:16 2020 +0000 Commit: Michał Górny gentoo org> CommitDate: Thu Jun 11 20:33:02 2020 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0e2e2731 dev-python/pymysql: Enable tests Signed-off-by: Michał Górny gentoo.org> dev-python/pymysql/pymysql-0.9.3.ebuild | 55 ++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/dev-python/pymysql/pymysql-0.9.3.ebuild b/dev-python/pymysql/pymysql-0.9.3.ebuild index e0580ba4984..5ab0788a13a 100644 --- a/dev-python/pymysql/pymysql-0.9.3.ebuild +++ b/dev-python/pymysql/pymysql-0.9.3.ebuild @@ -13,18 +13,65 @@ MY_P="${MY_PN}-${PV}" DESCRIPTION="Pure-Python MySQL Driver" HOMEPAGE="https://github.com/PyMySQL/PyMySQL" SRC_URI="https://github.com/${MY_PN}/${MY_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" +S=${WORKDIR}/${MY_P} LICENSE="MIT" SLOT="0" KEYWORDS="amd64 ~arm64 x86" IUSE="test" +RESTRICT="!test? ( test )" -S=${WORKDIR}/${MY_P} +# TODO: support other mysql variants +BDEPEND=" + test? ( dev-db/mariadb[server] )" + +src_prepare() { + find -name '*.py' -exec sed -i -e 's:unittest2:unittest:' {} + || die + distutils-r1_src_prepare +} + +src_test() { + mkdir -p "${T}"/mysql || die + "${BROOT}"/usr/share/mariadb/scripts/mysql_install_db \ + --no-defaults \ + --auth-root-authentication-method=normal \ + --basedir="${BROOT}/usr" \ + --datadir="${T}"/mysql || die + # TODO: random port + mysqld \ + --no-defaults \ + --character-set-server=utf8 \ + --bind-address=127.0.0.1 \ + --port=3306 \ + --socket="${T}"/mysqld.sock \ + --datadir="${T}"/mysql & + local pid=${!} -DEPEND="dev-python/setuptools[${PYTHON_USEDEP}]" + # wait for it to start + local i + for (( i = 0; i < 10; i++)); do + [[ -S ${T}/mysqld.sock ]] && break + sleep 1 + done + [[ -S ${T}/mysqld.sock ]] || die "mysqld failed to start" -# While tests exist, they require an unsecure server to run without manual config file -RESTRICT="test" + # create test databases + mysql -uroot --socket="${T}"/mysqld.sock -e ' + create database test1 DEFAULT CHARACTER SET utf8mb4; + create database test2 DEFAULT CHARACTER SET utf8mb4; + + create user test2 identified by "some password"; + grant all on test2.* to test2; + + create user test2@localhost identified by "some password"; + grant all on test2.* to test2@localhost; + ' || die + + distutils-r1_src_test + + kill "${pid}" + wait "${pid}" +} python_test() { ${PYTHON} runtests.py || die