4 |
4 |
EAPI=8
|
5 |
5 |
|
6 |
6 |
DIST_AUTHOR=PALI
|
7 |
|
DIST_VERSION=1.22
|
|
7 |
DIST_VERSION=1.23
|
|
8 |
DIST_WIKI=tests
|
8 |
9 |
inherit perl-module
|
9 |
10 |
|
10 |
11 |
DESCRIPTION="MariaDB and MySQL driver for the Perl5 Database Interface (DBI)"
|
... | ... | |
20 |
21 |
mysql? ( dev-db/mysql-connector-c:= )
|
21 |
22 |
mariadb? ( dev-db/mariadb-connector-c:= )
|
22 |
23 |
"
|
|
24 |
DEPEND="
|
|
25 |
mysql? ( dev-db/mysql-connector-c:= )
|
|
26 |
mariadb? ( dev-db/mariadb-connector-c:= )
|
|
27 |
"
|
23 |
28 |
# New test-harness needed for parallel testing to work
|
24 |
|
DEPEND="${RDEPEND}
|
|
29 |
BDEPEND="
|
|
30 |
${RDEPEND}
|
25 |
31 |
virtual/perl-Data-Dumper
|
26 |
32 |
>=dev-perl/Devel-CheckLib-1.120.0
|
27 |
33 |
virtual/perl-ExtUtils-MakeMaker
|
... | ... | |
33 |
39 |
dev-perl/Proc-ProcessTable
|
34 |
40 |
virtual/perl-Storable
|
35 |
41 |
)
|
|
42 |
mariadb? ( dev-db/mariadb:* )
|
|
43 |
mysql? ( dev-db/mysql:* )
|
36 |
44 |
virtual/perl-Encode
|
37 |
45 |
virtual/perl-File-Temp
|
38 |
46 |
dev-perl/Test-Deep
|
... | ... | |
51 |
59 |
src_configure() {
|
52 |
60 |
local impl=$(usex mariadb mariadb mysql)
|
53 |
61 |
|
54 |
|
if use test; then
|
55 |
|
myconf=(
|
56 |
|
${myconf}
|
57 |
|
--testdb=test
|
58 |
|
--testhost=localhost
|
59 |
|
--testuser=test
|
60 |
|
--testpassword=test
|
61 |
|
)
|
62 |
|
fi
|
|
62 |
# These must be set at configure time
|
|
63 |
export DBD_MARIADB_TESTDB=test
|
|
64 |
export DBD_MARIADB_TESTSOCKET="${T}"/mysqld.sock
|
|
65 |
export DBD_MARIADB_TESTAUTHPLUGIN=mysql_native_password
|
|
66 |
export DBD_MARIADB_TESTUSER=root
|
63 |
67 |
|
64 |
|
myconf+=( --${impl}_config="${BROOT}"/usr/bin/${impl}_config )
|
|
68 |
myconf=( --${impl}_config="${BROOT}"/usr/bin/${impl}_config )
|
65 |
69 |
|
66 |
70 |
perl-module_src_configure
|
67 |
71 |
}
|
68 |
72 |
|
69 |
73 |
src_test() {
|
70 |
|
ewarn "Comprehensive testing requires additional manual steps. For details"
|
71 |
|
ewarn "see:"
|
72 |
|
ewarn " https://wiki.gentoo.org/wiki/Project:Perl/maint-notes/${CATEGORY}/${PN}#Testing"
|
73 |
|
|
74 |
|
einfo
|
75 |
|
einfo "If tests fail, you have to configure your MariaDB/MySQL instance"
|
76 |
|
einfo "to create and grant some privileges to the test user."
|
77 |
|
einfo "You can run the following commands at the MariaDB/MySQL prompt: "
|
78 |
|
einfo "> CREATE USER 'test'@'localhost' IDENTIFIED BY 'test';"
|
79 |
|
einfo "> CREATE DATABASE test;"
|
80 |
|
einfo "> GRANT ALL PRIVILEGES ON test.* TO 'test'@'localhost';"
|
81 |
|
einfo
|
|
74 |
local -x USER=$(whoami)
|
82 |
75 |
|
83 |
|
sleep 5
|
|
76 |
einfo "Creating mysql test instance ..."
|
|
77 |
mkdir -p "${T}"/mysql || die
|
|
78 |
if use mariadb ; then
|
|
79 |
local -x PATH="${BROOT}/usr/share/mariadb/scripts:${PATH}"
|
|
80 |
|
|
81 |
mysql_install_db \
|
|
82 |
--no-defaults \
|
|
83 |
--auth-root-authentication-method=normal \
|
|
84 |
--basedir="${EPREFIX}/usr" \
|
|
85 |
--datadir="${T}"/mysql 1>"${T}"/mysqld_install.log || die
|
|
86 |
else
|
|
87 |
mysqld \
|
|
88 |
--no-defaults \
|
|
89 |
--initialize-insecure \
|
|
90 |
--user ${USER} \
|
|
91 |
--basedir="${EPREFIX}/usr" \
|
|
92 |
--datadir="${T}"/mysql 1>"${T}"/mysqld_install.log || die
|
|
93 |
fi
|
|
94 |
|
|
95 |
einfo "Starting mysql test instance ..."
|
|
96 |
mysqld \
|
|
97 |
--no-defaults \
|
|
98 |
--character-set-server=utf8 \
|
|
99 |
--bind-address=127.0.0.1 \
|
|
100 |
--pid-file="${T}"/mysqld.pid \
|
|
101 |
--socket="${T}"/mysqld.sock \
|
|
102 |
--datadir="${T}"/mysql 1>"${T}"/mysqld.log 2>&1 &
|
|
103 |
|
|
104 |
# Wait for it to start
|
|
105 |
local i
|
|
106 |
for (( i = 0; i < 10; i++ )); do
|
|
107 |
[[ -S ${T}/mysqld.sock ]] && break
|
|
108 |
sleep 1
|
|
109 |
done
|
|
110 |
[[ ! -S ${T}/mysqld.sock ]] && die "mysqld failed to start"
|
|
111 |
|
|
112 |
einfo "Configuring test mysql instance ..."
|
|
113 |
mysql -u root \
|
|
114 |
-e 'CREATE DATABASE /*M!50701 IF NOT EXISTS */ test' \
|
|
115 |
-S "${T}"/mysqld.sock || die "Failed to create test database"
|
84 |
116 |
|
85 |
117 |
# Don't be a hero and try to do EXTENDED_TESTING=1 unless you can figure
|
86 |
118 |
# out why 60leaks.t fails
|
87 |
|
perl-module_src_test
|
|
119 |
nonfatal perl-module_src_test
|
|
120 |
ret=$?
|
|
121 |
|
|
122 |
einfo "Stopping mysql test instance ..."
|
|
123 |
pkill -F "${T}"/mysqld.pid || die
|
|
124 |
# wait for it to stop
|
|
125 |
local i
|
|
126 |
for (( i = 0; i < 10; i++ )); do
|
|
127 |
[[ -S ${T}/mysqld.sock ]] || break
|
|
128 |
sleep 1
|
|
129 |
done
|
|
130 |
|
|
131 |
rm -rf "${T}"/mysql || die
|
|
132 |
|
|
133 |
[[ ${ret} -ne 0 ]] && die
|
88 |
134 |
}
|