Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(CMake): support running tests with ctest #405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions c/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -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)
Expand Down