Added fix for TeX includes with same name as subdirs.
[scons.git] / test / option--C.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
29 import TestSCons
30
31 def match_normcase(lines, matches):
32     if not isinstance(lines, list):
33         lines = lines.split("\n")
34     if not isinstance(matches, list):
35         matches = matches.split("\n")
36     if len(lines) != len(matches):
37         return
38     for i in range(len(lines)):
39         if os.path.normcase(lines[i]) != os.path.normcase(matches[i]):
40             return
41     return 1
42
43 test = TestSCons.TestSCons(match=match_normcase)
44
45 wpath = test.workpath()
46 wpath_sub = test.workpath('sub')
47 wpath_sub_dir = test.workpath('sub', 'dir')
48 wpath_sub_foo_bar = test.workpath('sub', 'foo', 'bar')
49
50 test.subdir('sub', ['sub', 'dir'])
51
52 test.write('SConstruct', """
53 import os
54 print "SConstruct", os.getcwd()
55 """)
56
57 test.write(['sub', 'SConstruct'], """
58 import os
59 print GetBuildPath('..')
60 """)
61
62 test.write(['sub', 'dir', 'SConstruct'], """
63 import os
64 env = Environment(FOO='foo', BAR='bar')
65 print env.GetBuildPath('../$FOO/$BAR')
66 """)
67
68 test.run(arguments = '-C sub .',
69          stdout = "scons: Entering directory `%s'\n" % wpath_sub \
70              + test.wrap_stdout(read_str = '%s\n' % wpath,
71                                 build_str = "scons: `.' is up to date.\n"))
72
73 test.run(arguments = '-C sub -C dir .',
74          stdout = "scons: Entering directory `%s'\n" % wpath_sub_dir \
75              + test.wrap_stdout(read_str = '%s\n' % wpath_sub_foo_bar,
76                                 build_str = "scons: `.' is up to date.\n"))
77
78 test.run(arguments = ".",
79          stdout = test.wrap_stdout(read_str = 'SConstruct %s\n' % wpath,
80                                    build_str = "scons: `.' is up to date.\n"))
81
82 test.run(arguments = '--directory=sub/dir .',
83          stdout = "scons: Entering directory `%s'\n" % wpath_sub_dir \
84              + test.wrap_stdout(read_str = '%s\n' % wpath_sub_foo_bar,
85                                 build_str = "scons: `.' is up to date.\n"))
86
87 test.run(arguments = '-C %s -C %s .' % (wpath_sub_dir, wpath_sub),
88          stdout = "scons: Entering directory `%s'\n" % wpath_sub \
89              + test.wrap_stdout(read_str = '%s\n' % wpath,
90                                 build_str = "scons: `.' is up to date.\n"))
91
92 test.pass_test()
93
94 # Local Variables:
95 # tab-width:4
96 # indent-tabs-mode:nil
97 # End:
98 # vim: set expandtab tabstop=4 shiftwidth=4: