-
Notifications
You must be signed in to change notification settings - Fork 43
/
devtools_test.cmake
173 lines (127 loc) · 4 KB
/
devtools_test.cmake
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#
# Include CTest Ext module
#
include("${CMAKE_CURRENT_LIST_DIR}/3rdparty/ctest-ext/ctest_ext.cmake")
#
# Check Pull Request Title
#
if(DEFINED ENV{TRAVIS_PULL_REQUEST})
set(PULL_REQUEST_ID "$ENV{TRAVIS_PULL_REQUEST}")
find_program(CURL_EXECUTABLE NAMES curl)
if(CURL_EXECUTABLE)
execute_process(
COMMAND "${CURL_EXECUTABLE}" "https://api.github.com/repos/UNN-VMK-Software/devtools-course-practice/pulls/${PULL_REQUEST_ID}"
OUTPUT_VARIABLE pr_info
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(pr_info MATCHES "\\\"title\\\": \\\"([^\r\n]*)\\\",\n")
set(PULL_REQUEST_TITLE "${CMAKE_MATCH_1}")
endif()
endif()
endif()
if(DEFINED ENV{APPVEYOR_PULL_REQUEST_NUMBER})
set(PULL_REQUEST_ID "$ENV{APPVEYOR_PULL_REQUEST_NUMBER}")
set(PULL_REQUEST_TITLE "$ENV{APPVEYOR_PULL_REQUEST_TITLE}")
endif()
if(PULL_REQUEST_TITLE)
ctext_ext_log_stage("Check pull request title")
if(PULL_REQUEST_TITLE MATCHES ".* - Лабораторная работа #[0-9].*")
message("${CTEST_EXT_TEXT_STYLE_BOLD_GREEN}SUCCESS: Valid title of the pull request: ${PULL_REQUEST_TITLE}${CTEST_EXT_TEXT_STYLE_RESET}")
else()
message("${CTEST_EXT_TEXT_STYLE_BOLD_RED}FAILURE: Invalid title of the pull request: ${PULL_REQUEST_TITLE}${CTEST_EXT_TEXT_STYLE_RESET}")
message("${CTEST_EXT_TEXT_STYLE_BOLD_RED}Should be something like: Корняков - Лабораторная работа #1${CTEST_EXT_TEXT_STYLE_RESET}")
endif()
endif()
#
# Initialize testing
#
set_ifndef(CTEST_PROJECT_NAME "devtools-course-practice")
set_ifndef(CTEST_DASHBOARD_ROOT "${CMAKE_CURRENT_LIST_DIR}/dashboard")
set_ifndef(CTEST_SOURCE_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}")
ctest_ext_init()
if(PULL_REQUEST_ID)
set(CTEST_BUILD_NAME "${CTEST_BUILD_NAME}-PR#${PULL_REQUEST_ID}")
endif()
#
# Check supported targets and models
#
check_if_matches(CTEST_MODEL "^Experimental$" "^Nightly$" "^Coverage$" "^MemCheck$" "^CodeCheck$")
#
# Configure the testing model (set options, not specified by user, to default values)
#
if(CTEST_MODEL STREQUAL "Nightly")
if(CTEST_COVERAGE_COMMAND)
set_ifndef(CTEST_WITH_COVERAGE TRUE)
set_ifndef(CTEST_COVERAGE_TOOL "CDASH")
endif()
if(CTEST_MEMORYCHECK_COMMAND)
set_ifndef(CTEST_WITH_DYNAMIC_ANALYSIS TRUE)
set_ifndef(CTEST_DYNAMIC_ANALYSIS_TOOL "CDASH")
endif()
set_ifndef(CTEST_WITH_SUBMIT TRUE)
endif()
if(CTEST_MODEL STREQUAL "Coverage")
check_vars_exist(CTEST_COVERAGE_COMMAND)
set(CTEST_WITH_COVERAGE TRUE)
set(CTEST_COVERAGE_TOOL "CDASH")
set_ifndef(CTEST_WITH_SUBMIT TRUE)
endif()
if(CTEST_MODEL STREQUAL "MemCheck")
check_vars_exist(CTEST_MEMORYCHECK_COMMAND)
set(CTEST_WITH_TESTS FALSE)
set(CTEST_WITH_DYNAMIC_ANALYSIS TRUE)
set(CTEST_DYNAMIC_ANALYSIS_TOOL "CDASH")
set_ifndef(CTEST_WITH_SUBMIT TRUE)
endif()
if(CTEST_MODEL STREQUAL "CodeCheck")
set(CTEST_WITH_TESTS FALSE)
endif()
#
# Configure cmake options
#
if(CTEST_TARGET_SYSTEM MATCHES "^Windows")
if(CTEST_TARGET_SYSTEM MATCHES "64")
set_ifndef(CTEST_CMAKE_GENERATOR "Visual Studio 14 Win64")
else()
set_ifndef(CTEST_CMAKE_GENERATOR "Visual Studio 14")
endif()
else()
set_ifndef(CTEST_CMAKE_GENERATOR "Unix Makefiles")
endif()
set_ifndef(CTEST_CONFIGURATION_TYPE "Debug")
if(CTEST_WITH_COVERAGE)
add_cmake_cache_entry("COVERAGE" TYPE "BOOL" "ON")
endif()
#
# Start testing
#
ctest_ext_start()
#
# Configure
#
ctest_ext_configure()
#
# Build
#
if(CTEST_MODEL STREQUAL "CodeCheck")
ctest_ext_build(TARGETS "cpplint" "cppcheck")
else()
ctest_ext_build()
endif()
#
# Test
#
ctest_ext_test()
#
# Coverage
#
ctest_ext_coverage(
CDASH
LABELS "Library;Application")
#
# MemCheck
#
ctest_ext_dynamic_analysis()
#
# Submit
#
ctest_ext_submit()