Blame tests/CMakeLists.txt

ccd28b
# Copyright (C) 2013 Christian Dywan <christian@twotoasts.de>
ccd28b
ccd28b
include(ContainTest)
ccd28b
add_custom_target(check COMMAND "env" "CTEST_OUTPUT_ON_FAILURE=1" "${CMAKE_CTEST_COMMAND}")
ccd28b
ccd28b
include_directories(
ccd28b
                    "${CMAKE_SOURCE_DIR}"
ccd28b
                    "${CMAKE_SOURCE_DIR}/midori"
ccd28b
                    ${DEPS_INCLUDE_DIRS}
ccd28b
                    ${OPTS_INCLUDE_DIRS}
ccd28b
                    ${DEPS_GTK_INCLUDE_DIRS}
ccd28b
                    ${CMAKE_BINARY_DIR}
ccd28b
                    "${CMAKE_BINARY_DIR}/midori"
ccd28b
                    )
ccd28b
file(GLOB TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c *.vala)
ccd28b
foreach(UNIT_SRC ${TESTS})
ccd28b
    if (${UNIT_SRC} MATCHES "(.vala)$")
ccd28b
        string(REPLACE ".vala" "" UNIT ${UNIT_SRC})
ccd28b
        include(ValaPrecompile)
ccd28b
        vala_precompile(UNIT_SRC_C ${UNIT}
ccd28b
            ${UNIT_SRC}
ccd28b
        PACKAGES
ccd28b
            ${PKGS}
ccd28b
        OPTIONS
ccd28b
            ${VALAFLAGS}
ccd28b
        CUSTOM_VAPIS
ccd28b
            ${EXTRA_VAPIS}
ccd28b
            "${CMAKE_SOURCE_DIR}/midori/midori.vapi"
ccd28b
            "${CMAKE_BINARY_DIR}/midori/${LIBMIDORI}.vapi"
ccd28b
        )
ccd28b
ccd28b
        add_executable(${UNIT} ${UNIT_SRC_C})
ccd28b
        set_target_properties(${UNIT} PROPERTIES
ccd28b
                              COMPILE_FLAGS "${VALA_CFLAGS}"
ccd28b
                              )
ccd28b
    else()
ccd28b
        string(REPLACE ".c" "" UNIT ${UNIT_SRC})
ccd28b
        add_executable(${UNIT} ${UNIT_SRC})
ccd28b
        set_target_properties(${UNIT} PROPERTIES
ccd28b
                              COMPILE_FLAGS ${CFLAGS}
ccd28b
                              )
ccd28b
    endif()
ccd28b
ccd28b
    target_link_libraries(${UNIT}
ccd28b
                          ${LIBMIDORI}
ccd28b
                          )
ccd28b
    add_test(NAME ${UNIT} COMMAND ${UNIT})
ccd28b
    contain_test (${UNIT} ${UNIT})
ccd28b
endforeach ()
ccd28b
ccd28b
file(GLOB TESTS ${CMAKE_BINARY_DIR}/extensions/lib*.so)
ccd28b
foreach(UNIT ${TESTS})
ccd28b
    string(REPLACE ${CMAKE_BINARY_DIR} "" TEST ${UNIT})
ccd28b
    string(REPLACE "/" "-" TEST ${TEST})
ccd28b
    string(REPLACE "-extensions-lib" "" TEST ${TEST})
ccd28b
    string(REPLACE ".so" "" TEST ${TEST})
ccd28b
    add_test(NAME ${TEST} COMMAND $<TARGET_FILE:extensions> -e ${UNIT})
ccd28b
    set(exe $<TARGET_FILE:extensions> -e ${UNIT})
ccd28b
    contain_test (${TEST} "${exe}")
ccd28b
endforeach()
ccd28b
ccd28b
file(GLOB TESTS *.sh)
ccd28b
foreach(UNIT_SRC ${TESTS})
ccd28b
    string(REPLACE ".sh" "" UNIT ${UNIT_SRC})
ccd28b
    add_test(NAME ${UNIT} COMMAND ${UNIT_SRC})
ccd28b
    file(RELATIVE_PATH BLDDIR ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
ccd28b
    set_tests_properties(${UNIT} PROPERTIES
ccd28b
                         ENVIRONMENT "SRCDIR=${CMAKE_SOURCE_DIR};BLDDIR=${BLDDIR};"
ccd28b
                         )
ccd28b
endforeach ()