diff --git a/.appveyor.yml b/.appveyor.yml index c88c1e936..db118a5e8 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -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 diff --git a/.editorconfig b/.editorconfig index afc4141bd..ef760659e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 diff --git a/.travis.yml b/.travis.yml index 5881e295f..4b7a8d0f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/test/Jamfile b/test/Jamfile index 8dfe441c9..59a6f2c06 100644 --- a/test/Jamfile +++ b/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 +# 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 $(BOOST_ROOT) . - ; + ; + +# 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 + : "BOOST_GIL_TEST_HEADER=$(rel_file)" $(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 + : "BOOST_GIL_TEST_HEADER=$(rel_file)" $(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 ; diff --git a/test/self_contained_header.cpp b/test/self_contained_header.cpp new file mode 100644 index 000000000..234901db6 --- /dev/null +++ b/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() + +#include BOOST_GIL_TEST_INCLUDE_HEADER() + +int main() +{ + return 0; +}