commit:     a56f53313c576244d9c4dab4577c5b554d828298
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 29 09:32:21 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Apr  3 05:10:36 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a56f5331

media-libs/lastfmlib: update EAPI 7 -> 8, wire up & fix tests

That said, we should really last-rite this anyway, per bug #928115, it's
just that I started working on this before I noticed that bug...

Bug: https://bugs.gentoo.org/928115
Closes: https://bugs.gentoo.org/889298
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/lastfmlib-0.4.0-autotools-tests.patch    | 31 ++++++++++++++
 .../files/lastfmlib-0.4.0-out-of-bounds-trim.patch | 24 +++++++++++
 media-libs/lastfmlib/lastfmlib-0.4.0-r2.ebuild     | 50 ++++++++++++++++++++++
 3 files changed, 105 insertions(+)

diff --git a/media-libs/lastfmlib/files/lastfmlib-0.4.0-autotools-tests.patch 
b/media-libs/lastfmlib/files/lastfmlib-0.4.0-autotools-tests.patch
new file mode 100644
index 000000000000..506d5a37693b
--- /dev/null
+++ b/media-libs/lastfmlib/files/lastfmlib-0.4.0-autotools-tests.patch
@@ -0,0 +1,31 @@
+* Run the tests as part of 'make check' (not just building testrunner).
+* Use pkg-config to find gtest, not the now-removed gtest-config.
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -59,6 +59,7 @@ pkgconfig_DATA = liblastfmlib.pc
+ 
+ if ENABLE_UNITTEST
+ check_PROGRAMS = testrunner
++TESTS = $(check_PROGRAMS)
+ endif
+ 
+ testrunner_SOURCES =    lastfmlib/unittest/testrunner.cpp \
+--- a/configure.ac
++++ b/configure.ac
+@@ -51,13 +51,10 @@ AC_ARG_ENABLE(unittests,
+    [  --enable-unittests Enables build of unittests ],
+    ENABLE_UNITTEST=$enableval)
+ 
+-if test "$ENABLE_UNITTEST" = "yes"; then
+-    AC_CHECK_HEADERS(
+-    [gtest/gtest.h],,
+-    [AC_MSG_ERROR([Missing gtest library, install the google unittest 
framework])])
+-    UNITTEST_LIBS="$(gtest-config --libs)"
++AS_IF([test "$ENABLE_UNITTEST" = "yes"], [
++    PKG_CHECK_MODULES([UNITTEST], [gtest], [], [AC_MSG_ERROR([Missing gtest 
library, install the google unittest framework])])
+     AC_SUBST(UNITTEST_LIBS)
+-fi
++])
+ AM_CONDITIONAL(ENABLE_UNITTEST, test "$enable_unittests" = "yes")
+ 
+ AC_SUBST([pkgconfigdir])

diff --git 
a/media-libs/lastfmlib/files/lastfmlib-0.4.0-out-of-bounds-trim.patch 
b/media-libs/lastfmlib/files/lastfmlib-0.4.0-out-of-bounds-trim.patch
new file mode 100644
index 000000000000..6c01a59269d4
--- /dev/null
+++ b/media-libs/lastfmlib/files/lastfmlib-0.4.0-out-of-bounds-trim.patch
@@ -0,0 +1,24 @@
+Fix out of bounds assertion with -D_GLIBCXX_ASSERTIONS on empty string in 
testsuite.
+--- a/lastfmlib/utils/stringoperations.cpp
++++ b/lastfmlib/utils/stringoperations.cpp
+@@ -40,7 +40,7 @@ void trim(std::string& aString)
+ {
+     size_t begin    = 0;
+     size_t end      = aString.size() - 1;
+-    
++
+     while ( aString[begin] == ' '  || aString[begin] == '\t'
+          || aString[begin] == '\r' || aString[begin] == '\n')
+     {
+@@ -50,8 +50,10 @@ void trim(std::string& aString)
+             break;
+     }
+ 
+-    if (begin == aString.size())
++    if (begin == aString.size()) {
+         aString = "";
++        return;
++    }
+ 
+     while ( aString[end] == ' '  || aString[end] == '\t'
+          || aString[end] == '\r' || aString[end] == '\n')

diff --git a/media-libs/lastfmlib/lastfmlib-0.4.0-r2.ebuild 
b/media-libs/lastfmlib/lastfmlib-0.4.0-r2.ebuild
new file mode 100644
index 000000000000..590503f295ec
--- /dev/null
+++ b/media-libs/lastfmlib/lastfmlib-0.4.0-r2.ebuild
@@ -0,0 +1,50 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools
+
+DESCRIPTION="C++ library to scrobble tracks on Last.fm"
+HOMEPAGE="https://github.com/dirkvdb/lastfmlib/releases";
+SRC_URI="https://github.com/dirkvdb/lastfmlib/archive/${P}.tar.gz";
+
+LICENSE="GPL-2+"
+SLOT="0"
+KEYWORDS="~amd64 ~ppc ~x86"
+IUSE="debug syslog test"
+RESTRICT="!test? ( test )"
+
+RDEPEND="net-misc/curl"
+DEPEND="
+       ${RDEPEND}
+       test? ( dev-cpp/gtest )
+"
+BDEPEND="virtual/pkgconfig"
+
+PATCHES=(
+       "${FILESDIR}/${P}-string-conv.patch"
+       "${FILESDIR}/${PN}-0.4.0-autotools-tests.patch"
+       "${FILESDIR}/${PN}-0.4.0-out-of-bounds-trim.patch"
+)
+
+src_prepare() {
+       default
+       eautoreconf
+}
+
+src_configure() {
+       CONFIG_SHELL="${BROOT}"/bin/bash econf \
+               $(use_enable debug) \
+               $(use_enable syslog logging) \
+               $(use_enable test unittests)
+}
+
+src_test() {
+       emake check VERBOSE=1
+}
+
+src_install() {
+       default
+       find "${D}"/usr -name '*.la' -delete || die "Pruning failed"
+}

Reply via email to