forked from doctest/doctest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
396 lines (331 loc) · 17.5 KB
/
.travis.yml
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# this file is HEAVILY influenced by https://github.com/boostorg/hana/blob/master/.travis.yml
dist: trusty
language: c++
notifications:
email: false
# gitter
webhooks:
urls: https://webhooks.gitter.im/e/10941dd1c67e5e967706
on_success: change
on_failure: always
git:
depth: 500
# both apt and ccache make the builds slower...
#cache:
# - apt
# - ccache
env:
global:
# - USE_CCACHE=1
# - CCACHE_SLOPPINESS=pch_defines,time_macros
# - CCACHE_COMPRESS=1
# - CCACHE_MAXSIZE=200M
# - CCACHE_CPP2=1
- CMAKE_OPTIONS_GLOBAL="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
addons:
coverity_scan:
# COVERITY_SCAN_TOKEN added as env var in travis project
project:
name: onqtam/doctest
notification_email: [email protected]
build_command: clang++ scripts/hello_world.cpp -I doctest
branch_pattern: coverity_scan
# these apt sources will be referenced later (by using *name)
apt:
sources: &apt_sources
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty
- llvm-toolchain-precise-3.7
- llvm-toolchain-trusty-3.9
- llvm-toolchain-trusty-4.0
- llvm-toolchain-trusty-5.0
- llvm-toolchain-trusty-6.0
- llvm-toolchain-trusty-7
- llvm-toolchain-trusty-8
compiler: clang
os: linux
matrix:
include:
# coverage
- env: COMPILER=g++ CODE_COVERAGE=true
compiler: gcc
addons:
apt:
packages: ["lcov"]
# static code analysis
- env: COMPILER=clang++-4.0 STATIC_CODE_ANALYSIS=true
addons: &static_analysis
apt:
packages: ["clang-4.0", "clang-tidy-4.0", "cppcheck"]
sources: *apt_sources
# GCC 4.8
- env: COMPILER=g++-4.8 HAS_ASAN=true SANITIZER_CXX_FLAGS="-fuse-ld=gold" TSAN_CXX_FLAGS="-ltsan" # TSAN broken for some time - seg faults
compiler: gcc
addons: &gcc48
apt:
packages: ["g++-4.8", "valgrind", "libc6-dbg", "linux-libc-dev"]
sources: *apt_sources
# GCC 4.9
- env: COMPILER=g++-4.9 HAS_ASAN=true HAS_UBSAN=true SANITIZER_CXX_FLAGS="-fuse-ld=gold" TSAN_CXX_FLAGS="-ltsan" # TSAN broken for some time - seg faults
compiler: gcc
addons: &gcc49
apt:
packages: ["g++-4.9", "valgrind", "libc6-dbg", "linux-libc-dev"]
sources: *apt_sources
# GCC 5
- env: COMPILER=g++-5 HAS_ASAN=true HAS_UBSAN=true SANITIZER_CXX_FLAGS="-fuse-ld=gold" TSAN_CXX_FLAGS="-ltsan" # TSAN broken for some time - seg faults
compiler: gcc
addons: &gcc5
apt:
packages: ["g++-5", "valgrind", "libc6-dbg", "linux-libc-dev"]
sources: *apt_sources
# GCC 6
- env: COMPILER=g++-6 HAS_ASAN=true HAS_UBSAN=true SANITIZER_CXX_FLAGS="-fuse-ld=gold" TSAN_CXX_FLAGS="-ltsan" # TSAN broken for some time - seg faults
compiler: gcc
addons: &gcc6
apt:
packages: ["g++-6", "valgrind", "libc6-dbg", "linux-libc-dev"]
sources: *apt_sources
# GCC 7
- env: COMPILER=g++-7 HAS_ASAN=true HAS_UBSAN=true SANITIZER_CXX_FLAGS="-fuse-ld=gold" TSAN_CXX_FLAGS="-ltsan" # TSAN broken for some time - seg faults
compiler: gcc
sudo: required # see this issue for more details: https://github.com/travis-ci/travis-ci/issues/9033
addons: &gcc7
apt:
packages: ["g++-7", "valgrind", "libc6-dbg", "linux-libc-dev"]
sources: *apt_sources
# GCC 8
- env: COMPILER=g++-8 HAS_ASAN=true HAS_UBSAN=true HAS_TSAN=true SANITIZER_CXX_FLAGS="-fuse-ld=gold" TSAN_CXX_FLAGS="-ltsan"
compiler: gcc
sudo: required # see this issue for more details: https://github.com/travis-ci/travis-ci/issues/9033
addons: &gcc8
apt:
packages: ["g++-8", "valgrind", "libc6-dbg", "linux-libc-dev"]
sources: *apt_sources
# GCC 9
- env: COMPILER=g++-9 HAS_ASAN=true HAS_UBSAN=true HAS_TSAN=true SANITIZER_CXX_FLAGS="-fuse-ld=gold" TSAN_CXX_FLAGS="-ltsan"
compiler: gcc
sudo: required # see this issue for more details: https://github.com/travis-ci/travis-ci/issues/9033
addons: &gcc9
apt:
packages: ["g++-9", "valgrind", "libc6-dbg", "linux-libc-dev"]
sources: *apt_sources
# Clang 3.5
- env: COMPILER=clang++-3.5 HAS_ASAN=true HAS_UBSAN=true # no HAS_TSAN - see errors: https://travis-ci.org/onqtam/doctest/builds/417926743
addons: &clang35
apt:
packages: ["clang-3.5", "valgrind", "libc6-dbg", "g++-6"]
sources: *apt_sources
# Clang 3.6
- env: COMPILER=clang++-3.6 HAS_ASAN=true HAS_UBSAN=true # no HAS_TSAN - see errors: https://travis-ci.org/onqtam/doctest/builds/417926743
addons: &clang36
apt:
packages: ["clang-3.6", "valgrind", "libc6-dbg", "g++-6"]
sources: *apt_sources
# Clang 3.7
- env: COMPILER=clang++-3.7
addons: &clang37
apt:
packages: ["clang-3.7", "valgrind", "libc6-dbg", "g++-6"]
sources: *apt_sources
# Clang 3.8
- env: COMPILER=clang++-3.8 HAS_ASAN=true HAS_UBSAN=true # no HAS_TSAN - see errors: https://travis-ci.org/onqtam/doctest/builds/417926743
addons: &clang38
apt:
packages: ["clang-3.8", "valgrind", "libc6-dbg", "g++-6"]
sources: *apt_sources
# Clang 3.9
- env: COMPILER=clang++-3.9 # no HAS_ASAN/HAS_UBSAN - see errors: https://travis-ci.org/onqtam/doctest/jobs/386263910
addons: &clang39
apt:
packages: ["clang-3.9", "valgrind", "libc6-dbg", "g++-6"]
sources: *apt_sources
# Clang 4.0
- env: COMPILER=clang++-4.0 HAS_ASAN=true HAS_UBSAN=true HAS_TSAN=true
sudo: required # see this issue for more details: https://github.com/travis-ci/travis-ci/issues/9033
addons: &clang40
apt:
packages: ["clang-4.0", "valgrind", "libc6-dbg", "g++-6"]
sources: *apt_sources
# Clang 5.0
- env: COMPILER=clang++-5.0 HAS_ASAN=true HAS_UBSAN=true HAS_TSAN=true
sudo: required # see this issue for more details: https://github.com/travis-ci/travis-ci/issues/9033
addons: &clang50
apt:
packages: ["clang-5.0", "valgrind", "libc6-dbg", "g++-6"]
sources: *apt_sources
# Clang 6.0
- env: COMPILER=clang++-6.0 HAS_ASAN=true HAS_UBSAN=true HAS_TSAN=true
sudo: required # see this issue for more details: https://github.com/travis-ci/travis-ci/issues/9033
addons: &clang60
apt:
packages: ["clang-6.0", "valgrind", "libc6-dbg", "g++-6"]
sources: *apt_sources
# Clang 7
- env: COMPILER=clang++-7 HAS_ASAN=true HAS_UBSAN=true HAS_TSAN=true
sudo: required # see this issue for more details: https://github.com/travis-ci/travis-ci/issues/9033
addons: &clang7
apt:
packages: ["clang-7", "valgrind", "libc6-dbg", "g++-6"]
sources: *apt_sources
# Clang 8
- env: COMPILER=clang++-8 HAS_ASAN=true HAS_UBSAN=true HAS_TSAN=true
sudo: required # see this issue for more details: https://github.com/travis-ci/travis-ci/issues/9033
addons: &clang8
apt:
packages: ["clang-8", "valgrind", "libc6-dbg", "g++-6"]
sources: *apt_sources
# Xcode 6.4 Clang
- env: COMPILER=clang++ CMAKE_OPTIONS="-DDOCTEST_THREAD_LOCAL="
osx_image: xcode6.4
os: osx
# Xcode 7.3 Clang
- env: COMPILER=clang++ HAS_ASAN=true CMAKE_OPTIONS="-DDOCTEST_THREAD_LOCAL="
osx_image: xcode7.3
os: osx
# Xcode 8 Clang
- env: COMPILER=clang++ HAS_TSAN=true # no HAS_ASAN - errors since using thread_local even in single-threaded cases - see errors: https://travis-ci.org/onqtam/doctest/builds/417181981
osx_image: xcode8
os: osx
# Xcode 8.3 Clang
- env: COMPILER=clang++ HAS_UBSAN=true HAS_TSAN=true # no HAS_ASAN - errors since using thread_local even in single-threaded cases - see errors: https://travis-ci.org/onqtam/doctest/builds/417181981
osx_image: xcode8.3
os: osx
# Xcode 9.2 Clang
- env: COMPILER=clang++ HAS_UBSAN=true HAS_TSAN=true # no HAS_ASAN - errors since using thread_local even in single-threaded cases - see errors: https://travis-ci.org/onqtam/doctest/builds/417181981
osx_image: xcode9.2
os: osx
# Xcode 9.4 Clang
- env: COMPILER=clang++ HAS_UBSAN=true HAS_TSAN=true # no HAS_ASAN - errors since using thread_local even in single-threaded cases - see errors: https://travis-ci.org/onqtam/doctest/builds/417181981
osx_image: xcode9.4
os: osx
# Xcode 10.0 Clang
- env: COMPILER=clang++ HAS_ASAN=true HAS_UBSAN=true HAS_TSAN=true
osx_image: xcode10
os: osx
# Xcode 10.2 Clang
- env: COMPILER=clang++ HAS_ASAN=true HAS_UBSAN=true HAS_TSAN=true
osx_image: xcode10.2
os: osx
# OSX LLVM-GCC
- env: COMPILER=g++ HAS_ASAN=true HAS_TSAN=true
compiler: gcc
osx_image: xcode10
os: osx
allow_failures:
# static code analysis
- env: COMPILER=clang++-4.0 STATIC_CODE_ANALYSIS=true
install:
- if [[ "${CODE_COVERAGE}" == "true" ]]; then gem install coveralls-lcov ; fi
############################################################################
# All the dependencies are installed in ${TRAVIS_BUILD_DIR}/deps/
############################################################################
# Make a dir for all
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
# Install a recent CMake
- |
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
CMAKE_URL="http://www.cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.tar.gz"
mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
fi
# Install OCLint
- |
if [[ "${STATIC_CODE_ANALYSIS}" = "true" ]]; then
OCLINT_URL="https://github.com/oclint/oclint/releases/download/v0.12/oclint-0.12-x86_64-linux-3.13.0-112-generic.tar.gz"
mkdir oclint && travis_retry wget --no-check-certificate --quiet -O - ${OCLINT_URL} | tar --strip-components=1 -xz -C oclint
export PATH=${DEPS_DIR}/oclint/bin:${PATH}
fi
# Go back to ${TRAVIS_BUILD_DIR}
- cd ${TRAVIS_BUILD_DIR}
############################################################################
# Install stuff with homebrew under OSX
############################################################################
- |
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
brew update
# brew install ccache
# brew install valgrind
# cmake
if brew list -1 | grep -q "^cmake\$"; then
brew outdated cmake || brew upgrade cmake
else
brew install cmake
fi
fi
- export CXX="${COMPILER}"
# - export CXX="ccache ${COMPILER}"
# - ccache -s
before_script:
- ${CXX} --version
script:
# coverage
- |
if [[ "${CODE_COVERAGE}" = "true" ]]; then
cmake ${CMAKE_OPTIONS_GLOBAL} ${CMAKE_OPTIONS} -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage -std=c++0x" -DCMAKE_BUILD_TYPE=Debug . || exit 1
make -k -j2 || exit 1
ctest -j2 --output-on-failure || exit 1
lcov -d . -c -o coverage.info # parse coverage data
lcov -r coverage.info "/usr*" -o coverage.info # remove data for system headers
lcov -r coverage.info "$(readlink -f examples)/*" -o coverage.info # remove data for .cpp files
lcov -r coverage.info "$(readlink -f scripts)/*" -o coverage.info # remove data for .cpp files
lcov -l coverage.info # just list a short summary of the results
coveralls-lcov --repo-token=${COVERALLS_REPO_TOKEN} coverage.info # upload results
# do not continue with other build configurations after that
exit
fi
# static code analysis
- |
if [[ "${STATIC_CODE_ANALYSIS}" = "true" ]]; then
# setup a test file "doctest.cpp" that is the header + a test case at the end
echo "#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN\n" >> doctest.cpp
cat doctest/doctest.h >> doctest.cpp
echo -e "TEST_CASE(\"\") {\n\tint a = 6;\n\tSUBCASE(\"\") a = 5;\n\tCAPTURE(a);\n\tCHECK(a == 6);\n}\n" >> doctest.cpp
# cppcheck
cppcheck doctest.cpp --enable=all --suppress=unmatchedSuppression --suppress=missingIncludeSystem --suppress=unusedFunction --suppress=functionConst --inline-suppr --platform=unix64 --inconclusive --std=posix --inconclusive -v --error-exitcode=1 --template "{file}({line}): {severity} ({id}): {message}"
# oclint
oclint doctest.cpp -disable-rule=ShortVariableName -disable-rule=LongLine -disable-rule=LongMethod -disable-rule=HighNcssMethod -disable-rule=LongVariableName -disable-rule=HighCyclomaticComplexity -disable-rule=HighNPathComplexity -disable-rule=UnusedLocalVariable -disable-rule=DoubleNegative -disable-rule=MultipleUnaryOperator -disable-rule=DeepNestedBlock || exit 1
# clang-tidy
cd scripts/playground
cmake ${CMAKE_OPTIONS_GLOBAL} ${CMAKE_OPTIONS} -DCMAKE_CXX_COMPILER=${CXX} . || exit 1
clang-tidy-4.0 -std=c++11 -p=. *.cpp -header-filter=.* -warnings-as-errors=* -checks='*,-misc-misplaced-widening-cast,-misc-macro-parentheses,-misc-definitions-in-headers,-misc-unused-parameters,-llvm-header-guard,-llvm-include-order,-google-readability-braces-around-statements,-google-runtime-references,-google-readability-todo,-google-build-using-namespace,-google-explicit-constructor,-cert-err58-cpp,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-special-member-functions,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-union-access,-clang-analyzer-security.insecureAPI.strcpy,-modernize-loop-convert,-modernize-use-auto,-modernize-use-bool-literals,-readability-braces-around-statements,-readability-named-parameter,-readability-else-after-return,-readability-redundant-declaration,-readability-implicit-bool-cast,-clang-diagnostic-variadic-macros,-clang-diagnostic-c++11-compat' || exit 1
# do not continue with other build configurations after that
exit
fi
# initial run with options
- cmake ${CMAKE_OPTIONS_GLOBAL} ${CMAKE_OPTIONS} -DCMAKE_CXX_COMPILER=${CXX} .
# set the common CXX flags
- export CXX_FLAGS="${CXX_FLAGS} -std=c++0x"
# debug
- cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" .
- make clean && make -k -j2
- if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then cmake -DDOCTEST_TEST_MODE=VALGRIND . && ctest -j2 --output-on-failure ; fi
- cmake -DDOCTEST_TEST_MODE=COMPARE . && ctest -j2 --output-on-failure
# release
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" .
- make clean && make -k -j2
- if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then cmake -DDOCTEST_TEST_MODE=VALGRIND . && ctest -j2 --output-on-failure ; fi
- cmake -DDOCTEST_TEST_MODE=COMPARE . && ctest -j2 --output-on-failure
# sanitizers - again Debug/Release configs through address/undefined/thread sanitizers
# on separate commands because when something fails I want to see which one exactly
- cmake -DDOCTEST_TEST_MODE=NORMAL .
- export ASAN_OPTIONS=verbosity=2:strict_string_checks=true:detect_odr_violation=2:detect_stack_use_after_return=true:check_initialization_order=true:strict_init_order=true
- if [[ "${HAS_ASAN}" = "true" ]]; then cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="${CXX_FLAGS} ${SANITIZER_CXX_FLAGS} -g -fno-omit-frame-pointer -fsanitize=address" . && make clean && make -k -j2 && ctest -j2 --output-on-failure ; fi
- if [[ "${HAS_ASAN}" = "true" ]]; then cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="${CXX_FLAGS} ${SANITIZER_CXX_FLAGS} -g -fno-omit-frame-pointer -fsanitize=address" . && make clean && make -k -j2 && ctest -j2 --output-on-failure ; fi
- export UBSAN_OPTIONS=verbosity=2
- if [[ "${HAS_UBSAN}" = "true" ]]; then cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="${CXX_FLAGS} ${SANITIZER_CXX_FLAGS} -g -fno-omit-frame-pointer -fsanitize=undefined" . && make clean && make -k -j2 && ctest -j2 --output-on-failure ; fi
- if [[ "${HAS_UBSAN}" = "true" ]]; then cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="${CXX_FLAGS} ${SANITIZER_CXX_FLAGS} -g -fno-omit-frame-pointer -fsanitize=undefined" . && make clean && make -k -j2 && ctest -j2 --output-on-failure ; fi
- export TSAN_OPTIONS=verbosity=2:force_seq_cst_atomics=1
- if [[ "${HAS_TSAN}" = "true" ]]; then cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="${CXX_FLAGS} ${SANITIZER_CXX_FLAGS} -g -fno-omit-frame-pointer -fsanitize=thread -pie -fPIE ${TSAN_CXX_FLAGS}" . && make clean && make -k -j2 && ctest -j2 --output-on-failure ; fi
- if [[ "${HAS_TSAN}" = "true" ]]; then cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="${CXX_FLAGS} ${SANITIZER_CXX_FLAGS} -g -fno-omit-frame-pointer -fsanitize=thread -pie -fPIE ${TSAN_CXX_FLAGS}" . && make clean && make -k -j2 && ctest -j2 --output-on-failure ; fi
# test without rtti - just Debug
- cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="${CXX_FLAGS} -fno-rtti" .
- make clean && make -k -j2
- cmake -DDOCTEST_TEST_MODE=COMPARE . && ctest -j2 --output-on-failure
# test only compilation without exceptions - just Debug
- cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="${CXX_FLAGS} -fno-exceptions -DDOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS" .
- make clean && make -k -j2
# - ccache -s
#after_script:
# - cat compile_commands.json