Skip to content

Commit

Permalink
fix(test): allow to run test locally on mac
Browse files Browse the repository at this point in the history
Make libinput and xbkcommon optional in test because they are not available on mac.
Add custom target 'run' to make it easier to run all tests.

Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
  • Loading branch information
XuNeo committed Feb 20, 2024
1 parent f5f19ca commit f1f5590
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
26 changes: 23 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,21 @@ find_package(Freetype REQUIRED)
include_directories(${FREETYPE_INCLUDE_DIRS})

# libinput is required for the libinput device driver test case
find_package(Libinput REQUIRED)
find_package(Libinput OPTIONAL_COMPONENTS)
include_directories(${LIBINPUT_INCLUDE_DIRS})

# libxkbcommon is required for the libinput device driver test case
if (NOT LIBINPUT_FOUND)
message("libinput is not found, defaulting to 0")
add_definitions(-DLV_USE_LIBINPUT=0)
endif()

find_package(PkgConfig)
pkg_check_modules(xkbcommon REQUIRED xkbcommon)
pkg_check_modules(xkbcommon pkg_check_modules xkbcommon)

if (NOT xkbcommon_FOUND)
message("xkbcommon is not found, defaulting to 0")
add_definitions(-DLV_LIBINPUT_XKB=0)
endif()

# disable test targets for build only tests
if (ENABLE_TESTS)
Expand All @@ -274,6 +283,10 @@ foreach( test_case_fname ${TEST_CASE_FILES} )
if (${test_name} STREQUAL "_test_template")
continue()
endif()

# gather all test cases
list(APPEND TEST_CASES ${test_name})

# Create path to auto-generated source file.
set(test_runner_fname ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_Runner.c)
# Run ruby to generate source in build directory
Expand Down Expand Up @@ -309,4 +322,11 @@ foreach( test_case_fname ${TEST_CASE_FILES} )
COMMAND ${test_name})
endforeach( test_case_fname ${TEST_CASE_FILES} )

add_custom_target(run
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --timeout 300
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
DEPENDS ${TEST_CASES}
USES_TERMINAL
)

endif()
10 changes: 8 additions & 2 deletions tests/src/lv_test_conf_full.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,14 @@
#define LV_USE_ST7735 1
#define LV_USE_ST7789 1
#define LV_USE_ST7796 1
#define LV_USE_LIBINPUT 1
#define LV_LIBINPUT_XKB 1

#ifndef LV_USE_LIBINPUT
#define LV_USE_LIBINPUT 1
#endif

#ifndef LV_LIBINPUT_XKB
#define LV_LIBINPUT_XKB 1
#endif

#define LV_USE_FREETYPE 1
#define LV_FREETYPE_CACHE_SIZE 768
Expand Down

0 comments on commit f1f5590

Please sign in to comment.