Imported Upstream version 1.51.0
[platform/upstream/boost.git] / tools / build / v2 / 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 http://www.boost.org/LICENSE_1_0.txt) 
7
8 import BoostBuild
9 import os
10
11 t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
12
13 t.write("echo_args.jam", """
14 rule echo_args ( a b ? c ? : d + : e * )
15 {
16     ECHO a= $(a) b= $(b) c= $(c) ":" d= $(d) ":" e= $(e) ;
17 }
18
19 rule echo_varargs ( a b ? c ? : d + : e * : * )
20 {
21     ECHO a= $(a) b= $(b) c= $(c) ":" d= $(d) ":" e= $(e)
22       ": rest= "$(4[1]) $(4[2])
23       ": "$(5[1]) $(5[2])
24       ": "$(6[1]) $(6[2])
25       ": "$(7[1]) $(7[2])
26       ": "$(8[1]) $(8[2])
27       ": "$(9[1]) $(9[2]) ;
28 }
29 """)
30
31 t.write("file.jam", "include echo_args.jam ; echo_args ;")
32 t.run_build_system("-ffile.jam", status=1)
33 t.expect_output_line("* missing argument a");
34
35 t.write("file.jam", "include echo_args.jam ; echo_args 1 2 : 3 : 4 : 5 ;")
36 t.run_build_system("-ffile.jam", status=1)
37 t.expect_output_line("* extra argument 5");
38
39 t.write("file.jam", "include echo_args.jam ; echo_args a b c1 c2 : d ;")
40 t.run_build_system("-ffile.jam", status=1)
41 t.expect_output_line("* extra argument c2");
42
43 # Check modifier '?'
44
45 t.write("file.jam", "include echo_args.jam ; echo_args 1 2 3 : 4 ;")
46 t.run_build_system("-ffile.jam", status=1)
47 t.expect_output_line("a= 1 b= 2 c= 3 : d= 4 : e=");
48
49 t.write("file.jam", "include echo_args.jam ; echo_args 1 2 : 3 ;")
50 t.run_build_system("-ffile.jam", status=1)
51 t.expect_output_line("a= 1 b= 2 c= : d= 3 : e=");
52
53 t.write("file.jam", "include echo_args.jam ; echo_args 1 : 2 ;")
54 t.run_build_system("-ffile.jam", status=1)
55 t.expect_output_line("a= 1 b= c= : d= 2 : e=");
56
57 # Check modifier '+'
58
59 t.write("file.jam", "include echo_args.jam ; echo_args 1 ;")
60 t.run_build_system("-ffile.jam", status=1)
61 t.expect_output_line("* missing argument d");
62
63 t.write("file.jam", "include echo_args.jam ; echo_args 1 : 2 3 ;")
64 t.run_build_system("-ffile.jam", status=1)
65 t.expect_output_line("a= 1 b= c= : d= 2 3 : e=");
66
67 t.write("file.jam", "include echo_args.jam ; echo_args 1 : 2 3 4 ;")
68 t.run_build_system("-ffile.jam", status=1)
69 t.expect_output_line("a= 1 b= c= : d= 2 3 4 : e=");
70
71 # Check modifier '*'
72
73 t.write("file.jam", "include echo_args.jam ; echo_args 1 : 2 : 3 ;")
74 t.run_build_system("-ffile.jam", status=1)
75 t.expect_output_line("a= 1 b= c= : d= 2 : e= 3");
76
77 t.write("file.jam", "include echo_args.jam ; echo_args 1 : 2 : 3 4 ;")
78 t.run_build_system("-ffile.jam", status=1)
79 t.expect_output_line("a= 1 b= c= : d= 2 : e= 3 4");
80
81 t.write("file.jam", "include echo_args.jam ; echo_args 1 : 2 : 3 4 5 ;")
82 t.run_build_system("-ffile.jam", status=1)
83 t.expect_output_line("a= 1 b= c= : d= 2 : e= 3 4 5");
84
85 #
86 # Check varargs
87 #
88
89 t.write("file.jam", "include echo_args.jam ; echo_varargs 1 : 2 : 3 4 5 ;")
90 t.run_build_system("-ffile.jam", status=1)
91 t.expect_output_line("a= 1 b= c= : d= 2 : e= 3 4 5");
92
93 t.write("file.jam", "include echo_args.jam ; echo_varargs 1 : 2 : 3 4 5 : 6 ;")
94 t.run_build_system("-ffile.jam", status=1)
95 t.expect_output_line("a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6");
96
97 t.write("file.jam", "include echo_args.jam ; echo_varargs 1 : 2 : 3 4 5 : 6 7 ;")
98 t.run_build_system("-ffile.jam", status=1)
99 t.expect_output_line("a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6 7");
100
101 t.write("file.jam", "include echo_args.jam ; echo_varargs 1 : 2 : 3 4 5 : 6 7 : 8 ;")
102 t.run_build_system("-ffile.jam", status=1)
103 t.expect_output_line("a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6 7 : 8");
104
105 t.write("file.jam", "include echo_args.jam ; echo_varargs 1 : 2 : 3 4 5 : 6 7 : 8 : 9 ;")
106 t.run_build_system("-ffile.jam", status=1)
107 t.expect_output_line("a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6 7 : 8 : 9");
108
109 t.cleanup()