#!/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) # Tests that properties conditioned on more than one other property work as # expected. import BoostBuild ################################################################################ # # test_multiple_conditions() # -------------------------- # ################################################################################ def test_multiple_conditions(): """Basic tests for properties conditioned on multiple other properties. """ t = BoostBuild.Tester("--ignore-regular-config toolset=testToolset", pass_toolset=False, use_test_config=False) t.write("testToolset.jam", """ import feature ; feature.extend toolset : testToolset ; rule init ( ) { } """) t.write("Jamroot.jam", """ import feature ; import notfile ; import toolset ; feature.feature description : : free incidental ; feature.feature aaa : 1 0 : incidental ; feature.feature bbb : 1 0 : incidental ; feature.feature ccc : 1 0 : incidental ; rule buildRule ( name : targets ? : properties * ) { for local description in [ feature.get-values description : $(properties) ] { ECHO "description:" /$(description)/ ; } } notfile testTarget1 : @buildRule : : d 0:a0 1:a1 0,0:a0-b0 0,1:a0-b1 1,0:a1-b0 1,1:a1-b1 0,0,0:a0-b0-c0 0,0,1:a0-b0-c1 0,1,1:a0-b1-c1 1,0,1:a1-b0-c1 1,1,0:a1-b1-c0 1,1,1:a1-b1-c1 ; """) t.run_build_system("aaa=1 bbb=1 ccc=1") t.expect_output_line("description: /d/" ) t.expect_output_line("description: /a0/" , False) t.expect_output_line("description: /a1/" ) t.expect_output_line("description: /a0-b0/" , False) t.expect_output_line("description: /a0-b1/" , False) t.expect_output_line("description: /a1-b0/" , False) t.expect_output_line("description: /a1-b1/" ) t.expect_output_line("description: /a0-b0-c0/", False) t.expect_output_line("description: /a0-b0-c1/", False) t.expect_output_line("description: /a0-b1-c1/", False) t.expect_output_line("description: /a1-b0-c1/", False) t.expect_output_line("description: /a1-b1-c0/", False) t.expect_output_line("description: /a1-b1-c1/" ) t.run_build_system("aaa=0 bbb=0 ccc=1") t.expect_output_line("description: /d/" ) t.expect_output_line("description: /a0/" ) t.expect_output_line("description: /a1/" , False) t.expect_output_line("description: /a0-b0/" ) t.expect_output_line("description: /a0-b1/" , False) t.expect_output_line("description: /a1-b0/" , False) t.expect_output_line("description: /a1-b1/" , False) t.expect_output_line("description: /a0-b0-c0/", False) t.expect_output_line("description: /a0-b0-c1/" ) t.expect_output_line("description: /a0-b1-c1/", False) t.expect_output_line("description: /a1-b0-c1/", False) t.expect_output_line("description: /a1-b1-c0/", False) t.expect_output_line("description: /a1-b1-c1/", False) t.run_build_system("aaa=0 bbb=0 ccc=0") t.expect_output_line("description: /d/" ) t.expect_output_line("description: /a0/" ) t.expect_output_line("description: /a1/" , False) t.expect_output_line("description: /a0-b0/" ) t.expect_output_line("description: /a0-b1/" , False) t.expect_output_line("description: /a1-b0/" , False) t.expect_output_line("description: /a1-b1/" , False) t.expect_output_line("description: /a0-b0-c0/" ) t.expect_output_line("description: /a0-b0-c1/", False) t.expect_output_line("description: /a0-b1-c1/", False) t.expect_output_line("description: /a1-b0-c1/", False) t.expect_output_line("description: /a1-b1-c0/", False) t.expect_output_line("description: /a1-b1-c1/", False) t.cleanup() ################################################################################ # # test_multiple_conditions_with_toolset_version() # ----------------------------------------------- # ################################################################################ def test_multiple_conditions_with_toolset_version(): """Regression tests for properties conditioned on the toolset version subfeature and some additional properties. """ toolset = "testToolset" ; t = BoostBuild.Tester("--ignore-regular-config", pass_toolset=False, use_test_config=False) t.write( toolset + ".jam", """ import feature ; feature.extend toolset : %(toolset)s ; feature.subfeature toolset %(toolset)s : version : 0 1 ; rule init ( version ? ) { } """ % {"toolset": toolset}) t.write("Jamroot.jam", """ import feature ; import notfile ; import toolset ; toolset.using testToolset ; feature.feature description : : free incidental ; feature.feature aaa : 0 1 : incidental ; feature.feature bbb : 0 1 : incidental ; feature.feature ccc : 0 1 : incidental ; rule buildRule ( name : targets ? : properties * ) { local ttt = [ feature.get-values toolset : $(properties) ] ; local vvv = [ feature.get-values toolset-testToolset:version : $(properties) ] ; local aaa = [ feature.get-values aaa : $(properties) ] ; local bbb = [ feature.get-values bbb : $(properties) ] ; local ccc = [ feature.get-values ccc : $(properties) ] ; ECHO "toolset:" /$(ttt)/ "version:" /$(vvv)/ "aaa/bbb/ccc:" /$(aaa)/$(bbb)/$(ccc)/ ; for local description in [ feature.get-values description : $(properties) ] { ECHO "description:" /$(description)/ ; } } notfile testTarget1 : @buildRule : : testToolset,0:t-a0 testToolset,1:t-a1 testToolset-0,0:t0-a0 testToolset-0,1:t0-a1 testToolset-1,0:t1-a0 testToolset-1,1:t1-a1 testToolset,0,0:t-a0-b0 testToolset,0,1:t-a0-b1 testToolset,1,0:t-a1-b0 testToolset,1,1:t-a1-b1 0,testToolset,0:a0-t-b0 0,testToolset,1:a0-t-b1 1,testToolset,0:a1-t-b0 1,testToolset,1:a1-t-b1 0,0,testToolset:a0-b0-t 0,1,testToolset:a0-b1-t 1,0,testToolset:a1-b0-t 1,1,testToolset:a1-b1-t testToolset-0,0,0:t0-a0-b0 testToolset-0,0,1:t0-a0-b1 testToolset-0,1,0:t0-a1-b0 testToolset-0,1,1:t0-a1-b1 testToolset-1,0,0:t1-a0-b0 testToolset-1,0,1:t1-a0-b1 testToolset-1,1,0:t1-a1-b0 testToolset-1,1,1:t1-a1-b1 0,testToolset-1,0:a0-t1-b0 0,testToolset-1,1:a0-t1-b1 1,testToolset-0,0:a1-t0-b0 1,testToolset-0,1:a1-t0-b1 0,1,testToolset-0:b0-a1-t0 0,0,testToolset-1:b0-a0-t1 0,1,testToolset-1:b0-a1-t1 1,0,testToolset-1:b1-a0-t1 1,1,testToolset-0:b1-a1-t0 1,1,testToolset-1:b1-a1-t1 ; """) t.run_build_system("aaa=1 bbb=1 ccc=1 toolset=%s-0" % toolset) t.expect_output_line("description: /t-a0/" , False) t.expect_output_line("description: /t-a1/" ) t.expect_output_line("description: /t0-a0/" , False) t.expect_output_line("description: /t0-a1/" ) t.expect_output_line("description: /t1-a0/" , False) t.expect_output_line("description: /t1-a1/" , False) t.expect_output_line("description: /t-a0-b0/" , False) t.expect_output_line("description: /t-a0-b1/" , False) t.expect_output_line("description: /t-a1-b0/" , False) t.expect_output_line("description: /t-a1-b1/" ) t.expect_output_line("description: /a0-t-b0/" , False) t.expect_output_line("description: /a0-t-b1/" , False) t.expect_output_line("description: /a1-t-b0/" , False) t.expect_output_line("description: /a1-t-b1/" ) t.expect_output_line("description: /a0-b0-t/" , False) t.expect_output_line("description: /a0-b1-t/" , False) t.expect_output_line("description: /a1-b0-t/" , False) t.expect_output_line("description: /a1-b1-t/" ) t.expect_output_line("description: /t0-a0-b0/", False) t.expect_output_line("description: /t0-a0-b1/", False) t.expect_output_line("description: /t0-a1-b0/", False) t.expect_output_line("description: /t0-a1-b1/" ) t.expect_output_line("description: /t1-a0-b0/", False) t.expect_output_line("description: /t1-a0-b1/", False) t.expect_output_line("description: /t1-a1-b0/", False) t.expect_output_line("description: /t1-a1-b1/", False) t.expect_output_line("description: /a0-t1-b0/", False) t.expect_output_line("description: /a0-t1-b1/", False) t.expect_output_line("description: /a1-t0-b0/", False) t.expect_output_line("description: /a1-t0-b1/", False) t.expect_output_line("description: /b0-a1-t0/", False) t.expect_output_line("description: /b0-a0-t1/", False) t.expect_output_line("description: /b0-a1-t1/", False) t.expect_output_line("description: /b1-a0-t1/", False) t.expect_output_line("description: /b1-a1-t0/" ) t.expect_output_line("description: /b1-a1-t1/", False) t.run_build_system("aaa=1 bbb=1 ccc=1 toolset=%s-1" % toolset) t.expect_output_line("description: /t-a0/" , False) t.expect_output_line("description: /t-a1/" ) t.expect_output_line("description: /t0-a0/" , False) t.expect_output_line("description: /t0-a1/" , False) t.expect_output_line("description: /t1-a0/" , False) t.expect_output_line("description: /t1-a1/" ) t.expect_output_line("description: /t-a0-b0/" , False) t.expect_output_line("description: /t-a0-b1/" , False) t.expect_output_line("description: /t-a1-b0/" , False) t.expect_output_line("description: /t-a1-b1/" ) t.expect_output_line("description: /a0-t-b0/" , False) t.expect_output_line("description: /a0-t-b1/" , False) t.expect_output_line("description: /a1-t-b0/" , False) t.expect_output_line("description: /a1-t-b1/" ) t.expect_output_line("description: /a0-b0-t/" , False) t.expect_output_line("description: /a0-b1-t/" , False) t.expect_output_line("description: /a1-b0-t/" , False) t.expect_output_line("description: /a1-b1-t/" ) t.expect_output_line("description: /t0-a0-b0/", False) t.expect_output_line("description: /t0-a0-b1/", False) t.expect_output_line("description: /t0-a1-b0/", False) t.expect_output_line("description: /t0-a1-b1/", False) t.expect_output_line("description: /t1-a0-b0/", False) t.expect_output_line("description: /t1-a0-b1/", False) t.expect_output_line("description: /t1-a1-b0/", False) t.expect_output_line("description: /t1-a1-b1/" ) t.expect_output_line("description: /a0-t1-b0/", False) t.expect_output_line("description: /a0-t1-b1/", False) t.expect_output_line("description: /a1-t0-b0/", False) t.expect_output_line("description: /a1-t0-b1/", False) t.expect_output_line("description: /b0-a1-t0/", False) t.expect_output_line("description: /b0-a0-t1/", False) t.expect_output_line("description: /b0-a1-t1/", False) t.expect_output_line("description: /b1-a0-t1/", False) t.expect_output_line("description: /b1-a1-t0/", False) t.expect_output_line("description: /b1-a1-t1/" ) t.cleanup() ################################################################################ # # main() # ------ # ################################################################################ test_multiple_conditions() test_multiple_conditions_with_toolset_version()