1# 2# Copyright (c) 2005 João Abecasis 3# 4# Distributed under the Boost Software License, Version 1.0. (See 5# accompanying file LICENSE_1_0.txt or copy at 6# http://www.boost.org/LICENSE_1_0.txt) 7# 8 9import feature ; 10import generators ; 11import modules ; 12import project ; 13import targets ; 14import testing ; 15import toolset ; 16import type ; 17 18feature.feature quickbook-testing.quickbook-command : : free dependency ; 19feature.feature <quickbook-test-define> : : free ; 20feature.feature <quickbook-test-include> : : free path ; 21feature.feature <quickbook-xinclude-base> : : free ; 22 23type.register QUICKBOOK_INPUT : quickbook ; 24type.register QUICKBOOK_OUTPUT ; 25type.register QUICKBOOK_HTML_OUTPUT ; 26 27generators.register-standard quickbook-testing.process-quickbook : QUICKBOOK_INPUT : QUICKBOOK_OUTPUT ; 28generators.register-standard quickbook-testing.process-quickbook-html : QUICKBOOK_INPUT : QUICKBOOK_HTML_OUTPUT ; 29 30################################################################################ 31# 32# quickbook-test - generates a test for quickbook itself. A quickbook-test is 33# actually made up of two tests: 34# $(target-name).boostbook : 35# generate boostbook from $(input) or $(target-name).quickbook 36# 37# $(target-name): 38# compare generated boostbook to $(reference-output) or 39# $(input).gold or $(target-name).gold 40# 41rule quickbook-test ( target-name : input ? : reference-output ? : requirements * ) 42{ 43 input ?= $(target-name).quickbook ; 44 reference-output ?= $(input:S=.gold) ; 45 reference-output-html = $(input:S=.gold-html) ; 46 47 local project = [ project.current ] ; 48 49 local boost-root = [ modules.peek : BOOST_ROOT ] ; 50 51 local t1 = 52 [ targets.create-typed-target QUICKBOOK_OUTPUT 53 : $(project) 54 : $(target-name).boostbook 55 : $(input) 56 : $(requirements) 57 <location-prefix>$(target-name).test 58 <quickbook-testing.quickbook-command>$(boost-root)/tools/quickbook/src//quickbook 59 ] ; 60 61 local t2 = 62 [ targets.create-typed-target RUN 63 : $(project) 64 : $(target-name) 65 : $(boost-root)/tools/quickbook/test/src/text_diff.cpp 66 : $(requirements) 67 <location-prefix>$(target-name).test2 68 <testing.input-file>$(reference-output) 69 <testing.input-file>$(target-name).boostbook 70 <preserve-test-targets>on 71 ] ; 72 73 local t1-html = 74 [ targets.create-typed-target QUICKBOOK_HTML_OUTPUT 75 : $(project) 76 : $(target-name).html 77 : $(input) 78 : $(requirements) 79 <location-prefix>$(target-name).test-html 80 <quickbook-testing.quickbook-command>$(boost-root)/tools/quickbook/src//quickbook 81 ] ; 82 83 local t2-html = 84 [ targets.create-typed-target RUN 85 : $(project) 86 : $(target-name)-compare-html 87 : $(boost-root)/tools/quickbook/test/src/text_diff.cpp 88 : $(requirements) 89 <location-prefix>$(target-name).test-html 90 <testing.input-file>$(reference-output-html) 91 <testing.input-file>$(target-name).html 92 <preserve-test-targets>on 93 ] ; 94 95 local all-tests = [ modules.peek testing : .all-tests ] ; 96 all-tests += $(t2) $(t2-html) ; 97 modules.poke testing : .all-tests : $(all-tests) ; 98 99 return $(t1) $(t2) $(t1-html) $(t2-html) ; 100} 101 102rule quickbook-fail-test ( target-name : input ? : requirements * ) 103{ 104 input ?= $(target-name).quickbook ; 105 106 local project = [ project.current ] ; 107 108 local boost-root = [ modules.peek : BOOST_ROOT ] ; 109 110 local t = 111 [ targets.create-typed-target RUN_FAIL 112 : $(project) 113 : $(target-name) 114 : $(boost-root)/tools/quickbook/src//quickbook 115 : $(requirements) 116 <testing.input-file>$(input) 117 <preserve-test-targets>on 118 <dependency>$(input) 119 ] 120 ; 121 122 local all-tests = [ modules.peek testing : .all-tests ] ; 123 all-tests += $(t) ; 124 modules.poke testing : .all-tests : $(all-tests) ; 125 126 return $(t) ; 127} 128 129rule quickbook-error-test ( target-name : input ? : requirements * ) 130{ 131 input ?= $(target-name).quickbook ; 132 133 local project = [ project.current ] ; 134 135 local boost-root = [ modules.peek : BOOST_ROOT ] ; 136 137 local t = 138 [ targets.create-typed-target RUN 139 : $(project) 140 : $(target-name) 141 : $(boost-root)/tools/quickbook/src//quickbook 142 : $(requirements) 143 <testing.input-file>$(input) 144 <testing.arg>--expect-errors 145 <preserve-test-targets>on 146 <dependency>$(input) 147 ] 148 ; 149 150 local all-tests = [ modules.peek testing : .all-tests ] ; 151 all-tests += $(t) ; 152 modules.poke testing : .all-tests : $(all-tests) ; 153 154 return $(t) ; 155} 156 157################################################################################ 158toolset.flags quickbook-testing.process-quickbook quickbook-command <quickbook-testing.quickbook-command> ; 159toolset.flags quickbook-testing.process-quickbook QB-DEFINES <quickbook-test-define> ; 160toolset.flags quickbook-testing.process-quickbook XINCLUDE <quickbook-xinclude-base> ; 161toolset.flags quickbook-testing.process-quickbook INCLUDES <quickbook-test-include> ; 162toolset.flags quickbook-testing.process-quickbook-html quickbook-command <quickbook-testing.quickbook-command> ; 163toolset.flags quickbook-testing.process-quickbook-html QB-DEFINES <quickbook-test-define> ; 164toolset.flags quickbook-testing.process-quickbook-html XINCLUDE <quickbook-xinclude-base> ; 165toolset.flags quickbook-testing.process-quickbook-html INCLUDES <quickbook-test-include> ; 166 167rule process-quickbook ( target : source : properties * ) 168{ 169 DEPENDS $(target) : [ on $(target) return $(quickbook-command) ] ; 170} 171 172actions process-quickbook bind quickbook-command 173{ 174 $(quickbook-command) $(>) --output-file=$(<) --debug -D"$(QB-DEFINES)" -I"$(INCLUDES)" --xinclude-base="$(XINCLUDE)" 175} 176 177rule process-quickbook-html ( target : source : properties * ) 178{ 179 DEPENDS $(target) : [ on $(target) return $(quickbook-command) ] ; 180} 181 182actions process-quickbook-html bind quickbook-command 183{ 184 $(quickbook-command) $(>) --output-format=onehtml --output-file=$(<) --debug -D"$(QB-DEFINES)" -I"$(INCLUDES)" --xinclude-base="$(XINCLUDE)" 185} 186