summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatoro Mahri <matoro_gentoo@matoro.tk>2024-08-08 22:06:36 -0400
committerMichał Górny <mgorny@gentoo.org>2024-08-09 19:20:45 +0200
commitcbe461a76a6ccfa9eea0cd6fa4c5e9584f03db51 (patch)
treec85e1b95b4ad0729ec1e26dc97631e1a79c1c2c1 /dev-libs/blake3
parentdev-python/pyproject-fmt: Stabilize 2.1.4 ppc64, #936343 (diff)
downloadgentoo-cbe461a76a6ccfa9eea0cd6fa4c5e9584f03db51.tar.gz
gentoo-cbe461a76a6ccfa9eea0cd6fa4c5e9584f03db51.tar.bz2
gentoo-cbe461a76a6ccfa9eea0cd6fa4c5e9584f03db51.zip
dev-libs/blake3: wire up tests
See: https://github.com/BLAKE3-team/BLAKE3/pull/405 Bug: https://bugs.gentoo.org/935370 Signed-off-by: Matoro Mahri <matoro_gentoo@matoro.tk> Closes: https://github.com/gentoo/gentoo/pull/38021 Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-libs/blake3')
-rw-r--r--dev-libs/blake3/blake3-1.5.3.ebuild18
-rw-r--r--dev-libs/blake3/files/blake3-1.5.3-backport-pr405.patch57
2 files changed, 74 insertions, 1 deletions
diff --git a/dev-libs/blake3/blake3-1.5.3.ebuild b/dev-libs/blake3/blake3-1.5.3.ebuild
index 073d73e0061b..0e7f9fe25cc9 100644
--- a/dev-libs/blake3/blake3-1.5.3.ebuild
+++ b/dev-libs/blake3/blake3-1.5.3.ebuild
@@ -3,7 +3,8 @@
EAPI=8
-inherit cmake
+PYTHON_COMPAT=( python3_{11..13} )
+inherit cmake python-any-r1
DESCRIPTION="a fast cryptographic hash function"
HOMEPAGE="https://github.com/BLAKE3-team/BLAKE3"
@@ -13,3 +14,18 @@ S="${WORKDIR}/BLAKE3-${PV}/c"
LICENSE="|| ( CC0-1.0 Apache-2.0 )"
SLOT="0/0"
KEYWORDS="~amd64 ~arm ~arm64 ~ia64 ~loong ~m68k ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
+IUSE="test"
+RESTRICT="!test? ( test )"
+PATCHES=( "${FILESDIR}/${PN}-1.5.3-backport-pr405.patch" )
+BDEPEND="test? ( ${PYTHON_DEPS} )"
+
+pkg_setup() {
+ use test && python-any-r1_pkg_setup
+}
+
+src_configure() {
+ local mycmakeargs=(
+ -DBLAKE3_BUILD_TESTING="$(usex test)"
+ )
+ cmake_src_configure
+}
diff --git a/dev-libs/blake3/files/blake3-1.5.3-backport-pr405.patch b/dev-libs/blake3/files/blake3-1.5.3-backport-pr405.patch
new file mode 100644
index 000000000000..53db4816a859
--- /dev/null
+++ b/dev-libs/blake3/files/blake3-1.5.3-backport-pr405.patch
@@ -0,0 +1,57 @@
+https://bugs.gentoo.org/935370
+https://github.com/BLAKE3-team/BLAKE3/pull/405
+
+From aad68f7f009b7e0607b3eee3b8b8e3021fa38bd7 Mon Sep 17 00:00:00 2001
+From: matoro <matoro@users.noreply.github.com>
+Date: Tue, 2 Jul 2024 19:36:45 -0400
+Subject: [PATCH] build(CMake): support running tests with ctest
+
+---
+ CMakeLists.txt | 11 +++++++++++
+ test.py | 4 ++--
+ 2 files changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 3a3b232d..e778e3d7 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -168,6 +168,17 @@ else()
+ BLAKE3_DISABLE_SIMD()
+ endif()
+
++# cmake test support
++if (BLAKE3_BUILD_TESTING)
++ find_package(Python3 REQUIRED)
++ get_target_property(BLAKE3_SOURCES blake3 SOURCES)
++ add_executable(blake3-testing ${BLAKE3_SOURCES} main.c)
++ set_property(TARGET blake3-testing PROPERTY OUTPUT_NAME blake3)
++ target_compile_definitions(blake3-testing PRIVATE BLAKE3_TESTING=1)
++ enable_testing()
++ add_test(test_vectors "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/test.py" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
++endif()
++
+ # cmake install support
+ install(FILES blake3.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
+ install(TARGETS blake3 EXPORT blake3-targets)
+diff --git a/test.py b/test.py
+index 98b1c3df..2eb1f07e 100755
+--- a/test.py
++++ b/test.py
+@@ -2,7 +2,7 @@
+
+ from binascii import hexlify
+ import json
+-from os import path
++from os import getcwd, path
+ import subprocess
+
+ HERE = path.dirname(__file__)
+@@ -11,7 +11,7 @@
+
+
+ def run_blake3(args, input):
+- output = subprocess.run([path.join(HERE, "blake3")] + args,
++ output = subprocess.run([path.join(getcwd(), "blake3")] + args,
+ input=input,
+ stdout=subprocess.PIPE,
+ check=True)