# Copyright 1999-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 DISTUTILS_SINGLE_IMPL=yes DISTUTILS_USE_PEP517=setuptools PYTHON_COMPAT=( python3_{12..14} ) PYPI_VERIFY_REPO=https://github.com/dbcli/mycli inherit distutils-r1 edo multiprocessing pypi DESCRIPTION="CLI for MySQL Database with auto-completion and syntax highlighting" HOMEPAGE=" https://www.mycli.net/ https://github.com/dbcli/mycli/ https://pypi.org/project/mycli/ " LICENSE="BSD MIT" SLOT="0" KEYWORDS="~amd64" # optional llm unpackaged # =/' \ -i pyproject.toml || die # convert from pycryptodomex to pycryptodome sed -e 's/pycryptodomex/pycryptodome/' -i pyproject.toml || die sed -e 's/from Cryptodome/from Crypto/' -i mycli/config.py || die # network-sandbox messes with these sed -e '/run mycli on localhost without port/i @gentoo_skip' \ -e '/run mycli on TCP host without port/i @gentoo_skip' \ -e '/run mycli without host and port/i @gentoo_skip' \ -i test/features/connection.feature || die # Requires an old school vi and the symlink for vi itself messes with this sed -e '/edit sql in file with external editor/i @gentoo_skip' \ -i test/features/iocommands.feature || die distutils-r1_python_prepare_all } src_test() { # test/utils.py local -x PYTEST_PASSWORD="notsecure" local -x PYTEST_HOST="127.0.0.1" local -x PYTEST_PORT="43307" local -x PYTEST_CHARSET="utf8" einfo "Creating mysql test instance ..." mysqld \ --no-defaults \ --initialize-insecure \ --basedir="${EPREFIX}/usr" \ --datadir="${T}/mysql" 1>"${T}"/mysql_install.log || die einfo "Starting mysql test instance ..." mysqld \ --no-defaults \ --character-set-server="${PYTEST_CHARSET}" \ --bind-address="${PYTEST_HOST}" \ --port="${PYTEST_PORT}" \ --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" \ -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '${PYTEST_PASSWORD}'" \ || die "Failed to change mysql user password" EPYTEST_IGNORE=( # Requires unpackaged llm test/pytests/test_special_llm.py ) local failures=() if ! nonfatal epytest -o addopts= ; then failures+=( pytest ) fi if ! nonfatal edo behave \ --jobs=$(get_makeopts_jobs) \ --summary --verbose \ --tags="not @gentoo_skip" \ test/features ; then failures+=( behave ) fi 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 if [[ ${#failures[@]} -gt 0 ]]; then die "Tests failed with ${EPYTHON}: ${failures}" fi }