Skip to content

Commit

Permalink
Add test to verify headers are self-contained
Browse files Browse the repository at this point in the history
For each header, a translation unit is generated along with
corresponding compile target.
Currently, only boost/gil/*.hpp and boost/gil/io/* headres are included.
  • Loading branch information
mloskot committed Oct 3, 2018
1 parent 7293313 commit 138a6dc
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 9 deletions.
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
60 changes: 52 additions & 8 deletions test/Jamfile
@@ -1,30 +1,74 @@
# 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>
#
# 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 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
rule test_self_contained_headers
{
local all_rules = ;
local all_targets = ;
local top_headers_path = [ path.make $(BOOST_ROOT)/libs/gil/include/boost/gil ] ;

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

# 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 = [ regex.replace self-contained/$(rel_file) "/" "-" ] ;
all_rules += [
compile self_contained_header.cpp
: <define>"BOOST_GIL_TEST_HEADER=$(rel_file)" <dependency>$(file)
: $(target)
] ;
all_targets += $(target) ;
}

# 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 : ]
{
local rel_file = [ path.relative-to $(top_headers_path) $(file) ] ;
local target = [ regex.replace self-contained/$(rel_file) "/" "-" ] ;
all_rules += [
compile self_contained_header.cpp
: <define>"BOOST_GIL_TEST_HEADER=$(rel_file)" <dependency>$(file)
: $(target)
] ;
all_targets += $(target) ;
}

#explicit $(all_targets) ;
return $(all_rules) ;
}

alias self_contained_headers : [ test_self_contained_headers ] ;
#explicit self_contained_headers ; # TODO: Uncomment all `#explicit` to build on-demand

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;
}

0 comments on commit 138a6dc

Please sign in to comment.