1# Copyright 2002. Dave Abrahams 2# Copyright 2016-2018. Rene Rivera 3# Distributed under the Boost Software License, Version 1.0. 4# (See accompanying file LICENSE_1_0.txt or copy at 5# http://www.boost.org/LICENSE_1_0.txt) 6 7# This build project manages running the tests for all of Boost. 8# The tests to run are discovered from the structure of the libs tree. 9# 10# Usage: 11# 12# > cd boost-root/status 13# > b2 [--check-libs-only] [--limit-tests=/lib-name-regex../]* [--exclude-tests=/lib-name-regex../]* 14# 15# --check-libs-only 16# Only runs the library conformance tests. 17# 18# --no-check-libs 19# Do not run the library conformance tests. 20# 21# --limit-tests, or --include-tests 22# Only runs the tests for whom the name matches the regex. 23# The value for the argument is a comma separated list of simple 24# regular expressions to check against the names of all the libraries. 25# If any one regex matches the matching library is tested. 26# 27# --exclude-tests 28# Only runs the tests for whom the names does not match the regex. 29# The argument is the same as for the limit-tests option except 30# that the result is that libraries for whom the name matches 31# are not tested. 32# 33# The test filters are evaluated in the order given in the command 34# and can be used to selectively narrow or widen the set of libraries 35# tested. 36# 37# Examples: 38# 39# > b2 --check-libs-only --include-tests=predef,config 40# 41# Runs the library conformance tests for the predef and config 42# libraries only. 43# 44# > b2 --include-tests=[n-t] --exclude-tests=rat --limit-tests=[v-w] 45# 46# Runs all the tests for library names that begin with "n" through "t", 47# or "v" through "w", but not libraries that start with "rat". 48 49project status 50 : source-location $(BOOST_ROOT) 51 : requirements <hardcode-dll-paths>true 52 ; 53 54import testing ; 55import modules ; 56import project ; 57import regex ; 58import modules ; 59import path ; 60import feature ; 61import numbers ; 62 63local check-libs-only = [ MATCH "^--(check-libs-only)" : [ modules.peek : ARGV ] ] ; 64local no-check-libs = [ MATCH "^--(no-check-libs)$" : [ modules.peek : ARGV ] ] ; 65local check-libs-only-targets = ; 66local libraries = ; 67 68local rule run-tests ( root : tests * ) 69{ 70 local filter-args = [ MATCH "^--(limit|exclude|include)-tests=(.*)" : [ modules.peek : ARGV ] ] ; 71 local filter-tests ; 72 while $(filter-args) 73 { 74 local type = $(filter-args[1]) ; 75 for local test in [ regex.split-list $(filter-args[2]) : "[,]" ] 76 { 77 filter-tests += $(type) $(test) ; 78 } 79 filter-args = $(filter-args[3-]) ; 80 } 81 # If any filter is given we make the initial set of tested libraries we: 82 # (a) make it empty if the first filter is an include. 83 # (b) make it full otherwise. 84 local include-default = y ; 85 if $(filter-tests[1]) && ( $(filter-tests[1]) in limit include ) 86 { 87 include-default = n ; 88 } 89 local location = [ project.attribute $(__name__) location ] ; 90 # We only run the check library test when host-os == target-os. 91 # Hence we need that information. 92 local host-os-default = [ feature.defaults <host-os> ] ; 93 for local test in $(tests) 94 { 95 local library = [ path.parent $(test) ] ; 96 if $(library) = "." 97 { 98 library = $(test) ; 99 } 100 local include-test = $(include-default) ; 101 local t = 1 ; 102 local f = 2 ; 103 while $(filter-tests[$(f)]) 104 { 105 if [ MATCH "^($(filter-tests[$(f)]))" : $(test) ] 106 { 107 if $(filter-tests[$(t)]) = exclude { include-test = n ; } 108 else { include-test = y ; } 109 } 110 t = [ CALC $(t) + 2 ] ; 111 f = [ CALC $(f) + 2 ] ; 112 } 113 if $(include-test) = y 114 { 115 if [ path.exists ../$(root)/$(test) ] 116 { 117 use-project /boost/$(test) : ../$(root)/$(test) ; 118 } 119 if $(root) = libs && ! $(no-check-libs) && ( ! ( $(library) in $(libraries) ) ) 120 { 121 libraries += $(library) ; 122 local test_module = [ project.find ../$(root)/$(test) : $(location) ] ; 123 modules.poke $(test_module) : __LIBRARY__ : $(root)/$(library) ; 124 modules.poke $(test_module) : __JAMFILE__ : [ modules.peek project : JAMFILE ] ; 125 modules.poke $(test_module) : __REQUIRE__ : <target-os>$(host-os-default:G=) ; 126 project.push-current [ project.target $(test_module) ] ; 127 module $(test_module) 128 { 129 import testing ; 130 testing.make-test run-pyd : 131 $(BOOST_ROOT)/status/boost_check_library.py 132 : 133 <pythonpath>$(BOOST_ROOT)/status 134 <testing.arg>--boost-root=\"$(BOOST_ROOT)\" 135 <testing.arg>--library=$(__LIBRARY__) 136 <testing.arg>--jamfile=\"$(__JAMFILE__:J=;)\" 137 <testing.arg>organization 138 $(__REQUIRE__) 139 : 140 __boost_check_library__ ; 141 } 142 project.pop-current ; 143 check-libs-only-targets += ../$(root)/$(test)//__boost_check_library__ ; 144 } 145 if ! $(check-libs-only) 146 { 147 build-project ../$(root)/$(test) ; 148 } 149 } 150 } 151} 152 153local rule find-targets ( target : libs * ) 154{ 155 local result = ; 156 157 for local lib in $(libs) 158 { 159 local path = $(lib)/test ; 160 local project = [ project.load $(path) ] ; 161 local pt = [ project.target $(project) ] ; 162 local mt = [ $(pt).main-target $(target) ] ; 163 164 if $(mt) 165 { 166 result += $(path)//$(target) ; 167 } 168 } 169 170 return $(result) ; 171} 172 173local libs-to-test = ; 174for local libdir in [ path.glob $(BOOST_ROOT) : libs/* ] 175{ 176 local jamfile = [ modules.peek project : JAMFILE ] ; 177 local jamfiles = [ path.glob [ path.join $(libdir) test ] : $(jamfile) ] ; 178 if $(jamfiles) 179 { 180 libs-to-test += $(libdir:B) ; 181 } 182 if [ path.glob $(libdir) : sublibs ] 183 { 184 jamfiles = [ path.glob $(libdir) : */test/$(jamfile) ] ; 185 for local sublib_jamfile in $(jamfiles) 186 { 187 local sublibdir = [ path.parent [ path.parent $(sublib_jamfile) ] ] ; 188 local sublib = $(libdir:B)/$(sublibdir:B) ; 189 libs-to-test += $(sublib) ; 190 } 191 } 192} 193 194libs-to-test = [ SORT $(libs-to-test) ] ; 195 196run-tests libs : $(libs-to-test)/test ; 197 198# Tests from Jamfiles in tools/ 199# Please keep these in alphabetical order 200 201local tools-to-test = ; 202for local tooldir in bcp check_build quickbook 203{ 204 local jamfile = [ modules.peek project : JAMFILE ] ; 205 local jamfiles = [ path.glob [ path.join $(BOOST_ROOT) tools $(tooldir) test ] : $(jamfile) ] ; 206 if $(jamfiles) 207 { 208 tools-to-test += $(tooldir) ; 209 } 210} 211 212#ECHO "tools-to-test:" $(tools-to-test) ; 213 214run-tests tools : $(tools-to-test)/test ; 215 216if $(check-libs-only-targets) 217{ 218 alias check-libs-only : $(check-libs-only-targets) ; 219} 220 221alias minimal : [ find-targets minimal : ../libs/$(libs-to-test) ] ; 222explicit minimal ; 223 224alias quick : [ find-targets quick : ../libs/$(libs-to-test) ../tools/$(tools-to-test) ] ; 225explicit quick ; 226