Skip to content

Commit

Permalink
on all platforms added CROW_FEATURES ssl, compression and needed libs…
Browse files Browse the repository at this point in the history
… to prerequisites

general tests are now enabled on MSVC, mustachetests disabled due to some strange bug in python script (will be done later)
  • Loading branch information
gittiver committed Jan 6, 2024
1 parent 6aed71e commit 37960c0
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 33 deletions.
34 changes: 25 additions & 9 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest, ubuntu-20.04,
macos-latest, macos-11,
windows-latest
os: [ ubuntu-latest,
windows-latest,
ubuntu-20.04,
macos-latest,
macos-11
]
# ubuntu-18.04 does not work due to compile error on asio
# windows-2019 not included to spare free minutes
Expand All @@ -36,11 +38,12 @@ jobs:
sudo apt-get update && \
sudo apt-get install -yq \
libasio-dev \
libssl-dev zlib1g-dev \
cmake
elif [ "$RUNNER_OS" == "Windows" ]; then
VCPKG_DEFAULT_TRIPLET=x64-windows vcpkg install
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install asio
brew install asio openssl zlib
else
echo "$RUNNER_OS not supported"
exit 1
Expand All @@ -51,12 +54,25 @@ jobs:
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
cmake \
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DCROW_FEATURES="ssl;compression" \
-DCROW_AMALGAMATE=ON \
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DCROW_FEATURES="ssl;compression" \
-DCROW_AMALGAMATE=ON \
-DCROW_BUILD_TESTS=ON \
-B build
elif [ "$RUNNER_OS" == "macOS" ]; then
LDFLAGS="-L/usr/local/opt/[email protected]/lib" \
CPPFLAGS="-I/usr/local/opt/[email protected]/include" \
cmake \
-DCROW_FEATURES="ssl;compression" \
-DCROW_AMALGAMATE=ON \
-DCROW_BUILD_TESTS=ON \
-B build
else
cmake \
-DCROW_FEATURES="ssl;compression" \
-DCROW_AMALGAMATE=ON \
-DCROW_BUILD_TESTS=ON \
-B build
else
cmake -B build
fi
shell: bash

Expand Down
42 changes: 28 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
endif()
if (MSVC)
add_compile_options(/bigobj)
endif ()

include(FindPython3)
find_package(Python3)

#####################################
# Define Options
Expand Down Expand Up @@ -94,20 +100,28 @@ if(CROW_BUILD_EXAMPLES)
endif()

# Tests
if(NOT MSVC AND CROW_BUILD_TESTS)
if(NOT "compression" IN_LIST CROW_FEATURES)
message(STATUS "Compression tests are omitted. (Configure with CROW_FEATURES containing 'compression' to enable them)")
endif()
if(NOT "ssl" IN_LIST CROW_FEATURES)
message(STATUS "SSL tests are omitted. (Configure with CROW_FEATURES containing 'ssl' to enable them)")
else()
add_test(NAME ssl_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/ssl/ssltest)
endif()

add_subdirectory(tests)
enable_testing()
add_test(NAME crow_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/unittest)
add_test(NAME template_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/template/test.py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests/template)
if(CROW_BUILD_TESTS)

add_subdirectory(tests)
enable_testing()
add_test(
NAME crow_test
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/unittest
)

if(NOT "compression" IN_LIST CROW_FEATURES)
message(STATUS "Compression tests are omitted. (Configure with CROW_FEATURES containing 'compression' to enable them)")
endif()
if(NOT "ssl" IN_LIST CROW_FEATURES)
message(STATUS "SSL tests are omitted. (Configure with CROW_FEATURES containing 'ssl' to enable them)")
else()
if(NOT MSVC)
add_test(
NAME ssl_test
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/ssl/ssltest
)
endif()
endif()
endif()

#####################################
Expand Down
8 changes: 6 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ project(crow_test)

include(${CMAKE_SOURCE_DIR}/cmake/compiler_options.cmake)

enable_testing()

set(TEST_SRCS
unittest.cpp
)
Expand All @@ -23,7 +25,9 @@ endif()
add_subdirectory(template)
add_subdirectory(multi_file)
add_subdirectory(external_definition)
if ("ssl" IN_LIST CROW_FEATURES)
add_subdirectory(ssl)
if(NOT MSVC)
if ("ssl" IN_LIST CROW_FEATURES)
add_subdirectory(ssl)
endif()
endif()
add_subdirectory(img)
23 changes: 16 additions & 7 deletions tests/template/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,21 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_link_libraries(mustachetest gcov)
endif()

file(COPY DIRECTORY . DESTINATION ${CMAKE_CURRENT_BINARY_DIR} FILES_MATCHING PATTERN "*.json")
if(NOT MSVC)
# there is a bug in the python script, it does not find the path
file(COPY DIRECTORY . DESTINATION ${CMAKE_CURRENT_BINARY_DIR} FILES_MATCHING PATTERN "*.json")

add_custom_command(OUTPUT test.py
COMMAND ${CMAKE_COMMAND} -E
copy ${PROJECT_SOURCE_DIR}/test.py ${CMAKE_CURRENT_BINARY_DIR}/test.py
DEPENDS ${PROJECT_SOURCE_DIR}/test.py
)
add_custom_command(OUTPUT test.py
COMMAND ${CMAKE_COMMAND} -E
copy ${PROJECT_SOURCE_DIR}/test.py ${CMAKE_CURRENT_BINARY_DIR}/test.py
DEPENDS ${PROJECT_SOURCE_DIR}/test.py
)

add_custom_target(template_test_copy ALL DEPENDS test.py)

add_custom_target(template_test_copy ALL DEPENDS test.py)
add_test(
NAME template_test
COMMAND python3 ${CMAKE_CURRENT_BINARY_DIR}/test.py
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif()
5 changes: 4 additions & 1 deletion tests/template/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
else:
open('partials', 'w').write("{}")

ret = subprocess.check_output("./mustachetest").decode('utf8')
if os.name == 'nt':
ret = subprocess.check_output("mustachetest.exe").decode('utf8')
else:
ret = subprocess.check_output('./mustachetest').decode('utf8')
print(testfile, test["name"])

if ret != test["expected"]:
Expand Down

0 comments on commit 37960c0

Please sign in to comment.