summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Schmaus <flow@gentoo.org>2024-02-23 12:28:34 +0100
committerFlorian Schmaus <flow@gentoo.org>2024-02-23 13:17:09 +0100
commit6663153d5011f64051edc3e6b58b929fe5b05232 (patch)
treecbc1917f9f9be48574be003ab0a0ada935898669 /app-shells
parentsys-libs/glibc: rekeyword 2.39 (diff)
downloadgentoo-6663153d5011f64051edc3e6b58b929fe5b05232.tar.gz
gentoo-6663153d5011f64051edc3e6b58b929fe5b05232.tar.bz2
gentoo-6663153d5011f64051edc3e6b58b929fe5b05232.zip
app-shells/atuin: enable server tests
Closes: https://bugs.gentoo.org/925163 Closes: https://github.com/gentoo/gentoo/pull/35495 Signed-off-by: Florian Schmaus <flow@gentoo.org>
Diffstat (limited to 'app-shells')
-rw-r--r--app-shells/atuin/atuin-18.0.1.ebuild42
1 files changed, 36 insertions, 6 deletions
diff --git a/app-shells/atuin/atuin-18.0.1.ebuild b/app-shells/atuin/atuin-18.0.1.ebuild
index db09098f28cc..23014456276e 100644
--- a/app-shells/atuin/atuin-18.0.1.ebuild
+++ b/app-shells/atuin/atuin-18.0.1.ebuild
@@ -457,6 +457,7 @@ REQUIRED_USE="
test? ( client server sync )
"
RDEPEND="server? ( acct-user/atuin )"
+DEPEND="test? ( dev-db/postgresql )"
BDEPEND=">=virtual/rust-1.71.0"
QA_FLAGS_IGNORED="usr/bin/${PN}"
@@ -467,12 +468,6 @@ DOCS=(
README.md
)
-src_prepare() {
- default
-
- rm atuin/tests/sync.rs || die
-}
-
src_configure() {
local myfeatures=(
$(usev client)
@@ -503,6 +498,41 @@ src_compile() {
done
}
+src_test() {
+ local postgres_dir="${T}"/postgres
+ initdb "${postgres_dir}" || die
+
+ local port=11123
+ # -h '' → only socket connections allowed.
+ postgres -D "${postgres_dir}" \
+ -k "${postgres_dir}" \
+ -p "${port}" &
+ local postgres_pid=${!}
+
+ local timeout_secs=30
+ timeout "${timeout_secs}" bash -c \
+ 'until printf "" >/dev/tcp/${0}/${1} 2>> "${T}/portlog"; do sleep 1; done' \
+ localhost "${port}" || die "Timeout waiting for postgres port ${port} to become available"
+
+ psql -h localhost -p "${port}" -d postgres <<-EOF || die "Failed to configure postgres"
+ create database atuin;
+ create user atuin with encrypted password 'pass';
+ grant all privileges on database atuin to atuin;
+ \connect atuin
+ grant all on schema public to atuin;
+ EOF
+
+ # Subshell so that postgres_pid is in scope when the trap is executed.
+ (
+ cleanup() {
+ kill "${postgres_pid}" || die "failed to send SIGTERM to postgres"
+ }
+ trap cleanup EXIT
+
+ ATUIN_DB_URI="postgres://atuin:pass@localhost:${port}/atuin" cargo_src_test
+ )
+}
+
src_install() {
exeinto "/usr/bin"
doexe "${ATUIN_BIN}"