]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/test/core_arguments.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / tools / build / test / core_arguments.py
CommitLineData
7c673cae
FG
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.
1e59de90
TL
6# (See accompanying file LICENSE.txt or copy at
7# https://www.bfgroup.xyz/b2/LICENSE.txt)
7c673cae
FG
8
9import BoostBuild
10
11
12def simple_args(start, finish):
92f5a8d4 13 return " : ".join("%d" % x for x in range(start, finish + 1))
7c673cae
FG
14
15
16def 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)
92f5a8d4 22 t.expect_output_lines(output)
7c673cae
FG
23
24
25def test_args(t, *args, **kwargs):
26 test(t, "args", *args, **kwargs)
27
28
29def test_varargs(t, *args, **kwargs):
30 test(t, "varargs", *args, **kwargs)
31
32
11fdf7f2 33t = BoostBuild.Tester(pass_toolset=0)
7c673cae
FG
34
35t.write("echo_args.jam", """\
36NOCARE all ;
37
38rule echo_args ( a b ? c ? : d + : e * )
39{
40 ECHO a= $(a) b= $(b) c= $(c) ":" d= $(d) ":" e= $(e) ;
41}
42
43rule 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
57test_args(t, "", "* missing argument a", status=1)
58test_args(t, "1 2 : 3 : 4 : 5", "* extra argument 5", status=1)
59test_args(t, "a b c1 c2 : d", "* extra argument c2", status=1)
60
61# Check modifier '?'
62test_args(t, "1 2 3 : 4", "a= 1 b= 2 c= 3 : d= 4 : e=")
63test_args(t, "1 2 : 3", "a= 1 b= 2 c= : d= 3 : e=")
64test_args(t, "1 2 : 3", "a= 1 b= 2 c= : d= 3 : e=")
65test_args(t, "1 : 2", "a= 1 b= c= : d= 2 : e=")
66
67# Check modifier '+'
68test_args(t, "1", "* missing argument d", status=1)
69test_args(t, "1 : 2 3", "a= 1 b= c= : d= 2 3 : e=")
70test_args(t, "1 : 2 3 4", "a= 1 b= c= : d= 2 3 4 : e=")
71
72# Check modifier '*'
73test_args(t, "1 : 2 : 3", "a= 1 b= c= : d= 2 : e= 3")
74test_args(t, "1 : 2 : 3 4", "a= 1 b= c= : d= 2 : e= 3 4")
75test_args(t, "1 : 2 : 3 4 5", "a= 1 b= c= : d= 2 : e= 3 4 5")
76
77# Check varargs
78test_varargs(t, "1 : 2 : 3 4 5", "a= 1 b= c= : d= 2 : e= 3 4 5")
79test_varargs(t, "1 : 2 : 3 4 5 : 6", "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6")
80test_varargs(t, "1 : 2 : 3 4 5 : 6 7",
81 "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6 7")
82test_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")
84test_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")
86test_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")
89test_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
95expected = "a= 1 b= c= : d= 2 : e= 3 : rest= " + simple_args(4, 19)
96test_varargs(t, simple_args(1, 19), expected)
97test_varargs(t, simple_args(1, 19) + " 19b 19c 19d", expected + " 19b 19c 19d")
1e59de90 98'''FIXME: 19 (=LOL_MAX) args is the limit
7c673cae
FG
99test_varargs(t, simple_args(1, 19) + " 19b 19c 19d : 20", expected + " 19b "
100 "19c 19d")
101test_varargs(t, simple_args(1, 20), expected)
102test_varargs(t, simple_args(1, 50), expected)
1e59de90 103'''
7c673cae
FG
104
105t.cleanup()