Skip to content

Commit

Permalink
First attempt to add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
casavaca committed Jan 16, 2024
1 parent b939a6e commit dd1fbb7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ jobs:
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev
# install xvfb for testing
sudo apt-get install -y xvfb
# It's nice to have cache, but it seems that it doesn't support updating yet.
# we could do "save cache" "build" "delete cache and re-upload cache"
Expand Down Expand Up @@ -132,8 +134,7 @@ jobs:
# Optional. Default is '6'
compression-level: 6

#- name: Test
# working-directory: ${{ steps.strings.outputs.build-output-dir }}
# # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest --build-config ${{ matrix.build_type }}
- name: Test
if: ${{ matrix.os == 'ubuntu-latest' && matrix.c_compiler == gcc }}
working-directory: ${{ github.workspace }}
run: ctest --build-config ${{ matrix.build_type }} --test-dir ${{ steps.strings.outputs.build-output-dir }}
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ FetchContent_MakeAvailable(cli11_proj)
# End Dependencies
################################################################################

################################################################################
# main target
################################################################################

# find all source files.
file(GLOB SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp" "${CMAKE_CURRENT_LIST_DIR}/src/*.c")

Expand Down Expand Up @@ -120,6 +124,10 @@ if (${PLATFORM} STREQUAL "Web")
target_link_options(${PROJECT_NAME} PRIVATE -sEXPORTED_FUNCTIONS=['_main','_malloc'] -sEXPORTED_RUNTIME_METHODS=ccall -sUSE_GLFW=3)
endif()

################################################################################
# copy assets
################################################################################

# copy assets and "${raygui_SOURCE_DIR}/styles" into BIN_DIR/assets.
#
# To correctly get ${BIN_DIR} is not trivial.
Expand Down Expand Up @@ -161,3 +169,12 @@ add_custom_command(TARGET ${PROJECT_NAME} PRE_LINK
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_LIST_DIR}/assets" ${BIN_DIR}/assets
COMMAND ${CMAKE_COMMAND} -E copy_directory "${raygui_SOURCE_DIR}/styles" ${BIN_DIR}/assets/styles
)

################################################################################
# test
################################################################################

# enable testing functionality
enable_testing()
add_test(NAME smoketest COMMAND xvfb-run -s "+extension GLX" ${BIN_DIR}/${PROJECT_NAME} --fps 0 --replay ${CMAKE_CURRENT_LIST_DIR}/test/test.events)
set_tests_properties(smoketest PROPERTIES TIMEOUT 30)

0 comments on commit dd1fbb7

Please sign in to comment.