Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c43315c

Browse files
committedMar 22, 2024
add self test
1 parent 70e5852 commit c43315c

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed
 

‎.github/workflows/ci.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ jobs:
6767
- name: CMake build examples
6868
run: cmake --build demos/build
6969

70+
- name: Run tests
71+
run: ctest --test-dir demos/build
72+
7073
- name: Create package
7174
if: github.event.action == 'published'
7275
run: cpack --config build/CPackConfig.cmake
@@ -122,7 +125,7 @@ jobs:
122125
with:
123126
version: "2.0"
124127

125-
- uses: actions/checkout@v2
128+
- uses: actions/checkout@v4
126129

127130
- name: Configure
128131
run: cmake -Bbuild --toolchain cmake/dos.cmake

‎cmake/test_run.cmake

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
if(NOT EXISTS "${in}")
2+
message(FATAL_ERROR "Input file ${in} does not exist")
3+
endif()
4+
5+
execute_process(COMMAND "${exe}"
6+
#INPUT_FILE "${in}"
7+
COMMAND_ERROR_IS_FATAL ANY
8+
)

‎demos/CMakeLists.txt

+17-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ endif()
77

88
project(PDcursesDemos LANGUAGES C)
99

10+
enable_testing()
11+
1012
find_package(PDCurses CONFIG REQUIRED)
1113

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

20-
# --- auto-ignore build directory
2122
file(GENERATE OUTPUT .gitignore CONTENT "*")
23+
24+
set(CI $ENV{CI})
25+
26+
file(GENERATE OUTPUT q.txt CONTENT "q")
27+
28+
foreach(t IN ITEMS rain ptest)
29+
30+
add_test(NAME ${t}
31+
COMMAND ${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:${t}> -Din=${CMAKE_CURRENT_BINARY_DIR}/q.txt
32+
-P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/test_run.cmake)
33+
34+
set_property(TEST ${t} PROPERTY DISABLED $<OR:$<BOOL:${WIN32}>,${CI}>)
35+
set_property(TEST ${t} PROPERTY TIMEOUT 7)
36+
37+
endforeach()

0 commit comments

Comments
 (0)
Please sign in to comment.