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__)
53 echo timed from $(>) >> $(<)
56 rule record_time ( target : source : start end user system )
58 __USER_TIME__ on $(target) = $(user) ;
59 __SYSTEM_TIME__ on $(target) = $(system) ;
69 echo made from $(>) >> $(<)
76 t.write("baz", "nothing")
78 expected_output = """\
79 \.\.\.found 4 targets\.\.\.
80 \.\.\.updating 2 targets\.\.\.
83 bar +user: [0-9\.]+ +system: +[0-9\.]+ *
84 \.\.\.updated 2 targets\.\.\.$
87 t.run_build_system(["-ffile.jam", "-d+1"], stdout=expected_output,
88 match=lambda actual, expected: re.search(expected, actual, re.DOTALL))
89 t.expect_addition("foo")
90 t.expect_addition("bar")
91 t.expect_nothing_more()
96 ###############################################################################
98 # boost_build_testing_support_timing_rule():
99 # ------------------------------------------
101 ###############################################################################
103 def boost_build_testing_support_timing_rule():
105 Tests the target build timing rule provided by the Boost Build testing
109 t = BoostBuild.Tester(use_test_config=False)
111 t.write("aaa.cpp", "int main() {}\n")
113 t.write("jamroot.jam", """\
115 exe my-exe : aaa.cpp ;
116 time my-time : my-exe ;
120 t.expect_addition("bin/$toolset/debug/aaa.obj")
121 t.expect_addition("bin/$toolset/debug/my-exe.exe")
122 t.expect_addition("bin/$toolset/debug/my-time.time")
124 t.expect_content_lines("bin/$toolset/debug/my-time.time",
125 "user: *[0-9] seconds")
126 t.expect_content_lines("bin/$toolset/debug/my-time.time",
127 "system: *[0-9] seconds")
132 ###############################################################################
134 # boost_build_testing_support_timing_rule_with_spaces_in_names()
135 # --------------------------------------------------------------
137 ###############################################################################
139 def boost_build_testing_support_timing_rule_with_spaces_in_names():
141 Tests the target build timing rule provided by the Boost Build testing
142 support system when used with targets contining spaces in their names.
145 t = BoostBuild.Tester(use_test_config=False)
147 t.write("aaa bbb.cpp", "int main() {}\n")
149 t.write("jamroot.jam", """\
151 exe "my exe" : "aaa bbb.cpp" ;
152 time "my time" : "my exe" ;
156 t.expect_addition("bin/$toolset/debug/aaa bbb.obj")
157 t.expect_addition("bin/$toolset/debug/my exe.exe")
158 t.expect_addition("bin/$toolset/debug/my time.time")
160 t.expect_content_lines("bin/$toolset/debug/my time.time", "user: *")
161 t.expect_content_lines("bin/$toolset/debug/my time.time", "system: *")
166 ###############################################################################
171 ###############################################################################
173 basic_jam_action_test()
174 boost_build_testing_support_timing_rule()
175 boost_build_testing_support_timing_rule_with_spaces_in_names()