Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to verify headers are self-contained #147

Merged
merged 1 commit into from Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .appveyor.yml
Expand Up @@ -20,6 +20,7 @@ environment:
- TOOLSET: msvc-14.1
ARCH: x86_64
VARIANT: debug
TEST_HEADERS: 1
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- TOOLSET: msvc-14.1
ARCH: x86_64
Expand Down
2 changes: 1 addition & 1 deletion .editorconfig
Expand Up @@ -9,7 +9,7 @@ indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true

[{CMakeLists.txt,CMakeSettings.json,*.cmake}]
[{Jamfile*,CMakeLists.txt,CMakeSettings.json,*.cmake}]
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -20,7 +20,7 @@ matrix:
- env: BOGUS_JOB=true
include:
- os: linux
env: COMPILER=g++-5 VARIANT=debug TOOLSET=gcc CXXSTD=c++11
env: COMPILER=g++-5 VARIANT=debug TOOLSET=gcc CXXSTD=c++11 TEST_HEADERS=1
addons:
apt:
packages:
Expand Down
64 changes: 56 additions & 8 deletions test/Jamfile
@@ -1,30 +1,78 @@
# Boost.GIL (Generic Image Library) - tests
#
# Copyright (c) 2007-2015 Andrey Semashev
# Copyright (c) 2008 Lubomir Bourdev, Hailin Jin
# Copyright (c) 2018 Mateusz Loskot <mateusz@loskot.net>
# Copyright (c) 2018 Dmitry Arkhipov
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or
# copy at http://www.boost.org/LICENSE_1_0.txt)

import os ;
import path ;
import regex ;
import testing ;

project
: requirements
: requirements
<include>$(BOOST_ROOT)
<include>.
;
;

# This rule is based on script copied from similar rule in Boost.Log
# and improved by Dmitry Arkhipov via #boost at cpplang.slack.com.
rule generate_self_contained_headers
{
local targets ;

# NOTE: All '/' in test names are replaced with '-' because apparently
# test scripts have a problem with test names containing slashes.

local top_headers_path = [ path.make $(BOOST_ROOT)/libs/gil/include/boost/gil ] ;

# boost/gil core headers
for local file in [ path.glob-tree $(top_headers_path) : *.hpp : extension io ]
{
local rel_file = [ path.relative-to $(top_headers_path) $(file) ] ;
local target_name = [ regex.replace self-contained/$(rel_file) "/" "-" ] ;
targets += [
compile self_contained_header.cpp
: <define>"BOOST_GIL_TEST_HEADER=$(rel_file)" <dependency>$(file)
: $(target_name)
] ;
}

# boost/gil/io headers
local headers_path = [ path.make $(BOOST_ROOT)/libs/gil/include/boost/gil/io ] ;
for local file in [ path.glob-tree $(headers_path) : *.hpp : extension io ]
{
local rel_file = [ path.relative-to $(top_headers_path) $(file) ] ;
local target_name = [ regex.replace self-contained/$(rel_file) "/" "-" ] ;
targets += [
compile self_contained_header.cpp
: <define>"BOOST_GIL_TEST_HEADER=$(rel_file)" <dependency>$(file)
: $(target_name)
] ;
}

return $(targets) ;
}

# On CI services, test the self-contained headers on-demand only to avoid build timeouts
# CI environment is common for Travis CI, AppVeyor, CircleCI, etc.
if ! [ os.environ CI ] || [ os.environ TEST_HEADERS ]
{
alias self_contained_headers : [ generate_self_contained_headers ] ;
}

run promote_integral.cpp ;
run image.cpp sample_image.cpp error_if.cpp : : gil_reference_checksums.txt ;
run channel.cpp error_if.cpp ;
run pixel.cpp error_if.cpp ;
run pixel_iterator.cpp error_if.cpp ;

alias perf :
[ run performance.cpp ]
;
explicit perf ;

build-project channel ;
build-project image_view ;

alias perf : [ run performance.cpp ] ;
explicit perf ;
18 changes: 18 additions & 0 deletions test/self_contained_header.cpp
@@ -0,0 +1,18 @@
//
// Copyright (c) 2007-2015 Andrey Semashev
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

// This file contains a test boilerplate for checking that every public header
// is self-contained and does not have any missing #include-s.

#define BOOST_GIL_TEST_INCLUDE_HEADER() <boost/gil/BOOST_GIL_TEST_HEADER>

#include BOOST_GIL_TEST_INCLUDE_HEADER()

int main()
{
return 0;
}