Skip to content

Commit 44360e9

Browse files
authored
Add YWIU checks to travis (etr#208)
Adds the YWIU checks to travis. Fixed the include statements to pass the tests. Forces code to be tested on appveyor too (in order to have this tested) - more generally this is useful because apparent travis-only change might affect windows too (like in this case).
1 parent b7a7245 commit 44360e9

25 files changed

+165
-97
lines changed

.travis.yml

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,28 @@ env:
1111
- LINKING="static"
1212
before_install:
1313
- eval "${MATRIX_EVAL}"
14+
# Installing iwyu manually because clang and iwyu paths won't match on Ubuntu otherwise.
15+
- if [ "$IWYU" = "iwyu" ]; then
16+
CLANG_VERSION=`clang --version | grep version | cut -f3 -d' ' | cut -f1 -d'-'` ;
17+
CLANG_PKG_VERSION=`echo $CLANG_VERSION | cut -f1,2 -d'.'`
18+
CLANG_PREFIX_PATH="/usr/local/clang-${CLANG_VERSION}/lib/clang/${CLANG_VERSION}" ;
19+
CLANG_BIN_PATH="/usr/local/clang-${CLANG_VERSION}/bin" ;
20+
git clone https://github.com/include-what-you-use/include-what-you-use.git ;
21+
cd include-what-you-use ;
22+
echo "$CLANG_PKG_VERSION" | grep '\.[0-9]$' ;
23+
if [ $? -eq 0 ]; then
24+
git checkout clang_${CLANG_PKG_VERSION} ;
25+
else
26+
git checkout clang_${CLANG_PKG_VERSION}.0 ;
27+
fi;
28+
cd .. ;
29+
mkdir build_iwyu ;
30+
cd build_iwyu ;
31+
cmake -G "Unix Makefiles" -DCMAKE_PREFIX_PATH=$CLANG_PREFIX_PATH -DCMAKE_C_COMPILER=$CLANG_BIN_PATH/clang -DCMAKE_CXX_COMPILER=$CLANG_BIN_PATH/clang++ ../include-what-you-use ;
32+
make ;
33+
sudo make install ;
34+
cd .. ;
35+
fi
1436
- export LDFLAGS="$LDFLAGS -L/usr/local/lib -L/usr/lib"
1537
- export PATH=$PATH:/usr/local/lib
1638
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
@@ -37,21 +59,32 @@ install:
3759
- ./bootstrap
3860
- mkdir build
3961
- cd build
40-
- if [ "$LINKING" = "static" ]; then
62+
- |
63+
if [ "$LINKING" = "static" ]; then
4164
../configure --enable-static --disable-fastopen;
4265
elif [ "$DEBUG" = "debug" ] && [ "$COVERAGE" = "coverage" ]; then
4366
../configure --enable-debug --enable-coverage --disable-shared --disable-fastopen;
4467
elif [ "$DEBUG" = "debug" ]; then
4568
../configure --enable-debug --disable-shared --disable-fastopen;
4669
elif [ "$VALGRIND" = "valgrind" ]; then
4770
../configure --enable-debug --disable-fastopen --disable-valgrind-helgrind --disable-valgrind-drd --disable-valgrind-sgcheck;
71+
elif [ "$IWYU" = "iwyu" ]; then
72+
../configure --disable-examples;
4873
else
4974
../configure --disable-fastopen;
5075
fi
51-
- make
76+
# Make or run iwyu. If running iwyu, check for the result code to be 2 (IWYU always returns an error code, if it is 2, no corrections are necessary).
77+
- |
78+
if [ "$IWYU" = "iwyu" ]; then
79+
make -k CXX='/usr/local/bin/include-what-you-use -Xiwyu --mapping_file=${top_builddir}/../custom_iwyu.imp' CXXFLAGS="-isystem ${CLANG_PREFIX_PATH}/include -std=c++11 -DHTTPSERVER_COMPILATION -D_REENTRANT $CXXFLAGS" ;
80+
if [ $? -ne 2 ]; then
81+
return 1;
82+
fi
83+
else
84+
make;
85+
fi
5286
script:
53-
- make check
54-
- cat test/test-suite.log
87+
- if [ "$IWYU" != "iwyu" ]; then make check; cat test/test-suite.log; fi
5588
- if [ "$VALGRIND" = "valgrind" ]; then make check-valgrind; fi;
5689
- if [ "$VALGRIND" = "valgrind" ]; then cat test/test-suite-memcheck.log; fi;
5790
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then cd ../src/; cppcheck --error-exitcode=1 .; cd ../build; fi
@@ -309,3 +342,17 @@ matrix:
309342
- clang-9
310343
env:
311344
- MATRIX_EVAL="CC=clang-9 && CXX=clang++-9"
345+
- os: linux
346+
compiler: clang
347+
addons:
348+
apt:
349+
sources:
350+
- llvm-toolchain-xenial-7
351+
- ubuntu-toolchain-r-test
352+
packages:
353+
- iwyu
354+
- cmake
355+
- llvm-dev
356+
- libclang-dev
357+
env:
358+
- MATRIX_EVAL="IWYU=iwyu"

appveyor.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
platform: x64
22

3-
branches:
4-
except:
5-
- /.*travis.*/
6-
skip_commits:
7-
message: /travis/
8-
files:
9-
- .travis.yml
10-
113
environment:
124
matrix:
135
- compiler: msys2

custom_iwyu.imp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{ include: ["\"microhttpd.h\"", "private", "<microhttpd.h>", "public"] },
3+
{ include: ["<ext/alloc_traits.h>", "private", "<memory>", "public"] },
4+
5+
{ symbol: ["std::exception", "private", "<exception>", "public"]},
6+
{ symbol: ["std::shared_ptr", "private", "<memory>", "public"]},
7+
{ symbol: ["std::uint16_t", "private", "<cstdint>", "public"]},
8+
{ symbol: ["std::uint64_t", "private", "<cstdint>", "public"]},
9+
{ symbol: ["std::istringstream", "private", "<sstream>", "public"]},
10+
{ symbol: ["std::stringstream", "private", "<sstream>", "public"]},
11+
{ symbol: ["std::ifstream", "private", "<fstream>", "public"]},
12+
13+
{ symbol: ["uint16_t", "private", "<stdint.h>", "public"]},
14+
{ symbol: ["uint64_t", "private", "<stdint.h>", "public"]},
15+
16+
{ symbol: ["MHD_Connection", "private", "<microhttpd.h>", "public"]},
17+
]

src/basic_auth_fail_response.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
*/
2020

2121
#include "httpserver/basic_auth_fail_response.hpp"
22+
#include <microhttpd.h>
23+
24+
struct MHD_Connection;
25+
struct MHD_Response;
2226

2327
using namespace std;
2428

src/deferred_response.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
*/
2020

2121
#include "httpserver/deferred_response.hpp"
22+
#include <microhttpd.h>
23+
24+
struct MHD_Response;
2225

2326
using namespace std;
2427

src/details/http_endpoint.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@
1818
USA
1919
*/
2020

21+
#include <ctype.h>
22+
#include <map>
23+
#include <memory>
24+
#include <regex>
25+
#include <sstream>
2126
#include <stdexcept>
27+
#include <string>
28+
#include <utility>
29+
#include <vector>
2230

2331
#include "httpserver/details/http_endpoint.hpp"
24-
2532
#include "httpserver/http_utils.hpp"
26-
#include "httpserver/string_utilities.hpp"
2733

2834
using namespace std;
2935

src/digest_auth_fail_response.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
*/
2020

2121
#include "httpserver/digest_auth_fail_response.hpp"
22+
#include <microhttpd.h>
23+
24+
struct MHD_Connection;
25+
struct MHD_Response;
2226

2327
using namespace std;
2428

src/file_response.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@
1919
*/
2020

2121
#include "httpserver/file_response.hpp"
22-
2322
#include <fcntl.h>
23+
#include <microhttpd.h>
24+
#include <stddef.h>
25+
#include <unistd.h>
26+
27+
struct MHD_Response;
2428

2529
using namespace std;
2630

src/http_request.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
*/
2121

2222
#include "httpserver/http_request.hpp"
23-
23+
#include <stdio.h>
24+
#include <stdlib.h>
2425
#include <iostream>
25-
2626
#include "httpserver/http_utils.hpp"
2727
#include "httpserver/string_utilities.hpp"
2828

src/http_resource.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,10 @@
1919
*/
2020

2121
#include "httpserver/http_resource.hpp"
22-
23-
#include <stdlib.h>
24-
25-
#include "httpserver/http_request.hpp"
26-
#include "httpserver/http_response.hpp"
27-
#include "httpserver/http_utils.hpp"
22+
#include <microhttpd.h>
2823
#include "httpserver/string_response.hpp"
29-
#include "httpserver/string_utilities.hpp"
30-
#include "httpserver/webserver.hpp"
24+
25+
namespace httpserver { class http_response; }
3126

3227
using namespace std;
3328

0 commit comments

Comments
 (0)