summaryrefslogtreecommitdiffstats
path: root/contrib/ctest/common.ctest.inc
blob: 4fa5829e6fdbbc1223d69500b069c35724ae5658 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#
# This file gets called from the host-specific test files in hosts/. They are
# expected to set the following CTest variables:
#
# CTEST_CMAKE_GENERATOR     - the generator to use for cmake (e.g. "Unix Makefiles")
# CTEST_SITE                - the name of this build-slave
# CTEST_BUILD_CONFIGURATION - "Debug", "Release" ..
# CTEST_BUILD_NAME          - name of the particular build (e.g. "darwin-x86_64 llvm bonjour")
# CMAKE_TOOLCHAIN_FILE      - name of a toolchain file for cross-compiling
#
# CTEST_BUILD_OPTIONS       - parameters to be passed to cmake when preparing the build
#                             these will most likely come from one of the tests/*.ctest files
#
# In addition, we expect the following environment variables to be set:
#
# CTEST_SUBMIT_TYPE - "Experimental", "Nightly", "Continuous"
# USCXML_SOURCE_DIR - full path to the uscxml sources we will work with
#
# We will always build in /tmp/build-*
#

if ("$ENV{CTEST_SUBMIT_TYPE}" STREQUAL "")
	message(FATAL_ERROR "ENV{CTEST_SUBMIT_TYPE} is emtpy")
endif()

if ("$ENV{USCXML_SOURCE_DIR}" STREQUAL "")
	message(FATAL_ERROR "ENV{USCXML_SOURCE_DIR} is emtpy")
endif()

set(CTEST_SOURCE_DIRECTORY $ENV{USCXML_SOURCE_DIR})
set(CTEST_SUBMIT_TYPE $ENV{CTEST_SUBMIT_TYPE})
set(CTEST_BINARY_DIRECTORY "/tmp/build-uscxml-${CTEST_SUBMIT_TYPE}-${CTEST_SCRIPT_NAME}")

set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 1048576)
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1048576)

### Coverage and Memory checks? (untested) ################################

#set(WITH_COVERAGE TRUE)
#find_program(CTEST_COVERAGE_COMMAND NAMES gcov)

#set(WITH_MEMCHECK TRUE)
#find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind)
#set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE ${CTEST_SOURCE_DIRECTORY}/tests/valgrind.supp)

### Versioning Control ###################################################

find_program(CTEST_GIT_COMMAND NAMES git)
if(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}")
  set(CTEST_CHECKOUT_COMMAND "${CTEST_GIT_COMMAND} clone git://github.com/tklab-tud/uscxml.git ${CTEST_SOURCE_DIRECTORY}")
endif()

set(CTEST_UPDATE_COMMAND "${CTEST_GIT_COMMAND}")

### CMake Command line ###################################################

set(CTEST_CONFIGURE_COMMAND "${CMAKE_COMMAND} -LA -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION}")
set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} \"-G${CTEST_CMAKE_GENERATOR}\"")

if (CTEST_TOOLCHAIN)
	set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} -DCMAKE_TOOLCHAIN_FILE=${CTEST_TOOLCHAIN} ${CTEST_BUILD_OPTIONS}")
else()
	set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} ${CTEST_BUILD_OPTIONS}")
	#set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} -DBUILD_TESTS=ON ${CTEST_BUILD_OPTIONS}")
endif()

set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} \"${CTEST_SOURCE_DIRECTORY}\"")

#message(FATAL_ERROR "CTEST_CONFIGURE_COMMAND: ${CTEST_CONFIGURE_COMMAND}")

### Test! ################################################################

# clean build directory for everything but continuous tests
if (NOT ${CTEST_SUBMIT_TYPE} MATCHES ".*Continuous.*")
	ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
endif()

ctest_start(${CTEST_SUBMIT_TYPE}) # start testing
#
# I accidentally resynced when running from IDE thrice!
# We will rely on the run_tests.cron script to update to head
#
#ctest_update()                    # synchronize with git head

ctest_configure()                 # run cmake

if(EXISTS "${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake")
	include(${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake)
elseif(EXISTS "${CTEST_BINARY_DIRECTORY}/CTestCustom.ctest")
	include(${CTEST_BINARY_DIRECTORY}/CTestCustom.ctest)
endif()

if (CTEST_TOOLCHAIN)
#
# We do not want to build the tests everytime we compile something, but we cannot
# add a dependency to target "test" as it is unknown to CMake, instead, we introduce
# a new target "ctest" for all tests to depend upon.
#
# But when cross-compiling, we do not add any tests, that is "ctest" depends on nothing,
# in this case, build the whole library without tests.
#
	set(CTEST_BUILD_TARGET "")
else()
	set(CTEST_BUILD_TARGET "")
endif()
ctest_build()                     # build custom target that depends on all the actual tests
ctest_test()                      # run tests

if (WITH_MEMCHECK AND CTEST_COVERAGE_COMMAND)
  ctest_coverage()
endif (WITH_MEMCHECK AND CTEST_COVERAGE_COMMAND)
if (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND)
  ctest_memcheck()
endif (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND)

ctest_submit()                    # submit