Boost logo

Boost-Commit :

From: jurko.gospodnetic_at_[hidden]
Date: 2008-01-06 15:56:20


Author: jurko
Date: 2008-01-06 15:56:20 EST (Sun, 06 Jan 2008)
New Revision: 42549
URL: http://svn.boost.org/trac/boost/changeset/42549

Log:
Added new tests related to Boost Build's default toolset handling. They test that the correct default toolset gets use and that when it gets used that has no different status than any other explicitly specified toolset.
Added:
   trunk/tools/build/v2/test/default_toolset.py (contents, props changed)
Text files modified:
   trunk/tools/build/v2/test/test_all.py | 1 +
   1 files changed, 1 insertions(+), 0 deletions(-)

Added: trunk/tools/build/v2/test/default_toolset.py
==============================================================================
--- (empty file)
+++ trunk/tools/build/v2/test/default_toolset.py 2008-01-06 15:56:20 EST (Sun, 06 Jan 2008)
@@ -0,0 +1,211 @@
+#!/usr/bin/python
+
+# 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)
+
+# Test that the expected default toolset is used when no toolset is explicitly
+# specified on the command line or used from code via the using rule. Test that
+# the default toolset is correctly used just like any other explicitly used
+# toolset (e.g. toolset prerequisites, properties conditioned on toolset related
+# features, etc.).
+#
+# Note that we need to ignore regular site/user/test configuration files to
+# avoid them marking any toolsets not under our control as used.
+
+import BoostBuild
+
+
+# Line displayed by Boost Build when using the default toolset.
+configuring_default_toolset_message = \
+ 'warning: Configuring default toolset "%s".'
+
+
+################################################################################
+#
+# test_conditions_on_default_toolset()
+# ------------------------------------
+#
+################################################################################
+
+def test_conditions_on_default_toolset():
+ """Test that toolset and toolset subfeature conditioned properties get
+ applied correctly when the toolset is selected by default. Implicitly tests
+ that we can use the set-default-toolset rule to set the default toolset to
+ be used by Boost Build.
+ """
+
+ t = BoostBuild.Tester("--user-config= --ignore-site-config",
+ pass_toolset=False, use_test_config=False)
+
+ toolset_name = "myCustomTestToolset"
+ toolset_version = "v"
+ toolset_version_unused = "v_unused"
+ message_loaded = "Toolset '%s' loaded." % toolset_name
+ message_initialized = "Toolset '%s' initialized." % toolset_name ;
+
+ # Custom toolset.
+ t.write(toolset_name + ".jam", """
+import feature ;
+ECHO "%(message_loaded)s" ;
+feature.extend toolset : %(toolset_name)s ;
+feature.subfeature toolset %(toolset_name)s : version : %(toolset_version)s %(toolset_version_unused)s ;
+rule init ( version ) { ECHO "%(message_initialized)s" ; }
+""" % {'message_loaded' : message_loaded ,
+ 'message_initialized' : message_initialized,
+ 'toolset_name' : toolset_name ,
+ 'toolset_version' : toolset_version ,
+ 'toolset_version_unused': toolset_version_unused})
+
+ # Main Boost Build project script.
+ t.write("Jamroot.jam", """
+import build-system ;
+import errors ;
+import feature ;
+import notfile ;
+
+build-system.set-default-toolset %(toolset_name)s : %(toolset_version)s ;
+
+feature.feature description : : free incidental ;
+
+# We use a rule instead of an action to avoid problems with action output not
+# getting piped to stdout by the testing system.
+rule buildRule ( names : targets ? : properties * )
+{
+ local descriptions = [ feature.get-values description : $(properties) ] ;
+ ECHO "descriptions:" /$(descriptions)/ ;
+ local toolset = [ feature.get-values toolset : $(properties) ] ;
+ ECHO "toolset:" /$(toolset)/ ;
+ local toolset-version = [ feature.get-values "toolset-$(toolset):version" : $(properties) ] ;
+ ECHO "toolset-version:" /$(toolset-version)/ ;
+}
+
+notfile testTarget
+ : @buildRule
+ :
+ :
+ <description>stand-alone
+ <toolset>%(toolset_name)s:<description>toolset
+ <toolset>%(toolset_name)s-%(toolset_version)s:<description>toolset-version
+ <toolset>%(toolset_name)s-%(toolset_version_unused)s:<description>toolset-version-unused ;
+""" % {'toolset_name' : toolset_name ,
+ 'toolset_version' : toolset_version,
+ 'toolset_version_unused': toolset_version_unused})
+
+ t.run_build_system()
+ t.expect_output_line(configuring_default_toolset_message % toolset_name)
+ t.expect_output_line(message_loaded)
+ t.expect_output_line(message_initialized)
+ t.expect_output_line("descriptions: /stand-alone/ /toolset/ /toolset-version/")
+ t.expect_output_line("toolset: /%s/" % toolset_name)
+ t.expect_output_line("toolset-version: /%s/" % toolset_version)
+
+ t.cleanup()
+
+
+################################################################################
+#
+# test_default_toolset_on_os()
+# ----------------------------
+#
+################################################################################
+
+def test_default_toolset_on_os( os, expected_toolset ):
+ """Test that the given toolset is used as the default toolset on the given
+ os. Uses hardcoded knowledge of how Boost Build decides on which host OS it
+ is currently running. Note that we must not do much after tricking Boost
+ Build into believing it has a specific host OS as this might mess up other
+ important internal Boost Build state.
+ """
+
+ t = BoostBuild.Tester("--user-config= --ignore-site-config",
+ pass_toolset=False, use_test_config=False)
+
+ t.write("Jamroot.jam", "modules.poke os : .name : %s ;" % os)
+
+ # We need to tell the test system to ignore stderr output as attempting to
+ # load missing toolsets might cause random failures with which we are not
+ # concerned in this test.
+ t.run_build_system(stderr=None)
+ t.expect_output_line(configuring_default_toolset_message % expected_toolset)
+
+ t.cleanup()
+
+
+################################################################################
+#
+# test_default_toolset_requirements()
+# -----------------------------------
+#
+################################################################################
+
+def test_default_toolset_requirements():
+ """Test that default toolset's requirements get applied correctly.
+ """
+
+ t = BoostBuild.Tester("--user-config= --ignore-site-config",
+ pass_toolset=False, use_test_config=False,
+ ignore_toolset_requirements=False)
+
+ toolset_name = "customTestToolsetWithRequirements"
+
+ # Custom toolset.
+ t.write(toolset_name + ".jam", """
+import feature ;
+import toolset ;
+feature.extend toolset : %(toolset_name)s ;
+toolset.add-requirements <description>toolset-requirement ;
+rule init ( ) { }
+""" % {'toolset_name': toolset_name})
+
+ # Main Boost Build project script.
+ t.write("Jamroot.jam", """
+import build-system ;
+import errors ;
+import feature ;
+import notfile ;
+
+build-system.set-default-toolset %(toolset_name)s ;
+
+feature.feature description : : free incidental ;
+
+# We use a rule instead of an action to avoid problems with action output not
+# getting piped to stdout by the testing system.
+rule buildRule ( names : targets ? : properties * )
+{
+ local descriptions = [ feature.get-values description : $(properties) ] ;
+ ECHO "descriptions:" /$(descriptions)/ ;
+ local toolset = [ feature.get-values toolset : $(properties) ] ;
+ ECHO "toolset:" /$(toolset)/ ;
+}
+
+notfile testTarget
+ : @buildRule
+ :
+ :
+ <description>target-requirement
+ <description>toolset-requirement:<description>conditioned-requirement
+ <description>unrelated-condition:<description>unrelated-description ;
+""" % {'toolset_name': toolset_name})
+
+ t.run_build_system()
+ t.expect_output_line(configuring_default_toolset_message % toolset_name)
+ t.expect_output_line("descriptions: /conditioned-requirement/ /target-requirement/ /toolset-requirement/")
+ t.expect_output_line("toolset: /%s/" % toolset_name)
+
+ t.cleanup()
+
+
+################################################################################
+#
+# main()
+# ------
+#
+################################################################################
+
+test_default_toolset_on_os("NT" , "msvc")
+test_default_toolset_on_os("LINUX" , "gcc" )
+test_default_toolset_on_os("CYGWIN" , "gcc" )
+test_default_toolset_on_os("SomeOtherOS", "gcc" )
+test_default_toolset_requirements()
+test_conditions_on_default_toolset()

Modified: trunk/tools/build/v2/test/test_all.py
==============================================================================
--- trunk/tools/build/v2/test/test_all.py (original)
+++ trunk/tools/build/v2/test/test_all.py 2008-01-06 15:56:20 EST (Sun, 06 Jan 2008)
@@ -104,6 +104,7 @@
           "no_type",
           "chain",
           "default_build",
+ "default_toolset",
           "use_requirements",
           "conditionals",
           "conditionals2",


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