Use AppendUnique() in ParseConfig(). Provide a unique=0 keyword argument in case...
[scons.git] / test / ParseConfig.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 import os
28 import sys
29
30 import TestCmd
31 import TestSCons
32
33 python = TestSCons.python
34
35 test = TestSCons.TestSCons()
36
37 test_config1 = test.workpath('test-config1')
38 test_config2 = test.workpath('test-config2')
39
40 # 'abc' is supposed to be a static lib; it is included in LIBS as a
41 # File node.
42 # It used to be returned as the 'static_libs' output of ParseConfig.
43 test.write(test_config1, """\
44 print "-I/usr/include/fum -Ibar -X"
45 print "-L/usr/fax -Lfoo -lxxx abc"
46 """)
47
48 test.write(test_config2, """\
49 print "-L foo -L lib_dir"
50 """)
51
52 test.write('SConstruct', """
53 env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], CCFLAGS = '')
54 env.ParseConfig([r"%(python)s", r"%(test_config1)s", "--libs --cflags"])
55 env.ParseConfig([r"%(python)s", r"%(test_config2)s", "--libs --cflags"])
56 print env['CPPPATH']
57 print env['LIBPATH']
58 print map(lambda x: str(x), env['LIBS'])
59 print env['CCFLAGS']
60 """ % locals())
61
62 test.write('SConstruct2', """
63 env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], CCFLAGS = '',
64                   PYTHON = '%(python)s')
65 env.ParseConfig(r"$PYTHON %(test_config1)s --libs --cflags")
66 env.ParseConfig(r"$PYTHON %(test_config2)s --libs --cflags")
67 print env['CPPPATH']
68 print env['LIBPATH']
69 print map(lambda x: str(x), env['LIBS'])
70 print env['CCFLAGS']
71 """ % locals())
72
73 good_stdout = test.wrap_stdout(read_str = """\
74 ['/usr/include/fum', 'bar']
75 ['/usr/fax', 'foo', 'lib_dir']
76 ['xxx', 'abc']
77 ['-X']
78 """, build_str = "scons: `.' is up to date.\n")
79
80 test.run(arguments = ".", stdout = good_stdout)
81
82 test.run(arguments = "-f SConstruct2 .", stdout = good_stdout)
83
84 test.pass_test()