CMakeLists.txt revision 0bbfda8a
10bbfda8aSnia# 20bbfda8aSnia# Automated tests 30bbfda8aSnia# 40bbfda8aSnia 50bbfda8aSniaset(CTWMBIN "${CMAKE_BINARY_DIR}/ctwm") 60bbfda8aSniaadd_custom_target(test_bins) 70bbfda8aSniaadd_dependencies(test_bins ctwm) 80bbfda8aSnia 90bbfda8aSnia 100bbfda8aSnia# Add some infrastructure for building executables for unit tests 110bbfda8aSniamacro(ctwm_simple_unit_test BIN) 120bbfda8aSnia # Building and linking it 130bbfda8aSnia add_executable(${BIN} EXCLUDE_FROM_ALL "${BIN}.c") 140bbfda8aSnia target_link_libraries(${BIN} ctwmlib) 150bbfda8aSnia 160bbfda8aSnia # Few of our tests really need any of the X or other libs we pull in. 170bbfda8aSnia # However, most of the .o's for ctwm itself are going to have some 180bbfda8aSnia # ref out to them somewhere, so any tests that wind up pulling 190bbfda8aSnia # functions from those are going to make the linker want to resolve 200bbfda8aSnia # them when we link ${BIN}. So just unconditionally add them and 210bbfda8aSnia # don't worry about which tests may not actually need 'em. 220bbfda8aSnia target_link_libraries(${BIN} ${CTWMLIBS}) 230bbfda8aSnia 240bbfda8aSnia # Add to pre-test target 250bbfda8aSnia add_dependencies(test_bins ${BIN}) 260bbfda8aSnia 270bbfda8aSnia # And add the test itself 280bbfda8aSnia add_test(NAME ${BIN} 290bbfda8aSnia COMMAND $<TARGET_FILE:${BIN}> 300bbfda8aSnia ) 310bbfda8aSniaendmacro() 320bbfda8aSnia 330bbfda8aSnia 340bbfda8aSnia 350bbfda8aSnia# First a simple smoke test of the built binary 360bbfda8aSniaadd_test(NAME run-info 370bbfda8aSnia COMMAND ${CTWMBIN} --info 380bbfda8aSnia ) 390bbfda8aSniaset_tests_properties(run-info PROPERTIES 400bbfda8aSnia PASS_REGULAR_EXPRESSION "Twm version: " 410bbfda8aSnia ) 420bbfda8aSnia 430bbfda8aSnia 440bbfda8aSnia# Try parsing the system.ctwmrc 450bbfda8aSnia# Have to support skipping if no $DISPLAY is set, since we require 460bbfda8aSnia# talking to the X server to get far enough to cfgchk. Should really 470bbfda8aSnia# find a way around that, but it's a lot more involved than you'd think, 480bbfda8aSnia# so 'till then... 490bbfda8aSniaadd_test(NAME cfgchk 500bbfda8aSnia COMMAND sh -c "[ -z \"\$DISPLAY\" ] && exit 99 ; ${CTWMBIN} --cfgchk -f ${CMAKE_SOURCE_DIR}/system.ctwmrc" 510bbfda8aSnia ) 520bbfda8aSniaset_tests_properties(cfgchk PROPERTIES 530bbfda8aSnia # XXX Requires cmake 3.0... 540bbfda8aSnia SKIP_RETURN_CODE 99 550bbfda8aSnia ) 560bbfda8aSnia 570bbfda8aSnia 580bbfda8aSnia# Simple test of m4 preprocessing, but we skip if built without m4. 590bbfda8aSnia# XXX Gotta skip if no $DISPLAY here too. Fix that :( 600bbfda8aSnia# XXX This seems like the simplest way of actually "skip"'ing a test 610bbfda8aSnia# based on configure options. That's nuts. REQUIRED_FILES sounds like 620bbfda8aSnia# it would, but actually causes the test to "not run" and be considered 630bbfda8aSnia# failed :( 640bbfda8aSniaif(USE_M4) 650bbfda8aSnia set(_test_m4_cmd 660bbfda8aSnia "[ -z \"\$DISPLAY\" ] && exit 99 \\; ${CTWMBIN} --cfgchk -f ${CMAKE_CURRENT_SOURCE_DIR}/test_m4/ctwmrc" 670bbfda8aSnia ) 680bbfda8aSniaelse() 690bbfda8aSnia set(_test_m4_cmd "echo Built without m4, skipping \\; exit 99") 700bbfda8aSniaendif() 710bbfda8aSniaadd_test(NAME test_m4 720bbfda8aSnia COMMAND sh -c ${_test_m4_cmd} 730bbfda8aSnia ) 740bbfda8aSniaset_tests_properties(test_m4 PROPERTIES 750bbfda8aSnia SKIP_RETURN_CODE 99 760bbfda8aSnia ) 770bbfda8aSnia 780bbfda8aSnia 790bbfda8aSnia# A first run at a unit test 800bbfda8aSniaadd_subdirectory(util_expand) 81