Boost logo

Boost-Commit :

From: troy_at_[hidden]
Date: 2007-07-17 18:34:52


Author: troy
Date: 2007-07-17 18:34:51 EDT (Tue, 17 Jul 2007)
New Revision: 7457
URL: http://svn.boost.org/trac/boost/changeset/7457

Log:

Minimal setup for running continuous/nightly regression tests.

Added:
   sandbox-branches/boost-cmake/dart-client/README
Text files modified:
   sandbox-branches/boost-cmake/dart-client/client.py | 147 +++++++++++++++++++++++----------------
   sandbox-branches/boost-cmake/dart-client/conf.py | 32 +++++--
   2 files changed, 107 insertions(+), 72 deletions(-)

Added: sandbox-branches/boost-cmake/dart-client/README
==============================================================================
--- (empty file)
+++ sandbox-branches/boost-cmake/dart-client/README 2007-07-17 18:34:51 EDT (Tue, 17 Jul 2007)
@@ -0,0 +1,15 @@
+
+This directory contains a utility for running continuous and nightly
+regression tests via ctest. To use, checkout this directory,
+customize conf.py, and either run
+
+ ./client.py bootstrap
+
+which is the equivalent of
+
+ ./client.py clean
+ ./client.py checkout
+ ./client.py initialize_builds
+ ./client.py run
+
+

Modified: sandbox-branches/boost-cmake/dart-client/client.py
==============================================================================
--- sandbox-branches/boost-cmake/dart-client/client.py (original)
+++ sandbox-branches/boost-cmake/dart-client/client.py 2007-07-17 18:34:51 EDT (Tue, 17 Jul 2007)
@@ -1,5 +1,11 @@
 #!/usr/bin/env python
-
+#
+# Copyright (C) 2007 Troy Straszheim <troy_at_[hidden]>
+#
+# 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
+#
 #
 # Continuous/nightly testing script.
 #
@@ -22,7 +28,6 @@
 import time
 import subprocess
 from datetime import datetime, timedelta
-from xml.dom.minidom import parseString
 
 configfile = "conf.py"
 
@@ -35,38 +40,24 @@
 # last_start: time this test was last started.
 #
 class Build:
- def __init__(self, id_, build_variant_, ctest_variant_, revision_):
+ def dir(self):
+ return os.path.join(self.id, self.build_variant, self.ctest_variant)
+
+ def srcdir(self):
+ return os.path.join(self.dir(), "src")
+
+ def builddir(self):
+ return os.path.join(self.dir(), "build")
+
+ def __str__(self):
+ return self.id + "/" + self.build_variant + "/" + self.ctest_variant + " last_start @ " + str(self.last_start)
+
+ def __init__(self, id_, build_variant_, ctest_variant_):
         self.id = id_
         self.build_variant = build_variant_
         self.ctest_variant = ctest_variant_
- self.revision = revision_
         self.last_start = datetime.now()
-
- def __str__(self):
- return self.id + "/" + self.build_variant + "/" + self.ctest_variant + " r" + str(self.revision) + " last_start @ " + str(self.last_start)
-
-#
-# Get current svn revision number of srcdir
-#
-def svn_status_revision(srcdir):
- output = subprocess.Popen([svn, "info", "--xml", srcdir], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
- dom = parseString(output)
- rev = dom.getElementsByTagName("commit")[0].getAttribute("revision")
- return rev
-
-#
-# svn update "srcdir" to revision "revision"
-#
-def svn_update(srcdir, revision):
- try:
- retcode = subprocess.call([svn, "update", "-r", revision, srcdir])
- if retcode < 0:
- print >>sys.stderr, "Child was terminated by signal ", -retcode
- else:
- print >>sys.stderr, "Child returned", retcode
- except OSError, e:
- print >> sys.stderr, "Execution failed:", e
-
+
 #
 # svn checkout "url" to local directory "srcdir"
 #
@@ -85,7 +76,7 @@
 # as reported by the *_dt functions in the config file.
 #
 def nextbuild(builds):
- nextbuild = Build('none', 'none', 'none', -1)
+ nextbuild = Build('none', 'none', 'none')
     nextbuild_deltat = timedelta.min
 
     for b in builds:
@@ -101,16 +92,11 @@
 def initbuilds():
     builds = []
     for id in urls:
- srcdir = os.path.join(topdir, prefix, id, "src")
- try:
- rev = svn_status_revision(srcdir)
- except:
- rev = -1
         for bv in build_variants:
             for cv in ctest_variants:
- build = Build(id, bv, cv, rev)
+ build = Build(id, bv, cv)
                 builds.append(build)
- print "Initialized build " + str(build)
+ print ">>> info: Build " + str(build)
     return builds
 
 #
@@ -131,71 +117,103 @@
         exit(1)
 
 #
+# take path to build/src directory and return absolute path
+#
+def absolute_path(p):
+ return os.path.join(topdir, prefix, p)
+
+#
 # run cmake (but not make) for each build directory
 #
 def initialize_builds(argv):
+ """
+ Configures each build with cmake."""
     print "Making build directories..."
     for build in initbuilds():
- buildpath = os.path.join(topdir,prefix, build.id, build.build_variant, build.ctest_variant)
- srcpath = os.path.join(topdir, prefix, build.id, "src")
+ buildpath = absolute_path(build.builddir())
+ srcpath = absolute_path(build.srcdir())
         try:
             if not os.path.isdir(buildpath):
                 os.makedirs(buildpath)
                 print ">>> Initializing " + buildpath
         except Exception, e:
- print "Directory %s exists, not creating (%s)" % (buildpath, e)
+ print "Directory %s exists, not creating (%s)" % (buildpath, str(e))
         os.chdir(buildpath)
         cmd = cmake + " " + " ".join(build_variants[build.build_variant]) + " " + srcpath
         print ">>> Executing " + cmd
         os.system(cmd)
     
 #
+# clean prefix and all subdirectores
+#
+def clean(argv):
+ """
+ Wipes prefix directory."""
+ print "Obliterating [prefix] directories"
+ for root, dirs, files in os.walk(prefix, topdown=False):
+ for name in files:
+ os.remove(os.path.join(root, name))
+ for name in dirs:
+ print "- ", os.path.join(root, name)
+ os.rmdir(os.path.join(root, name))
+#
 # Create the necessary directories for the various build/test variants
 # and checkout the source, but don't run cmake.
 #
 def checkout(argv):
- builds = initbuilds()
- for id, url in urls.items():
- srcdir = os.path.join(topdir,prefix,id,"src")
+ """
+ Runs svn checkout for each build/variant."""
+ for build in initbuilds():
+ srcdir = absolute_path(build.srcdir())
         try:
             os.mkdir(srcdir)
         except:
- print "Directory %s exists, not creating." % id
+ print "Directory %s exists, not creating." % build.id
             
- print "Checking out " + id
- svn_checkout(url, srcdir)
+ print "Checking out " + build.id
+ svn_checkout(urls[build.id], srcdir)
 
 #
 # Do the builds in an infinite loop.
 #
 def run(args):
+ """
+ Runs ctest over all builds/variants in a loop."""
     builds = initbuilds()
     while True:
         build = nextbuild(builds)
         print ">>> Starting " + str(build)
- srcdir = os.path.join(topdir, prefix, build.id, "src")
- if build.revision != -1:
- print ">>> Updating " + srcdir + " to " + str(build.revision)
- svn_update(srcdir, build.revision)
+ srcdir = absolute_path(build.srcdir())
         build.last_start = datetime.now()
- os.chdir(os.path.join(topdir, prefix, build.id, build.build_variant, build.ctest_variant))
+ os.chdir(absolute_path(build.builddir()))
         cmd = ctest + " " + " ".join(ctest_variants[build.ctest_variant][0])
         os.system(cmd)
- rev = svn_status_revision(srcdir)
- build.revision = rev
- print ">>> Finished %s/%s/%s, now at r%s" % (build.id, build.build_variant, build.ctest_variant, build.revision)
         print ">>> Sleeping %s seconds..." % interbuild_sleep
         time.sleep(interbuild_sleep)
 
-def srcdir_path(build):
- return os.path.join(topdir, prefix, build.id, "src")
 #
-# eh.
+# Do everything required to get up and running, clean.
 #
+def bootstrap(argv):
+ """
+ Does everything from scratch. Wipes the source directory, checks
+ out the source, initializes each build, runs ctest in a loop."""
+ clean(argv)
+ checkout(argv)
+ initialize_builds(argv)
+ run(argv)
+
 def help(argv):
- print "Usage:\n\n " + argv[0] + " (checkout|run)\n\ncheckout: checks out source and sets up build environment. Do this first.\nrun: run regression tests in a loop.\n\n"
- sys.exit(1)
-
+ """
+ Prints this help."""
+ print "Usage:\n%s <command>" % argv[0]
+ print "See file %s for specific configuration." % configfile
+ print "Available commands:"
+ for (name, fn) in action_mapping.iteritems():
+ print " %s: %s" % (name, fn.__doc__)
+#
+# The main routine
+#
 topdir = '?'
 def main(argv):
     globals()['topdir'] = os.getcwd()
@@ -211,12 +229,17 @@
 # map command-line strings to functions
 #
 action_mapping = {
+ 'help' : help,
     'checkout' : checkout,
+ 'clean' : clean,
+ 'bootstrap' : bootstrap,
     'initialize_builds' : initialize_builds,
     'run' : run,
- 'help' : help,
     }
 
+#
+# standard python main-hook.
+#
 if __name__ == "__main__":
     if len(sys.argv) != 2:
         help(sys.argv)

Modified: sandbox-branches/boost-cmake/dart-client/conf.py
==============================================================================
--- sandbox-branches/boost-cmake/dart-client/conf.py (original)
+++ sandbox-branches/boost-cmake/dart-client/conf.py 2007-07-17 18:34:51 EDT (Tue, 17 Jul 2007)
@@ -1,7 +1,15 @@
 #
+# Copyright (C) 2007 Troy Straszheim <troy_at_[hidden]>
+#
+# 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
+#
+#
+#
 # Name of local directory that will contain build output
 #
-prefix = 'prefix'
+prefix = 'work'
 
 #
 # Wait 1 minute between builds
@@ -10,14 +18,16 @@
 interbuild_sleep = 60
 
 #
-# Association tag => url of things to build/test
+# Association source_tag => url of things to build/test. The tags will be used as
+# local directory names.
 #
 boost_svn = 'http://svn.boost.org/svn/boost/sandbox-branches/boost-cmake/boost_1_34_0'
 test_svn = 'http://svn.resophonic.com/pub/ctest-tiny'
 urls = { 'boost_1_34_0' : boost_svn }
 
 #
-# Variants to build/test: map of tag => [cmake_arguments]
+# Variants to build/test: map of boost_variant_tag => [cmake_arguments]
+# The boost_variant_tag will be used a as local directory name.
 #
 all_args = ['-DBUILD_TESTING:BOOL=ON']
 build_variants = {
@@ -54,7 +64,7 @@
     return current_time - t
 
 #
-# Association of ctest variants to build: tag => ([ctest_args], delta_fn)
+# Association of ctest variants to build: ctest_variant_tag => ([ctest_args], delta_fn)
 #
 # Where delta_fn returns the amount of time between now and its
 # argument. The build with the longest delta_t will be built next.
@@ -62,20 +72,22 @@
 # (and therefore will not be built) when the actual dt is less than some
 # threshold.
 #
+# Each ctest_variant_tag will be used as a local directory name.
+#
 ctest_variants = {
     'continuous' : (['-D', 'Continuous'], continuous_dt),
     'nightly' : (['-D', 'Nightly'], nightly_dt)
     }
 
 #
-# CUSTOMIZE THESE
-#
-# Typical settings on unix.
+# You may need to customize these for your platform. These are
+# typical settings on unix.
 #
-ctest = "ctest"
-cmake = "cmake"
-svn = "svn"
+ctest = "ctest" # path to ctest binary
+cmake = "cmake" # path to cmake binary
+svn = "svn" # path to svn
 
+#
 # Typical settings on windows:
 #
 # The escaped doublequotes around the name of the executables are necessary.


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