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