summaryrefslogtreecommitdiff
path: root/status/Jamfile.v2
blob: ee0288945afb0ad0145cf1e49f7f757aa000e8d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# Copyright 2002. Dave Abrahams
# Copyright 2016-2018. Rene Rivera
# 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 build project manages running the tests for all of Boost.
# The tests to run are discovered from the structure of the libs tree.
#
# Usage:
#
# > cd boost-root/status
# > b2 [--check-libs-only] [--limit-tests=/lib-name-regex../]* [--exclude-tests=/lib-name-regex../]*
#
# --check-libs-only
#   Only runs the library conformance tests.
#
# --no-check-libs
#   Do not run the library conformance tests.
#
# --limit-tests, or --include-tests
#   Only runs the tests for whom the name matches the regex.
#   The value for the argument is a comma separated list of simple
#   regular expressions to check against the names of all the libraries.
#   If any one regex matches the matching library is tested.
#
# --exclude-tests
#   Only runs the tests for whom the names does not match the regex.
#   The argument is the same as for the limit-tests option except
#   that the result is that libraries for whom the name matches
#   are not tested.
#
# The test filters are evaluated in the order given in the command
# and can be used to selectively narrow or widen the set of libraries
# tested.
#
# Examples:
#
# > b2 --check-libs-only --include-tests=predef,config
# 
# Runs the library conformance tests for the predef and config
# libraries only.
#
# > b2 --include-tests=[n-t] --exclude-tests=rat --limit-tests=[v-w]
#
# Runs all the tests for library names that begin with "n" through "t",
# or "v" through "w", but not libraries that start with "rat".

project status
    : source-location $(BOOST_ROOT)
    : requirements <hardcode-dll-paths>true
    ;

import testing ;
import modules ;
import project ;
import regex ;
import modules ;
import path ;
import feature ;
import numbers ;

local check-libs-only = [ MATCH "^--(check-libs-only)" : [ modules.peek : ARGV ] ] ;
local no-check-libs = [ MATCH "^--(no-check-libs)$" : [ modules.peek : ARGV ] ] ;
local check-libs-only-targets = ;
local libraries = ;

local rule run-tests ( root : tests * )
{
    local filter-args = [ MATCH "^--(limit|exclude|include)-tests=(.*)" : [ modules.peek : ARGV ] ] ;
    local filter-tests ;
    while $(filter-args)
    {
        local type = $(filter-args[1]) ;
        for local test in [ regex.split-list $(filter-args[2]) : "[,]" ]
        {
            filter-tests += $(type) $(test) ;
        }
        filter-args = $(filter-args[3-]) ;
    }
    # If any filter is given we make the initial set of tested libraries we:
    # (a) make it empty if the first filter is an include.
    # (b) make it full otherwise.
    local include-default = y ;
    if $(filter-tests[1]) && ( $(filter-tests[1]) in limit include )
    {
        include-default = n ;
    }
    local location = [ project.attribute $(__name__) location ] ;
    # We only run the check library test when host-os == target-os.
    # Hence we need that information.
    local host-os-default = [ feature.defaults <host-os> ] ;
    for local test in $(tests)
    {
        local library = [ path.parent $(test) ] ;
        if $(library) = "."
        {
            library = $(test) ;
        }
        local include-test = $(include-default) ;
        local t = 1 ;
        local f = 2 ;
        while $(filter-tests[$(f)])
        {
            if [ MATCH "^($(filter-tests[$(f)]))" : $(test) ]
            {
                if $(filter-tests[$(t)]) = exclude { include-test = n ; }
                else { include-test = y ; }
            }
            t = [ CALC $(t) + 2 ] ;
            f = [ CALC $(f) + 2 ] ;
        }
        if $(include-test) = y
        {
            if [ path.exists ../$(root)/$(test) ]
            {
                use-project /boost/$(test) : ../$(root)/$(test) ;
            }
            if $(root) = libs && ! $(no-check-libs) && ( ! ( $(library) in $(libraries) ) )
            {
                libraries += $(library) ;
                local test_module = [ project.find ../$(root)/$(test) : $(location) ] ;
                modules.poke $(test_module) : __LIBRARY__ : $(root)/$(library) ;
                modules.poke $(test_module) : __JAMFILE__ : [ modules.peek project : JAMFILE ] ;
                modules.poke $(test_module) : __REQUIRE__ : <target-os>$(host-os-default:G=) ;
                project.push-current [ project.target $(test_module) ] ;
                module $(test_module)
                {
                    import testing ;
                    testing.make-test run-pyd :
                        $(BOOST_ROOT)/status/boost_check_library.py
                        :
                        <pythonpath>$(BOOST_ROOT)/status
                        <testing.arg>--boost-root=\"$(BOOST_ROOT)\"
                        <testing.arg>--library=$(__LIBRARY__)
                        <testing.arg>--jamfile=\"$(__JAMFILE__:J=;)\"
                        <testing.arg>organization
                        $(__REQUIRE__)
                        :
                        __boost_check_library__ ;
                }
                project.pop-current ;
                check-libs-only-targets += ../$(root)/$(test)//__boost_check_library__ ;
            }
            if ! $(check-libs-only)
            {
                build-project ../$(root)/$(test) ;
            }
        }
    }
}

local rule find-targets ( target : libs * )
{
    local result = ;

    for local lib in $(libs)
    {
        local path = $(lib)/test ;
        local project = [ project.load $(path) ] ;
        local pt = [ project.target $(project) ] ;
        local mt = [ $(pt).main-target $(target) ] ;

        if $(mt)
        {
            result += $(path)//$(target) ;
        }
    }

    return $(result) ;
}

local libs-to-test = ;
for local libdir in [ path.glob $(BOOST_ROOT) : libs/* ]
{
    local jamfile = [ modules.peek project : JAMFILE ] ;
    local jamfiles = [ path.glob [ path.join $(libdir) test ] : $(jamfile) ] ;
    if $(jamfiles)
    {
        libs-to-test += $(libdir:B) ;
    }
    if [ path.glob $(libdir) : sublibs ]
    {
        jamfiles = [ path.glob $(libdir) : */test/$(jamfile) ] ;
        for local sublib_jamfile in $(jamfiles)
        {
            local sublibdir = [ path.parent [ path.parent $(sublib_jamfile) ] ] ;
            local sublib = $(libdir:B)/$(sublibdir:B) ;
            libs-to-test += $(sublib) ;
        }
    }
}

libs-to-test = [ SORT $(libs-to-test) ] ;

run-tests libs : $(libs-to-test)/test ;

# Tests from Jamfiles in tools/
# Please keep these in alphabetical order

local tools-to-test = ;
for local tooldir in bcp check_build quickbook
{
    local jamfile = [ modules.peek project : JAMFILE ] ;
    local jamfiles = [ path.glob [ path.join $(BOOST_ROOT) tools $(tooldir) test ] : $(jamfile) ] ;
    if $(jamfiles)
    {
        tools-to-test += $(tooldir) ;
    }
}

#ECHO "tools-to-test:" $(tools-to-test) ;

run-tests tools : $(tools-to-test)/test ;

if $(check-libs-only-targets)
{
    alias check-libs-only : $(check-libs-only-targets) ;
}

alias minimal : [ find-targets minimal : ../libs/$(libs-to-test) ] ;
explicit minimal ;

alias quick : [ find-targets quick : ../libs/$(libs-to-test) ../tools/$(tools-to-test) ] ;
explicit quick ;