Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79775 - trunk/tools/build/v2/test
From: jurko.gospodnetic_at_[hidden]
Date: 2012-07-27 19:41:26


Author: jurko
Date: 2012-07-27 19:41:25 EDT (Fri, 27 Jul 2012)
New Revision: 79775
URL: http://svn.boost.org/trac/boost/changeset/79775

Log:
Updated the internal Boost Build testing system's file system - now more precisely tracks the largest file modification timestamp assigned by a test build run, corrected several invalid or outdated comments, file & folder tree modeling structure's root nodes now hold correct directory name information, minor stylistic changes.
Text files modified:
   trunk/tools/build/v2/test/BoostBuild.py | 78 ++++++++++++++++++---------------------
   trunk/tools/build/v2/test/tree.py | 37 +++++++++++-------
   2 files changed, 58 insertions(+), 57 deletions(-)

Modified: trunk/tools/build/v2/test/BoostBuild.py
==============================================================================
--- trunk/tools/build/v2/test/BoostBuild.py (original)
+++ trunk/tools/build/v2/test/BoostBuild.py 2012-07-27 19:41:25 EDT (Fri, 27 Jul 2012)
@@ -419,63 +419,57 @@
         annotation("STDOUT", self.stdout())
         annotation("STDERR", self.stderr())
 
- #
- # FIXME: Large portion copied from TestSCons.py, should be moved?
- #
     def run_build_system(self, extra_args=None, subdir="", stdout=None,
         stderr="", status=0, match=None, pass_toolset=None,
         use_test_config=None, ignore_toolset_requirements=None,
         expected_duration=None, **kw):
 
         assert extra_args.__class__ is not str
- build_time_start = time.time()
 
- try:
- if os.path.isabs(subdir):
- print("You must pass a relative directory to subdir <%s>." %
- subdir)
- return
+ if os.path.isabs(subdir):
+ print("You must pass a relative directory to subdir <%s>." % subdir
+ )
+ return
 
- self.previous_tree = tree.build_tree(self.workdir)
+ self.previous_tree, dummy = tree.build_tree(self.workdir)
 
- if match is None:
- match = self.match
+ if match is None:
+ match = self.match
 
- if pass_toolset is None:
- pass_toolset = self.pass_toolset
+ if pass_toolset is None:
+ pass_toolset = self.pass_toolset
 
- if use_test_config is None:
- use_test_config = self.use_test_config
+ if use_test_config is None:
+ use_test_config = self.use_test_config
 
- if ignore_toolset_requirements is None:
- ignore_toolset_requirements = self.ignore_toolset_requirements
+ if ignore_toolset_requirements is None:
+ ignore_toolset_requirements = self.ignore_toolset_requirements
 
- try:
- kw["program"] = []
- kw["program"] += self.program
- if extra_args:
- kw["program"] += extra_args
- if pass_toolset:
- kw["program"].append("toolset=" + self.toolset)
- if use_test_config:
- kw["program"].append('--test-config="%s"' % os.path.join(
- self.original_workdir, "test-config.jam"))
- if ignore_toolset_requirements:
- kw["program"].append("--ignore-toolset-requirements")
- if "--python" in sys.argv:
- kw["program"].append("--python")
- kw["chdir"] = subdir
- self.last_program_invocation = kw["program"]
- apply(TestCmd.TestCmd.run, [self], kw)
- except:
- self.dump_stdio()
- raise
- finally:
+ try:
+ kw["program"] = []
+ kw["program"] += self.program
+ if extra_args:
+ kw["program"] += extra_args
+ if pass_toolset:
+ kw["program"].append("toolset=" + self.toolset)
+ if use_test_config:
+ kw["program"].append('--test-config="%s"' % os.path.join(
+ self.original_workdir, "test-config.jam"))
+ if ignore_toolset_requirements:
+ kw["program"].append("--ignore-toolset-requirements")
+ if "--python" in sys.argv:
+ kw["program"].append("--python")
+ kw["chdir"] = subdir
+ self.last_program_invocation = kw["program"]
+ build_time_start = time.time()
+ apply(TestCmd.TestCmd.run, [self], kw)
             build_time_finish = time.time()
- old_last_build_timestamp = self.last_build_timestamp
- self.last_build_timestamp = self.__get_current_file_timestamp()
+ except:
+ self.dump_stdio()
+ raise
 
- self.tree = tree.build_tree(self.workdir)
+ old_last_build_timestamp = self.last_build_timestamp
+ self.tree, self.last_build_timestamp = tree.build_tree(self.workdir)
         self.difference = tree.tree_difference(self.previous_tree, self.tree)
         if self.difference.empty():
             # If nothing has been changed by this build and sufficient time has

Modified: trunk/tools/build/v2/test/tree.py
==============================================================================
--- trunk/tools/build/v2/test/tree.py (original)
+++ trunk/tools/build/v2/test/tree.py 2012-07-27 19:41:25 EDT (Fri, 27 Jul 2012)
@@ -120,13 +120,11 @@
     """
       Takes PATH as the folder path, walks the file system below that path, and
     creates a tree structure based on any files and folders found there.
+ Returns the prepared tree structure plus the maximum file modification
+ timestamp under the given folder.
 
- All root nodes have an empty name to avoid being displayed when listing
- differences between two
     """
- root = TreeNode("__ROOT_TREE_NODE__", children=[])
- _handle_dir(os.path.normpath(path), root)
- return root
+ return _handle_dir(os.path.normpath(path))
 
 
 def tree_difference(a, b):
@@ -208,10 +206,17 @@
         fp.close()
 
 
-def _handle_dir(path, current_parent):
- """Main recursive worker function for build_tree()."""
+def _handle_dir(path):
+ """
+ Main recursive worker function for build_tree(). Returns a newly created
+ tree node representing the given normalized folder path as well as the
+ maximum file/folder modification time detected under the same path.
+
+ """
     files = []
     dirs = []
+ node = TreeNode(os.path.basename(path), children=[])
+ max_mtime = node.mtime = os.stat(path).st_mtime
 
     # List files & folders.
     for f in os.listdir(path):
@@ -221,16 +226,18 @@
         elif os.path.isfile(f):
             files.append(f)
 
- # Add each file as a child of CURRENT_PARENT.
+ # Add a child node for each file.
     for f in files:
         fcontents = _get_text(f)
- c = TreeNode(os.path.basename(f), contents=fcontents)
- c.mtime = os.stat(f).st_mtime
- current_parent.add_child(c)
+ new_file_node = TreeNode(os.path.basename(f), contents=fcontents)
+ new_file_node.mtime = os.stat(f).st_mtime
+ max_mtime = max(max_mtime, new_file_node.mtime)
+ node.add_child(new_file_node)
 
     # For each subdir, create a node, walk its tree, add it as a child.
     for d in dirs:
- new_dir_node = TreeNode(os.path.basename(d), children=[])
- _handle_dir(d, new_dir_node)
- new_dir_node.mtime = os.stat(f).st_mtime
- current_parent.add_child(new_dir_node)
+ new_dir_node, new_max_mtime = _handle_dir(d)
+ max_mtime = max(max_mtime, new_max_mtime)
+ node.add_child(new_dir_node)
+
+ return node, max_mtime


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk