* [gentoo-commits] repo/gentoo:master commit in: profiles/arch/powerpc/ppc32/, dev-ruby/mysql2/
@ 2023-04-07 11:25 Sam James
0 siblings, 0 replies; only message in thread
From: Sam James @ 2023-04-07 11:25 UTC (permalink / raw
To: gentoo-commits
commit: 7d015ad7ced54062060803a8831c0ef08c464249
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 7 07:15:56 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Apr 7 11:24:50 2023 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7d015ad7
dev-ruby/mysql2: enable ruby32, run tests
Signed-off-by: Sam James <sam <AT> gentoo.org>
dev-ruby/mysql2/mysql2-0.5.5.ebuild | 105 +++++++++++++++++++++++++--
profiles/arch/powerpc/ppc32/package.use.mask | 4 +
2 files changed, 103 insertions(+), 6 deletions(-)
diff --git a/dev-ruby/mysql2/mysql2-0.5.5.ebuild b/dev-ruby/mysql2/mysql2-0.5.5.ebuild
index b247f8f33093..5ec2338a5603 100644
--- a/dev-ruby/mysql2/mysql2-0.5.5.ebuild
+++ b/dev-ruby/mysql2/mysql2-0.5.5.ebuild
@@ -2,10 +2,10 @@
# Distributed under the terms of the GNU General Public License v2
EAPI=8
-USE_RUBY="ruby27 ruby30 ruby31"
-# Tests require a live MySQL database but should all pass.
-RUBY_FAKEGEM_TASK_TEST=""
+USE_RUBY="ruby27 ruby30 ruby31 ruby32"
+
+RUBY_FAKEGEM_RECIPE_TEST="rspec3"
RUBY_FAKEGEM_TASK_DOC=""
@@ -28,9 +28,15 @@ KEYWORDS="amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~riscv ~sparc ~x86"
IUSE="mysql mariadb"
REQUIRED_USE="^^ ( mariadb mysql )"
-MDEPEND="mysql? ( dev-db/mysql-connector-c:= ) mariadb? ( dev-db/mariadb-connector-c:= )"
-DEPEND="${DEPEND} ${MDEPEND}"
-RDEPEND="${RDEPEND} ${MDEPEND}"
+SQL_DEPEND="mysql? ( dev-db/mysql-connector-c:= ) mariadb? ( dev-db/mariadb-connector-c:= )"
+DEPEND="${DEPEND} ${SQL_DEPEND}"
+RDEPEND="${RDEPEND} ${SQL_DEPEND}"
+BDEPEND="
+ test? (
+ mariadb? ( dev-db/mariadb:* )
+ mysql? ( >=dev-db/mysql-8:* )
+ )
+"
all_ruby_prepare() {
sed -i -e '/s.version/ s/Mysql2::VERSION/"'${PV}'"/' ${RUBY_FAKEGEM_GEMSPEC} || die
@@ -47,3 +53,90 @@ each_ruby_configure() {
${RUBY} -Cext/mysql2 extconf.rb --with-mysql-config="${config}" || die
}
+
+each_ruby_test() {
+ local -x USER=$(whoami)
+
+ if use mariadb ; then
+ local -x PATH="${BROOT}/usr/share/mariadb/scripts:${PATH}"
+ fi
+
+ einfo "Creating mysql test instance ..."
+ mkdir -p "${T}"/mysql || die
+ if use mariadb ; then
+ mysql_install_db \
+ --no-defaults \
+ --auth-root-authentication-method=normal \
+ --basedir="${EPREFIX}/usr" \
+ --datadir="${T}"/mysql 1>"${T}"/mysqld_install.log || die
+ else
+ mysqld \
+ --no-defaults \
+ --initialize-insecure \
+ --user ${USER} \
+ --basedir="${EPREFIX}/usr" \
+ --datadir="${T}"/mysql 1>"${T}"/mysqld_install.log || die
+ fi
+
+ einfo "Starting mysql test instance ..."
+ # TODO: random port
+ mysqld \
+ --no-defaults \
+ --character-set-server=utf8 \
+ --bind-address=127.0.0.1 \
+ --pid-file="${T}"/mysqld.pid \
+ --socket="${T}"/mysqld.sock \
+ --datadir="${T}"/mysql 1>"${T}"/mysqld.log 2>&1 &
+
+ # 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"
+
+ einfo "Configuring test mysql instance ..."
+
+ mysql -u root --socket="${T}"/mysqld.sock -s -e '
+ CREATE DATABASE test1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
+ ' || die "Failed to create test databases"
+
+ # https://github.com/brianmario/mysql2/blob/master/ci/setup.sh
+ mysql -u root \
+ -e 'CREATE DATABASE /*M!50701 IF NOT EXISTS */ test' \
+ -S "${T}"/mysqld.sock || die
+
+ # https://github.com/brianmario/mysql2/blob/master/tasks/rspec.rake
+ cat <<-EOF > spec/configuration.yml || die
+ root:
+ host: localhost
+ username: root
+ password:
+ database: test
+ socket: ${T}/mysqld.sock
+
+ user:
+ host: localhost
+ username: root
+ password:
+ database: mysql2_test
+ socket: ${T}/mysqld.sock
+ EOF
+
+ nonfatal each_fakegem_test
+ local ret=${?}
+
+ einfo "Stopping mysql test instance ..."
+ pkill -F "${T}"/mysqld.pid || die
+ # wait for it to stop
+ local i
+ for (( i = 0; i < 10; i++ )); do
+ [[ -S ${T}/mysqld.sock ]] || break
+ sleep 1
+ done
+
+ rm -rf "${T}"/mysql || die
+
+ [[ ${ret} -ne 0 ]] && die
+}
diff --git a/profiles/arch/powerpc/ppc32/package.use.mask b/profiles/arch/powerpc/ppc32/package.use.mask
index 0a3e61556837..99e054d3aec9 100644
--- a/profiles/arch/powerpc/ppc32/package.use.mask
+++ b/profiles/arch/powerpc/ppc32/package.use.mask
@@ -1,6 +1,10 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
+# Sam James <sam@gentoo.org> (2023-04-07)
+# dev-db/mysql not stable here
+dev-ruby/mysql2 mysql
+
# Sam James <sam@gentoo.org> (2023-01-05)
# dev-python/pythran fails tests on ppc32 right now, bug #880263
dev-python/scipy fortran pythran
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-07 11:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-07 11:25 [gentoo-commits] repo/gentoo:master commit in: profiles/arch/powerpc/ppc32/, dev-ruby/mysql2/ Sam James
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox