Skip to content

Commit

Permalink
add self test
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Mar 22, 2024
1 parent 70e5852 commit c43315c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ jobs:
- name: CMake build examples
run: cmake --build demos/build

- name: Run tests
run: ctest --test-dir demos/build

- name: Create package
if: github.event.action == 'published'
run: cpack --config build/CPackConfig.cmake
Expand Down Expand Up @@ -122,7 +125,7 @@ jobs:
with:
version: "2.0"

- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Configure
run: cmake -Bbuild --toolchain cmake/dos.cmake
Expand Down
8 changes: 8 additions & 0 deletions cmake/test_run.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if(NOT EXISTS "${in}")
message(FATAL_ERROR "Input file ${in} does not exist")
endif()

execute_process(COMMAND "${exe}"
#INPUT_FILE "${in}"
COMMAND_ERROR_IS_FATAL ANY
)
18 changes: 17 additions & 1 deletion demos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ endif()

project(PDcursesDemos LANGUAGES C)

enable_testing()

find_package(PDCurses CONFIG REQUIRED)

foreach(f IN ITEMS testcurs ozdemo xmas firework ptest rain worm)
Expand All @@ -17,5 +19,19 @@ endforeach()
add_executable(tuidemo tui.c tuidemo.c)
target_link_libraries(tuidemo PRIVATE CURSES::CURSES)

# --- auto-ignore build directory
file(GENERATE OUTPUT .gitignore CONTENT "*")

set(CI $ENV{CI})

file(GENERATE OUTPUT q.txt CONTENT "q")

foreach(t IN ITEMS rain ptest)

add_test(NAME ${t}
COMMAND ${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:${t}> -Din=${CMAKE_CURRENT_BINARY_DIR}/q.txt
-P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/test_run.cmake)

set_property(TEST ${t} PROPERTY DISABLED $<OR:$<BOOL:${WIN32}>,${CI}>)
set_property(TEST ${t} PROPERTY TIMEOUT 7)

endforeach()

0 comments on commit c43315c

Please sign in to comment.