]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/core_arguments.py
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / build / test / core_arguments.py
1 #!/usr/bin/python
2
3 # Copyright 2001 Dave Abrahams
4 # Copyright 2011 Steven Watanabe
5 # Distributed under the Boost Software License, Version 1.0.
6 # (See accompanying file LICENSE_1_0.txt or copy at
7 # http://www.boost.org/LICENSE_1_0.txt)
8
9 import BoostBuild
10
11
12 def simple_args(start, finish):
13 return " : ".join("%d" % x for x in xrange(start, finish + 1))
14
15
16 def test(t, type, input, output, status=0):
17 code = ["include echo_args.jam ; echo_%s" % type]
18 if input: code.append(input)
19 code.append(";")
20 t.write("file.jam", " ".join(code))
21 t.run_build_system(["-ffile.jam"], status=status)
22 t.expect_output_lines(output);
23
24
25 def test_args(t, *args, **kwargs):
26 test(t, "args", *args, **kwargs)
27
28
29 def test_varargs(t, *args, **kwargs):
30 test(t, "varargs", *args, **kwargs)
31
32
33 t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
34
35 t.write("echo_args.jam", """\
36 NOCARE all ;
37
38 rule echo_args ( a b ? c ? : d + : e * )
39 {
40 ECHO a= $(a) b= $(b) c= $(c) ":" d= $(d) ":" e= $(e) ;
41 }
42
43 rule echo_varargs ( a b ? c ? : d + : e * : * )
44 {
45 ECHO a= $(a) b= $(b) c= $(c) ":" d= $(d) ":" e= $(e)
46 ": rest= "$(4[1]) $(4[2-])
47 ": "$(5[1]) $(5[2-]) ": "$(6[1]) $(6[2-]) ": "$(7[1]) $(7[2-])
48 ": "$(8[1]) $(8[2-]) ": "$(9[1]) $(9[2-]) ": "$(10[1]) $(10[2-])
49 ": "$(11[1]) $(11[2-]) ": "$(12[1]) $(12[2-]) ": "$(13[1]) $(13[2-])
50 ": "$(14[1]) $(14[2-]) ": "$(15[1]) $(15[2-]) ": "$(16[1]) $(16[2-])
51 ": "$(17[1]) $(17[2-]) ": "$(18[1]) $(18[2-]) ": "$(19[1]) $(19[2-])
52 ": "$(20[1]) $(20[2-]) ": "$(21[1]) $(21[2-]) ": "$(22[1]) $(22[2-])
53 ": "$(23[1]) $(23[2-]) ": "$(24[1]) $(24[2-]) ": "$(25[1]) $(25[2-]) ;
54 }
55 """)
56
57 test_args(t, "", "* missing argument a", status=1)
58 test_args(t, "1 2 : 3 : 4 : 5", "* extra argument 5", status=1)
59 test_args(t, "a b c1 c2 : d", "* extra argument c2", status=1)
60
61 # Check modifier '?'
62 test_args(t, "1 2 3 : 4", "a= 1 b= 2 c= 3 : d= 4 : e=")
63 test_args(t, "1 2 : 3", "a= 1 b= 2 c= : d= 3 : e=")
64 test_args(t, "1 2 : 3", "a= 1 b= 2 c= : d= 3 : e=")
65 test_args(t, "1 : 2", "a= 1 b= c= : d= 2 : e=")
66
67 # Check modifier '+'
68 test_args(t, "1", "* missing argument d", status=1)
69 test_args(t, "1 : 2 3", "a= 1 b= c= : d= 2 3 : e=")
70 test_args(t, "1 : 2 3 4", "a= 1 b= c= : d= 2 3 4 : e=")
71
72 # Check modifier '*'
73 test_args(t, "1 : 2 : 3", "a= 1 b= c= : d= 2 : e= 3")
74 test_args(t, "1 : 2 : 3 4", "a= 1 b= c= : d= 2 : e= 3 4")
75 test_args(t, "1 : 2 : 3 4 5", "a= 1 b= c= : d= 2 : e= 3 4 5")
76
77 # Check varargs
78 test_varargs(t, "1 : 2 : 3 4 5", "a= 1 b= c= : d= 2 : e= 3 4 5")
79 test_varargs(t, "1 : 2 : 3 4 5 : 6", "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6")
80 test_varargs(t, "1 : 2 : 3 4 5 : 6 7",
81 "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6 7")
82 test_varargs(t, "1 : 2 : 3 4 5 : 6 7 : 8",
83 "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6 7 : 8")
84 test_varargs(t, "1 : 2 : 3 4 5 : 6 7 : 8 : 9",
85 "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6 7 : 8 : 9")
86 test_varargs(t, "1 : 2 : 3 4 5 : 6 7 : 8 : 9 : 10 : 11 : 12 : 13 : 14 : 15 : "
87 "16 : 17 : 18 : 19a 19b", "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6 7 : 8 : "
88 "9 : 10 : 11 : 12 : 13 : 14 : 15 : 16 : 17 : 18 : 19a 19b")
89 test_varargs(t, "1 : 2 : 3 4 5 : 6 7 : 8 : 9 : 10 : 11 : 12 : 13 : 14 : 15 : "
90 "16 : 17 : 18 : 19a 19b 19c : 20", "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= "
91 "6 7 : 8 : 9 : 10 : 11 : 12 : 13 : 14 : 15 : 16 : 17 : 18 : 19a 19b 19c : "
92 "20")
93
94 # Check varargs upper limit
95 expected = "a= 1 b= c= : d= 2 : e= 3 : rest= " + simple_args(4, 19)
96 test_varargs(t, simple_args(1, 19), expected)
97 test_varargs(t, simple_args(1, 19) + " 19b 19c 19d", expected + " 19b 19c 19d")
98 test_varargs(t, simple_args(1, 19) + " 19b 19c 19d : 20", expected + " 19b "
99 "19c 19d")
100 test_varargs(t, simple_args(1, 20), expected)
101 test_varargs(t, simple_args(1, 50), expected)
102
103 t.cleanup()