• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#  Copyright (C) 2016-2021 Antony Polukhin.
2#
3# Use, modification and distribution is subject to the Boost Software License,
4# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5# http://www.boost.org/LICENSE_1_0.txt)
6#
7
8import python ;
9import testing ;
10import ../../config/checks/config : requires ;
11
12project
13    : source-location .
14    : requirements
15        <toolset>msvc:<cxxflags>"/std:c++latest"
16        <define>BOOST_PFR_DETAIL_STRICT_RVALUE_TESTING=1
17        [ requires cxx14_constexpr ]
18    ;
19
20########## BEGIN of helpers to detect Loophole trick support
21
22actions mp_simple_run_action
23{
24      $(>) > $(<)
25}
26
27rule mp-run-simple ( sources + : args * : input-files * : requirements * : target-name )
28{
29   exe $(target-name)_exe : $(sources) : $(requirements) ;
30   explicit $(target-name)_exe ;
31   make $(target-name).output : $(target-name)_exe : @mp_simple_run_action ;
32   explicit $(target-name).output ;
33   alias $(target-name) : $(target-name).output ;
34}
35
36mp-run-simple loophole_detection.cpp : : : : compiler_supports_loophole ;
37explicit compiler_supports_loophole ;
38
39########## END of helpers to detect Loophole trick support
40
41
42local DISABLE_ON_MSVC = <toolset>msvc:<build>no ;
43local REQUIRE_LOOPHOLE =
44    [ check-target-builds ../test//compiler_supports_loophole : : <build>no ]
45  ;
46
47local STRUCTURED_BINDING_ENGINE = <define>BOOST_PFR_USE_LOOPHOLE=0 <define>BOOST_PFR_USE_CPP17=1 [ requires cxx17_structured_bindings ] ;
48local LOOPHOLE_ENGINE = <define>BOOST_PFR_USE_LOOPHOLE=1 <define>BOOST_PFR_USE_CPP17=0 $(REQUIRE_LOOPHOLE) ;
49local CLASSIC_ENGINE = <define>BOOST_PFR_USE_LOOPHOLE=0 <define>BOOST_PFR_USE_CPP17=0 $(DISABLE_ON_MSVC) ;
50
51test-suite pfr_tests
52  :
53    [ run print_config.cpp : : : <test-info>always_show_run_output : auto_engine_config ]
54
55    [ run offset_based_getter.cpp ]
56
57    [ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON=char : test_tuple_sizes_on_chars ]
58    [ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON=int : test_tuple_sizes_on_ints ]
59    [ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON=short : test_tuple_sizes_on_shorts ]
60    [ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON=void* : test_tuple_sizes_on_voidptrs ]
61    [ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON="std::size_t" : test_tuple_sizes_on_size_ts ]
62
63    [ run run/motivating_example.cpp      : : : : auto_engine_motivating ]
64    [ run ../example/sample_printing.cpp  : : : : auto_engine_sample_printing ]
65    [ run ../example/get.cpp              : : : : auto_engine_get ]
66    [ run ../example/quick_examples.cpp   : : : : auto_engine_quick ]
67  ;
68
69local BLACKLIST_TESTS_FOR_LOOPHOLE =
70    constexpr_ops                       # Loophole is not constexpr usable because of the reinterpret_cast usage
71    get_const_field                     # boost::pfr::get gives compile time error on const fields
72    optional_chrono                     # boost::pfr::* has problems with std::optional, produces compile time error
73    template_constructor                # Template constructor in one of the fields of the aggregate
74    tie_anonymous_const_field           # boost::pfr::structure_tie gives compile time error on const fields
75  ;
76
77# Those tests are either
78# * reflecting a non literal type
79# * or calling boost::pfr::get and the result is a user defined structure
80local BLACKLIST_TESTS_FOR_CLASSIC =
81    constexpr_ops
82    get_const_field
83    get_non_default_constructible
84    get_rvalue
85    issue30
86    issue33
87    motivating_example0
88    motivating_example2
89    optional_chrono
90    optional_like
91    read_write_non_literal
92    template_constructor
93    template_forwarding_ref
94    template_unconstrained
95    tie_anonymous
96    tie_anonymous_const_field
97  ;
98
99for local source_file in [ glob ./run/*.cpp ] [ glob ../example/*.cpp ]
100{
101    local target_name = $(source_file[1]:B) ;
102    pfr_tests += [ run $(source_file) : : : $(STRUCTURED_BINDING_ENGINE) : $(target_name)_sb ] ;
103
104    if ! $(target_name) in $(BLACKLIST_TESTS_FOR_LOOPHOLE)
105    {
106        pfr_tests += [ run $(source_file) : : : $(LOOPHOLE_ENGINE) : $(target_name)_lh ] ;
107    }
108    else
109    {
110        pfr_tests += [ compile-fail $(source_file) : $(LOOPHOLE_ENGINE) : $(target_name)_lh ] ;
111    }
112
113    if ! $(target_name) in $(BLACKLIST_TESTS_FOR_CLASSIC)
114    {
115        pfr_tests += [ run $(source_file) : : : $(CLASSIC_ENGINE) : $(target_name)_classic ] ;
116    }
117    else
118    {
119        pfr_tests += [ compile-fail $(source_file) : $(CLASSIC_ENGINE) : $(target_name)_classic ] ;
120    }
121}
122
123for local source_file in [ glob ./compile-fail/*.cpp ]
124{
125    local target_name = $(source_file[1]:B) ;
126    pfr_tests += [ compile-fail $(source_file) : $(STRUCTURED_BINDING_ENGINE) : $(target_name)_sb ] ;
127    pfr_tests += [ compile-fail $(source_file) : $(LOOPHOLE_ENGINE) : $(target_name)_lh ] ;
128    pfr_tests += [ compile-fail $(source_file) : $(CLASSIC_ENGINE) : $(target_name)_classic ] ;
129}
130
131if [ python.configured ]
132{
133    testing.make-test run-pyd : ../misc/generate_cpp17.py ;
134}
135