$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r48648 - in trunk/tools/build/v2: test tools
From: jurko.gospodnetic_at_[hidden]
Date: 2008-09-07 04:38:16
Author: jurko
Date: 2008-09-07 04:38:15 EDT (Sun, 07 Sep 2008)
New Revision: 48648
URL: http://svn.boost.org/trac/boost/changeset/48648
Log:
Added documentation comments for the action timing 'time' rule in the Boost Build tools/testing.jam module. Added a test for this rule. Corrected a bug with this rule not storing user time in its output file.
Text files modified: 
   trunk/tools/build/v2/test/timedata.py  |    86 +++++++++++++++++++++++++++++++++------ 
   trunk/tools/build/v2/tools/testing.jam |     6 ++                                      
   2 files changed, 77 insertions(+), 15 deletions(-)
Modified: trunk/tools/build/v2/test/timedata.py
==============================================================================
--- trunk/tools/build/v2/test/timedata.py	(original)
+++ trunk/tools/build/v2/test/timedata.py	2008-09-07 04:38:15 EDT (Sun, 07 Sep 2008)
@@ -1,16 +1,30 @@
 #!/usr/bin/python
-# Copyright David Abrahams 2005. 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 tests the build step timing facilities.
+# Copyright 2005 David Abrahams
+# Copyright 2008 Jurko Gospodnetic
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+# Tests the build step timing facilities.
+
 
 import BoostBuild
 import re
 
-t = BoostBuild.Tester(pass_toolset=0)
 
-t.write("file.jam", """
+################################################################################
+#
+# basic_jam_action_test()
+# -----------------------
+#
+################################################################################
+
+def basic_jam_action_test():
+    """Tests basic Jam action timing support."""
+
+    t = BoostBuild.Tester(pass_toolset=0)
+
+    t.write("file.jam", """
 rule time
 {
     DEPENDS $(<) : $(>) ;
@@ -44,9 +58,9 @@
 make bar : baz ;
 """)
 
-t.write("baz", "nothing\n")
+    t.write("baz", "nothing\n")
 
-expected_output = """\.\.\.found 4 targets\.\.\.
+    expected_output = """\.\.\.found 4 targets\.\.\.
 \.\.\.updating 2 targets\.\.\.
 make bar
 time foo
@@ -54,10 +68,54 @@
 \.\.\.updated 2 targets\.\.\.$
 """
 
-t.run_build_system("-ffile.jam -d+1", stdout=expected_output,
-    match=lambda actual, expected: re.search(expected, actual, re.DOTALL))
-t.expect_addition("foo")
-t.expect_addition("bar")
-t.expect_nothing_more()
+    t.run_build_system("-ffile.jam -d+1", stdout=expected_output, match=lambda
+        actual, expected: re.search(expected, actual, re.DOTALL))
+    t.expect_addition("foo")
+    t.expect_addition("bar")
+    t.expect_nothing_more()
+
+    t.cleanup()
+
+
+################################################################################
+#
+# boost_build_testing_support_timing_rule():
+# ------------------------------------------
+#
+################################################################################
+
+def boost_build_testing_support_timing_rule():
+    """Tests the target build timing rule profided by the Boost Build tasting
+    support system.
+    """
+
+    t = BoostBuild.Tester()
+
+    t.write("aaa.cpp", "int main() {}\n")
+
+    t.write("jamroot.jam", """
+import testing ;
+exe my-exe : aaa.cpp ;
+time my-time : my-exe ;
+""")
+
+    t.run_build_system()
+    t.expect_addition("bin/$toolset/debug/aaa.obj")
+    t.expect_addition("bin/$toolset/debug/my-exe.exe")
+    t.expect_addition("bin/$toolset/debug/my-time.time")
+
+    t.expect_content_line("bin/$toolset/debug/my-time.time", "user: *")
+    t.expect_content_line("bin/$toolset/debug/my-time.time", "system: *")
+
+    t.cleanup()
+
+
+################################################################################
+#
+# main()
+# ------
+#
+################################################################################
 
-t.cleanup()
+basic_jam_action_test()
+boost_build_testing_support_timing_rule()
Modified: trunk/tools/build/v2/tools/testing.jam
==============================================================================
--- trunk/tools/build/v2/tools/testing.jam	(original)
+++ trunk/tools/build/v2/tools/testing.jam	2008-09-07 04:38:15 EDT (Sun, 07 Sep 2008)
@@ -560,6 +560,10 @@
 IMPORT testing : record-time : : testing.record-time ;
 
 
+# Calling this rule requests that Boost Build time how long it taks to build the
+# 'source' target and display the results both on the standard output and in the
+# 'target' file.
+#
 rule time ( target : source : properties *  )
 {
     # Set up rule for recording timing information.
@@ -577,5 +581,5 @@
     echo system: $(SYSTEM_TIME)
 
     echo user: $(USER_TIME)" seconds" > $(<)
-    echo system: $(SYSTEM_TIME)" seconds" > $(<)
+    echo system: $(SYSTEM_TIME)" seconds" >> $(<)
 }