Skip to content

Commit

Permalink
build(CMake): support running tests with ctest
Browse files Browse the repository at this point in the history
  • Loading branch information
matoro committed Jul 2, 2024
1 parent c8834c2 commit d94e2b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ else()
BLAKE3_DISABLE_SIMD()
endif()

# cmake test support
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 "${CMAKE_CURRENT_SOURCE_DIR}/test.py" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")

# 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

0 comments on commit d94e2b8

Please sign in to comment.