1#!/usr/bin/python 2 3# Copyright 2004 Vladimir Prus. 4# Distributed under the Boost Software License, Version 1.0. 5# (See accompanying file LICENSE_1_0.txt or copy at 6# http://www.boost.org/LICENSE_1_0.txt) 7 8# Test that we load parent projects before loading children. 9 10import BoostBuild 11 12t = BoostBuild.Tester(use_test_config=False) 13 14t.write("jamroot.jam", """\ 15use-project /child : child ; 16ECHO "Setting parent requirements" ; 17project : requirements <define>PASS_THE_TEST ; 18alias x : child//main ; 19""") 20 21t.write("child/jamfile.jam", """\ 22ECHO "Setting child requirements" ; 23project /child ; 24exe main : main.cpp ; 25""") 26 27t.write("child/main.cpp", """\ 28#if defined(PASS_THE_TEST) 29int main() {} 30#endif 31""") 32 33t.run_build_system() 34 35t.expect_addition("child/bin/$toolset/debug*/main.exe") 36t.fail_test(t.stdout().find("Setting child requirements") < t.stdout().find( 37 "Setting parent requirements")) 38 39 40# Regression test: parent requirements were ignored in some cases. 41t.rm(".") 42t.write("jamroot.jam", "build-project src ;") 43t.write("src/jamfile.jam", "project : requirements <define>EVERYTHING_OK ;") 44t.write("src/app/jamfile.jam", "exe test : test.cpp ;") 45t.write("src/app/test.cpp", """\ 46#ifdef EVERYTHING_OK 47int main() {} 48#endif 49""") 50 51t.run_build_system(subdir="src/app") 52t.expect_addition("src/app/bin/$toolset/debug*/test.exe") 53 54 55# child/child2 used to be loaded before child 56t.rm(".") 57t.write("jamroot.jam", """\ 58use-project /child/child2 : child/child2 ; 59rule parent-rule ( ) 60{ 61 ECHO "Running parent-rule" ; 62} 63""") 64t.write("child/jamfile.jam", "") 65t.write("child/child1/jamfile.jam", "") 66t.write("child/child2/jamfile.jam", "parent-rule ;") 67 68t.run_build_system(subdir="child/child1") 69t.expect_output_lines("Running parent-rule") 70 71t.cleanup() 72