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:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
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.
26 Test that the -C option changes directory as expected and that
27 multiple -C options are additive, except if a full path is given
30 __revision__
= "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
36 def match_normcase(lines
, matches
):
37 if not isinstance(lines
, list):
38 lines
= lines
.split("\n")
39 if not isinstance(matches
, list):
40 matches
= matches
.split("\n")
41 if len(lines
) != len(matches
):
43 for line
, match
in zip(lines
, matches
):
44 if os
.path
.normcase(line
) != os
.path
.normcase(match
):
48 test
= TestSCons
.TestSCons(match
=match_normcase
)
50 wpath
= test
.workpath()
51 wpath_sub
= test
.workpath('sub')
52 wpath_sub_dir
= test
.workpath('sub', 'dir')
53 wpath_sub_foo_bar
= test
.workpath('sub', 'foo', 'bar')
55 test
.subdir('sub', ['sub', 'dir'])
57 test
.write('SConstruct', """
58 DefaultEnvironment(tools=[])
60 print("SConstruct " + os.getcwd())
63 test
.write(['sub', 'SConstruct'], """
64 DefaultEnvironment(tools=[])
66 print(GetBuildPath('..'))
69 test
.write(['sub', 'dir', 'SConstruct'], """
70 DefaultEnvironment(tools=[])
72 env = Environment(FOO='foo', BAR='bar', tools=[])
73 print(env.GetBuildPath('../$FOO/$BAR'))
77 test
.run(arguments
='-C sub .',
78 stdout
="scons: Entering directory `%s'\n" % wpath_sub \
79 + test
.wrap_stdout(read_str
='%s\n' % wpath
,
80 build_str
="scons: `.' is up to date.\n"))
83 test
.run(arguments
='-C sub -C dir .',
84 stdout
="scons: Entering directory `%s'\n" % wpath_sub_dir \
85 + test
.wrap_stdout(read_str
='%s\n' % wpath_sub_foo_bar
,
86 build_str
="scons: `.' is up to date.\n"))
88 test
.run(arguments
=".",
89 stdout
=test
.wrap_stdout(read_str
='SConstruct %s\n' % wpath
,
90 build_str
="scons: `.' is up to date.\n"))
93 test
.run(arguments
='--directory=sub/dir .',
94 stdout
="scons: Entering directory `%s'\n" % wpath_sub_dir \
95 + test
.wrap_stdout(read_str
='%s\n' % wpath_sub_foo_bar
,
96 build_str
="scons: `.' is up to date.\n"))
98 # checks that using full paths is not additive
99 test
.run(arguments
='-C %s -C %s .' % (wpath_sub_dir
, wpath_sub
),
100 stdout
="scons: Entering directory `%s'\n" % wpath_sub \
101 + test
.wrap_stdout(read_str
='%s\n' % wpath
,
102 build_str
="scons: `.' is up to date.\n"))
109 # indent-tabs-mode:nil
111 # vim: set expandtab tabstop=4 shiftwidth=4: