nats.zig/deps/nats.c/test/CMakeLists.txt
torque 79a45fd2e3
git subrepo clone (merge) --branch=v3.6.1 https://github.com/nats-io/nats.c.git deps/nats.c
subrepo:
  subdir:   "deps/nats.c"
  merged:   "66cec7f"
upstream:
  origin:   "https://github.com/nats-io/nats.c.git"
  branch:   "v3.6.1"
  commit:   "66cec7f"
git-subrepo:
  version:  "0.4.6"
  commit:   "b8b46501e"
2023-08-15 00:21:33 -07:00

49 lines
1.3 KiB
CMake

if(NOT BUILD_TESTING)
return()
endif()
if(NOT NATS_BUILD_LIB_STATIC)
MESSAGE(FATAL_ERROR
"Building tests require static library, or run CMake with -DBUILD_TESTING=OFF")
return()
endif()
# We need this to build the test program
include_directories(${PROJECT_SOURCE_DIR}/src)
if(NATS_BUILD_WITH_TLS)
include_directories(${OPENSSL_INCLUDE_DIR})
endif(NATS_BUILD_WITH_TLS)
if(NATS_BUILD_STREAMING)
include_directories(${NATS_PROTOBUF_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/src/stan)
endif(NATS_BUILD_STREAMING)
# Build the test program
add_executable(testsuite test.c)
# Link statically with the library
target_link_libraries(testsuite nats_static ${NATS_EXTRA_LIB})
# Set the test index to 0
set(testIndex 0)
# Read the file 'list.txt' to get all the test names
file(STRINGS list.txt listOfTestNames)
# For each test name
foreach(name ${listOfTestNames})
# Create a test and pass the index (start and end are the same)
# to the testsuite executable
add_test(NAME Test_${name}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMAND testsuite ${testIndex} ${testIndex})
# Make sure the test passes
set_tests_properties(Test_${name} PROPERTIES PASS_REGULAR_EXPRESSION "ALL PASSED")
# Bump the test index number
math(EXPR testIndex "${testIndex}+1")
endforeach()