1#!/usr/local/bin/python3.8 2 3# Copyright 2013 Steven Watanabe 4# Distributed under the Boost Software License, Version 1.0. 5# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 6 7# Tests that action sources are not reordered 8 9import BoostBuild 10 11t = BoostBuild.Tester() 12 13t.write("check-order.jam", """\ 14import type ; 15import generators ; 16 17type.register ORDER_TEST : order-test ; 18 19SPACE = " " ; 20nl = "\n" ; 21actions check-order 22{ 23 echo$(SPACE)$(>[1])>$(<[1]) 24 echo$(SPACE)$(>[2-])>>$(<[1])$(nl) 25} 26 27generators.register-composing check-order.check-order : C : ORDER_TEST ; 28""") 29 30t.write( 31 'check-order.py', 32""" 33import bjam 34 35from b2.build import type as type_, generators 36from b2.tools import common 37from b2.manager import get_manager 38 39MANAGER = get_manager() 40ENGINE = MANAGER.engine() 41 42type_.register('ORDER_TEST', ['order-test']) 43 44generators.register_composing('check-order.check-order', ['C'], ['ORDER_TEST']) 45 46def check_order(targets, sources, properties): 47 ENGINE.set_target_variable(targets, 'SPACE', ' ') 48 ENGINE.set_target_variable(targets, 'nl', '\\n') 49 50ENGINE.register_action( 51 'check-order.check-order', 52 function=check_order, 53 command=''' 54 echo$(SPACE)$(>[1])>$(<[1]) 55 echo$(SPACE)$(>[2-])>>$(<[1])$(nl) 56 ''' 57) 58""" 59) 60 61# The aliases are necessary for this test, since 62# the targets were sorted by virtual target 63# id, not by file name. 64t.write("jamroot.jam", """\ 65import check-order ; 66alias file1 : file1.c ; 67alias file2 : file2.c ; 68alias file3 : file3.c ; 69order-test check : file2 file1 file3 ; 70""") 71 72t.write("file1.c", "") 73t.write("file2.c", "") 74t.write("file3.c", "") 75 76t.run_build_system() 77t.expect_addition("bin/check.order-test") 78t.expect_content("bin/check.order-test", """\ 79file2.c 80file1.c 81file3.c 82""", True) 83 84t.cleanup() 85