boost/libs/pfr/test/Jamfile.v2
2021-10-05 21:37:46 +02:00

135 lines
4.9 KiB
Plaintext

# Copyright (C) 2016-2021 Antony Polukhin.
#
# Use, modification and distribution is subject to 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 python ;
import testing ;
import ../../config/checks/config : requires ;
project
: source-location .
: requirements
<toolset>msvc:<cxxflags>"/std:c++latest"
<define>BOOST_PFR_DETAIL_STRICT_RVALUE_TESTING=1
[ requires cxx14_constexpr ]
;
########## BEGIN of helpers to detect Loophole trick support
actions mp_simple_run_action
{
$(>) > $(<)
}
rule mp-run-simple ( sources + : args * : input-files * : requirements * : target-name )
{
exe $(target-name)_exe : $(sources) : $(requirements) ;
explicit $(target-name)_exe ;
make $(target-name).output : $(target-name)_exe : @mp_simple_run_action ;
explicit $(target-name).output ;
alias $(target-name) : $(target-name).output ;
}
mp-run-simple loophole_detection.cpp : : : : compiler_supports_loophole ;
explicit compiler_supports_loophole ;
########## END of helpers to detect Loophole trick support
local DISABLE_ON_MSVC = <toolset>msvc:<build>no ;
local REQUIRE_LOOPHOLE =
[ check-target-builds ../test//compiler_supports_loophole : : <build>no ]
;
local STRUCTURED_BINDING_ENGINE = <define>BOOST_PFR_USE_LOOPHOLE=0 <define>BOOST_PFR_USE_CPP17=1 [ requires cxx17_structured_bindings ] ;
local LOOPHOLE_ENGINE = <define>BOOST_PFR_USE_LOOPHOLE=1 <define>BOOST_PFR_USE_CPP17=0 $(REQUIRE_LOOPHOLE) ;
local CLASSIC_ENGINE = <define>BOOST_PFR_USE_LOOPHOLE=0 <define>BOOST_PFR_USE_CPP17=0 $(DISABLE_ON_MSVC) ;
test-suite pfr_tests
:
[ run print_config.cpp : : : <test-info>always_show_run_output : auto_engine_config ]
[ run offset_based_getter.cpp ]
[ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON=char : test_tuple_sizes_on_chars ]
[ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON=int : test_tuple_sizes_on_ints ]
[ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON=short : test_tuple_sizes_on_shorts ]
[ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON=void* : test_tuple_sizes_on_voidptrs ]
[ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON="std::size_t" : test_tuple_sizes_on_size_ts ]
[ run run/motivating_example.cpp : : : : auto_engine_motivating ]
[ run ../example/sample_printing.cpp : : : : auto_engine_sample_printing ]
[ run ../example/get.cpp : : : : auto_engine_get ]
[ run ../example/quick_examples.cpp : : : : auto_engine_quick ]
;
local BLACKLIST_TESTS_FOR_LOOPHOLE =
constexpr_ops # Loophole is not constexpr usable because of the reinterpret_cast usage
get_const_field # boost::pfr::get gives compile time error on const fields
optional_chrono # boost::pfr::* has problems with std::optional, produces compile time error
template_constructor # Template constructor in one of the fields of the aggregate
tie_anonymous_const_field # boost::pfr::structure_tie gives compile time error on const fields
;
# Those tests are either
# * reflecting a non literal type
# * or calling boost::pfr::get and the result is a user defined structure
local BLACKLIST_TESTS_FOR_CLASSIC =
constexpr_ops
get_const_field
get_non_default_constructible
get_rvalue
issue30
issue33
motivating_example0
motivating_example2
optional_chrono
optional_like
read_write_non_literal
template_constructor
template_forwarding_ref
template_unconstrained
tie_anonymous
tie_anonymous_const_field
;
for local source_file in [ glob ./run/*.cpp ] [ glob ../example/*.cpp ]
{
local target_name = $(source_file[1]:B) ;
pfr_tests += [ run $(source_file) : : : $(STRUCTURED_BINDING_ENGINE) : $(target_name)_sb ] ;
if ! $(target_name) in $(BLACKLIST_TESTS_FOR_LOOPHOLE)
{
pfr_tests += [ run $(source_file) : : : $(LOOPHOLE_ENGINE) : $(target_name)_lh ] ;
}
else
{
pfr_tests += [ compile-fail $(source_file) : $(LOOPHOLE_ENGINE) : $(target_name)_lh ] ;
}
if ! $(target_name) in $(BLACKLIST_TESTS_FOR_CLASSIC)
{
pfr_tests += [ run $(source_file) : : : $(CLASSIC_ENGINE) : $(target_name)_classic ] ;
}
else
{
pfr_tests += [ compile-fail $(source_file) : $(CLASSIC_ENGINE) : $(target_name)_classic ] ;
}
}
for local source_file in [ glob ./compile-fail/*.cpp ]
{
local target_name = $(source_file[1]:B) ;
pfr_tests += [ compile-fail $(source_file) : $(STRUCTURED_BINDING_ENGINE) : $(target_name)_sb ] ;
pfr_tests += [ compile-fail $(source_file) : $(LOOPHOLE_ENGINE) : $(target_name)_lh ] ;
pfr_tests += [ compile-fail $(source_file) : $(CLASSIC_ENGINE) : $(target_name)_classic ] ;
}
if [ python.configured ]
{
testing.make-test run-pyd : ../misc/generate_cpp17.py ;
}