]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/timedata.py
3 # Copyright 2005 David Abrahams
4 # Copyright 2008, 2012 Jurko Gospodnetic
5 # Distributed under the Boost Software License, Version 1.0.
6 # (See accompanying file LICENSE_1_0.txt or copy at
7 # http://www.boost.org/LICENSE_1_0.txt)
9 # Tests the build step timing facilities.
11 # TODO: Missing tests:
12 # 1. 'time' target with a source target representing more than one virtual
13 # target. This happens in practice, e.g. when using the time rule on a msvc
14 # exe target whose generator actually constructs an EXE and a PDB target.
15 # When this is done - only the main virtual target's constructing action
17 # 2. 'time' target with a source target representing a virtual target that
18 # actually gets built by multiple actions run in sequence. In that case a
19 # separate timing result should be reported for each of those actions. This
20 # happens in practice, e.g. when using the time rule on a msvc exe target
21 # which first gets created as a result of some link action and then its
22 # manifest gets embedded inside it as a resource using a separate action
23 # (assuming an appropriate property has been set for this target - see the
24 # msvc module for details).
30 ###############################################################################
32 # basic_jam_action_test()
33 # -----------------------
35 ###############################################################################
37 def basic_jam_action_test():
38 """Tests basic Jam action timing support."""
40 t
= BoostBuild
.Tester(pass_toolset
=0)
42 t
.write("file.jam", """\
46 __TIMING_RULE__ on $(>) = record_time $(<) ;
52 echo $(>) user: $(__USER_TIME__) system: $(__SYSTEM_TIME__) clock: $(__CLOCK_TIME__)
53 echo timed from $(>) >> $(<)
56 rule record_time ( target : source : start end user system clock )
58 __USER_TIME__ on $(target) = $(user) ;
59 __SYSTEM_TIME__ on $(target) = $(system) ;
60 __CLOCK_TIME__ on $(target) = $(clock) ;
70 echo made from $(>) >> $(<)
77 t
.write("baz", "nothing")
79 expected_output
= """\
80 \.\.\.found 4 targets\.\.\.
81 \.\.\.updating 2 targets\.\.\.
84 bar +user: [0-9\.]+ +system: +[0-9\.]+ +clock: +[0-9\.]+ *
85 \.\.\.updated 2 targets\.\.\.$
88 t
.run_build_system(["-ffile.jam", "-d+1"], stdout
=expected_output
,
89 match
=lambda actual
, expected
: re
.search(expected
, actual
, re
.DOTALL
))
90 t
.expect_addition("foo")
91 t
.expect_addition("bar")
92 t
.expect_nothing_more()
97 ###############################################################################
99 # boost_build_testing_support_timing_rule():
100 # ------------------------------------------
102 ###############################################################################
104 def boost_build_testing_support_timing_rule():
106 Tests the target build timing rule provided by the Boost Build testing
110 t
= BoostBuild
.Tester(use_test_config
=False)
112 t
.write("aaa.cpp", "int main() {}\n")
114 t
.write("jamroot.jam", """\
116 exe my-exe : aaa.cpp ;
117 time my-time : my-exe ;
121 t
.expect_addition("bin/$toolset/debug/aaa.obj")
122 t
.expect_addition("bin/$toolset/debug/my-exe.exe")
123 t
.expect_addition("bin/$toolset/debug/my-time.time")
125 t
.expect_content_lines("bin/$toolset/debug/my-time.time",
126 "user: *[0-9] seconds")
127 t
.expect_content_lines("bin/$toolset/debug/my-time.time",
128 "system: *[0-9] seconds")
129 t
.expect_content_lines("bin/$toolset/debug/my-time.time",
130 "clock: *[0-9] seconds")
135 ###############################################################################
137 # boost_build_testing_support_timing_rule_with_spaces_in_names()
138 # --------------------------------------------------------------
140 ###############################################################################
142 def boost_build_testing_support_timing_rule_with_spaces_in_names():
144 Tests the target build timing rule provided by the Boost Build testing
145 support system when used with targets contining spaces in their names.
148 t
= BoostBuild
.Tester(use_test_config
=False)
150 t
.write("aaa bbb.cpp", "int main() {}\n")
152 t
.write("jamroot.jam", """\
154 exe "my exe" : "aaa bbb.cpp" ;
155 time "my time" : "my exe" ;
159 t
.expect_addition("bin/$toolset/debug/aaa bbb.obj")
160 t
.expect_addition("bin/$toolset/debug/my exe.exe")
161 t
.expect_addition("bin/$toolset/debug/my time.time")
163 t
.expect_content_lines("bin/$toolset/debug/my time.time", "user: *")
164 t
.expect_content_lines("bin/$toolset/debug/my time.time", "system: *")
169 ###############################################################################
174 ###############################################################################
176 basic_jam_action_test()
177 boost_build_testing_support_timing_rule()
178 boost_build_testing_support_timing_rule_with_spaces_in_names()