Imported Upstream version 1.57.0
[platform/upstream/boost.git] / tools / build / test / project_root_constants.py
1 #!/usr/bin/python
2
3 # Copyright 2003, 2004, 2005 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 import BoostBuild
9
10 # Create a temporary working directory.
11 t = BoostBuild.Tester()
12
13 # Create the needed files.
14 t.write("jamroot.jam", """\
15 constant FOO : foobar gee ;
16 ECHO $(FOO) ;
17 """)
18
19 t.run_build_system()
20 t.expect_output_lines("foobar gee")
21
22 # Regression test: when absolute paths were passed to path-constant rule,
23 # Boost.Build failed to recognize path as absolute and prepended the current
24 # dir.
25 t.write("jamroot.jam", """\
26 import path ;
27 local here = [ path.native [ path.pwd ] ] ;
28 path-constant HERE : $(here) ;
29 if $(HERE) != $(here)
30 {
31     ECHO "PWD           =" $(here) ;
32     ECHO "path constant =" $(HERE) ;
33     EXIT ;
34 }
35 """)
36 t.write("jamfile.jam", "")
37
38 t.run_build_system()
39
40 t.write("jamfile.jam", """\
41 # This tests that rule 'hello' will be imported to children unlocalized, and
42 # will still access variables in this Jamfile.
43 x = 10 ;
44 constant FOO : foo ;
45 rule hello ( ) { ECHO "Hello $(x)" ; }
46 """)
47
48 t.write("d/jamfile.jam", """\
49 ECHO "d: $(FOO)" ;
50 constant BAR : bar ;
51 """)
52
53 t.write("d/d2/jamfile.jam", """\
54 ECHO "d2: $(FOO)" ;
55 ECHO "d2: $(BAR)" ;
56 hello ;
57 """)
58
59 t.run_build_system(subdir="d/d2")
60 t.expect_output_lines("d: foo\nd2: foo\nd2: bar\nHello 10")
61
62 t.cleanup()