changeset 611:294641e84e89

0.6dev: Adding `${name}` and `${basedir}` (#325) for recipe substitution. Updated docs + new test.
author osimons
date Sat, 01 Aug 2009 01:56:14 +0000
parents 610a97f7e1ba
children ac6c6fbead45
files bitten/master.py bitten/recipe.py bitten/tests/recipe.py doc/configure.txt doc/recipes.txt
diffstat 5 files changed, 38 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/master.py
+++ b/bitten/master.py
@@ -189,6 +189,7 @@
         xml.attr['build'] = str(build.id)
         target_platform = TargetPlatform.fetch(self.env, build.platform)
         xml.attr['platform'] = target_platform.name
+        xml.attr['name'] = build.slave
         body = str(xml)
 
         self.log.info('Build slave %r initiated build %d', build.slave,
--- a/bitten/recipe.py
+++ b/bitten/recipe.py
@@ -56,6 +56,7 @@
         self.output = []
         self.basedir = os.path.realpath(self.config.interpolate(basedir,
                                                                 **self.vars))
+        self.vars['basedir'] = self.basedir
 
     def run(self, step, namespace, name, attr):
         """Run the specified recipe command.
--- a/bitten/tests/recipe.py
+++ b/bitten/tests/recipe.py
@@ -13,10 +13,27 @@
 import tempfile
 import unittest
 
-from bitten.recipe import Recipe, InvalidRecipeError
+from bitten.build.config import Configuration
+from bitten.recipe import Context, Recipe, InvalidRecipeError
 from bitten.util import xmlio
 
 
+class ContextTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.basedir = os.path.realpath(tempfile.mkdtemp())
+
+    def tearDown(self):
+        shutil.rmtree(self.basedir)
+
+    def test_vars_basedir(self):
+        config = Configuration(properties={'foo.bar': 'baz'})
+        ctxt = Context('/foo/${path}/${foo.bar}', config,
+                        {'path': 'bar'})
+
+        self.assertEquals('/foo/bar/baz', ctxt.vars['basedir'])
+
+
 class RecipeTestCase(unittest.TestCase):
 
     def setUp(self):
@@ -102,7 +119,10 @@
         recipe.validate()
 
 def suite():
-    return unittest.makeSuite(RecipeTestCase, 'test')
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(ContextTestCase, 'test'))
+    suite.addTest(unittest.makeSuite(RecipeTestCase, 'test'))
+    return suite
 
 if __name__ == '__main__':
     unittest.main(defaultTest='suite')
--- a/doc/configure.txt
+++ b/doc/configure.txt
@@ -131,6 +131,9 @@
   version = 2.3.5
   path = /usr/bin/python2.3
 
+*Note:* Options called ``name`` is not allowed in custom sections (will
+be skipped).
+
 The build slave sends this package information as part of the build initiation,
 which when using verbose logging (``bitten-slave -v``) will display a debug
 message 'Sending slave configuration:' followed by:
--- a/doc/recipes.txt
+++ b/doc/recipes.txt
@@ -36,9 +36,9 @@
 these elements are declared in XML namespaces, where the namespace URI defines
 a collection of related commands.
 
-A ``<step>```element can additionally have a ``onerror`` attribute with possible
-values of ``fail`` (terminate after step, default behaviour), or ``continue``
-(fail, but run next step), or ``ignore`` (errors are unimportant, continue).
+A ``<step>`` element can additionally have an ``onerror`` attribute with
+value of ``fail`` (terminate after step, default behaviour) or ``ignore``
+(fail, but run next step).
 
 Commonly, the first step of any build recipe will perform the checkout from the
 repository.
@@ -75,7 +75,7 @@
 `Slave Configuration`_ further custom properties can be used. Bitten supports
 these pre-defined properties:
 
-.. _`slave configuration`: slaveconfig.html
+.. _`slave configuration`: configure.html
 
 +-----------------+----------------------------------------------------------+
 | Constant        | Value                                                    |
@@ -88,6 +88,13 @@
 +-----------------+----------------------------------------------------------+
 | ``${revision}`` | The repository revision being tested                     |
 +-----------------+----------------------------------------------------------+
+| ``${platform}`` | The name of the target platform being built              |
++-----------------+----------------------------------------------------------+
+| ``${name}``     | The name of the build slave                              |
++-----------------+----------------------------------------------------------+
+| ``${basedir}``  | The absolute path of the build location, joining         |
+|                 | ``work-dir`` (absolute) with ``build-dir`` (relative)    |
++-----------------+----------------------------------------------------------+
 
 As the recipe needs to be valid XML, any reserved characters in attributes must
 be quoted using regular XML entities:
Copyright (C) 2012-2017 Edgewall Software