summaryrefslogtreecommitdiffstats
path: root/tests/CMakeLists.txt
blob: 4cacd140a97a5e317f8d01ce70db64254fe36b72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
if(CMAKE_VERSION VERSION_LESS 2.8)
    message("CMake version greater than 2.8 necessary to run tests")
else()
    if(NOT CTEST_TESTING_TIMEOUT)
        set(CTEST_TESTING_TIMEOUT 60)
    endif()

   if(WIN32)
        set(TEST_PYTHONPATH     "${CMAKE_BINARY_DIR};${CMAKE_SOURCE_DIR}/tests/util")
        set(TEST_LIBRARY_PATH   "${libpyside_BINARY_DIR};$ENV{PATH}")
        set(LIBRARY_PATH_VAR    "PATH")
        string(REPLACE "\\" "/" TEST_PYTHONPATH "${TEST_PYTHONPATH}")
        string(REPLACE "\\" "/" TEST_LIBRARY_PATH "${TEST_LIBRARY_PATH}")

        string(REPLACE ";" "\\;" TEST_PYTHONPATH "${TEST_PYTHONPATH}")
        string(REPLACE ";" "\\;" TEST_LIBRARY_PATH "${TEST_LIBRARY_PATH}")
    else()
        set(TEST_PYTHONPATH     "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util")
        set(TEST_LIBRARY_PATH   "${libpyside_BINARY_DIR}:$ENV{LD_LIBRARY_PATH}")
        set(LIBRARY_PATH_VAR    "LD_LIBRARY_PATH")
    endif()


    macro(TEST_QT_MODULE var name)
      if(NOT DISABLE_${name} AND ${var})
          add_subdirectory(${name})
      endif()
    endmacro()

    macro(PYSIDE_TEST)
        string(REGEX MATCH "/([^/]+)//?([^/]+)\\.py" foo "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}" )
        set(TEST_NAME "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
        if (${ARGC} EQUAL 1)
            set(EXPECT_TO_FAIL 0)
        elseif(${ARGC} EQUAL 2)
            set(EXPECT_TO_FAIL ${ARGV1})
        else()
            message(WARNING "Ivalid call of macro PYSIDE_TEST")
        endif()
        set(TEST_CMD ${XVFB_EXEC} ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}")
        add_test(${TEST_NAME} ${TEST_CMD})
        set_tests_properties(${TEST_NAME} PROPERTIES
                             TIMEOUT ${CTEST_TESTING_TIMEOUT}
                             WILL_FAIL ${EXPECT_TO_FAIL}
                             ENVIRONMENT "PYTHONPATH=${TEST_PYTHONPATH};${LIBRARY_PATH_VAR}=${TEST_LIBRARY_PATH}")
    endmacro()

    # Try to find QtMultimedia
    # TODO: Remove this hack when cmake support QtMultimedia module
    if (NOT QT_QTMULTIMEDIA_FOUND AND ${QTVERSION} VERSION_GREATER 4.5.9)
        find_path(QT_QTMULTIMEDIA_INCLUDE_DIR QtMultimedia
                PATHS ${QT_HEADERS_DIR}/QtMultimedia
                    ${QT_LIBRARY_DIR}/QtMultimedia.framework/Headers
                NO_DEFAULT_PATH)
        find_library(QT_QTMULTIMEDIA_LIBRARY QtMultimedia PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
        if (QT_QTMULTIMEDIA_INCLUDE_DIR AND QT_QTMULTIMEDIA_LIBRARY)
            set(QT_QTMULTIMEDIA_FOUND ON)
        endif()
    endif ()

    add_subdirectory(signals)
    TEST_QT_MODULE(QT_QTCORE_FOUND QtCore)
    TEST_QT_MODULE(QT_QTGUI_FOUND QtGui)
    TEST_QT_MODULE(QT_QTNETWORK_FOUND QtNetwork)
    TEST_QT_MODULE(QT_QTWEBKIT_FOUND QtWebKit)
    TEST_QT_MODULE(QT_QTSVG_FOUND QtSvg)
    TEST_QT_MODULE(QT_QTXML_FOUND QtXml)
    TEST_QT_MODULE(QT_QTTEST_FOUND QtTest)
    TEST_QT_MODULE(QT_QTOPENGL_FOUND QtOpenGL)
    TEST_QT_MODULE(QT_QTSQL_FOUND QtSql)
    TEST_QT_MODULE(QT_QTUITOOLS_FOUND QtUiTools)
    TEST_QT_MODULE(QT_QTHELP_FOUND QtHelp)
    TEST_QT_MODULE(QT_QTXMLPATTERNS_FOUND QtXmlPatterns)
    TEST_QT_MODULE(QT_QTMAEMO5_FOUND QtMaemo5)
    TEST_QT_MODULE(QT_QTSCRIPT_FOUND QtScript)
    TEST_QT_MODULE(QT_QTSCRIPTTOOLS_FOUND QtScriptTools)
    TEST_QT_MODULE(QT_QTMULTIMEDIA_FOUND QtMultimedia)
    TEST_QT_MODULE(QT_PHONON_FOUND phonon)
    TEST_QT_MODULE(QT_QTDECLARATIVE_FOUND QtDeclarative)
endif()