fix typo
[scons.git] / test / Climb / option--U.py
blob137bb268ccbaa9148eb8297f74da2f38dada8d74
1 #!/usr/bin/env python
3 # __COPYRIGHT__
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.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
27 import sys
29 import TestSCons
31 test = TestSCons.TestSCons()
33 _python_ = TestSCons._python_
35 test.subdir('sub1', 'sub2', 'sub3')
37 test.write('build.py', r"""
38 import sys
39 with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp:
40 ofp.write(ifp.read())
41 """)
43 test.write('SConstruct', r"""
44 DefaultEnvironment(tools=[])
45 import SCons.Defaults
46 env = Environment(tools=[])
47 env['BUILDERS']['B'] = Builder(action=r'%(_python_)s build.py $TARGET $SOURCES', multi=1)
48 Default(env.B(target = 'sub1/foo.out', source = 'sub1/foo.in'))
49 Export('env')
50 SConscript('sub2/SConscript')
51 Default(env.B(target = 'sub3/baz.out', source = 'sub3/baz.in'))
52 VariantDir('sub2b', 'sub2')
53 SConscript('sub2b/SConscript')
54 Default(env.B(target = 'sub2/xxx.out', source = 'xxx.in'))
55 SConscript('SConscript')
56 """ % locals())
58 test.write(['sub2', 'SConscript'], """
59 Import('env')
60 bar = env.B(target = 'bar.out', source = 'bar.in')
61 Default(bar)
62 env.Alias('bar', bar)
63 Default(env.B(target = '../bar.out', source = 'bar.in'))
64 """)
67 test.write(['sub1', 'foo.in'], "sub1/foo.in\n")
68 test.write(['sub2', 'bar.in'], "sub2/bar.in\n")
69 test.write(['sub3', 'baz.in'], "sub3/baz.in\n")
70 test.write('xxx.in', "xxx.in\n")
72 test.write('SConscript', """assert GetLaunchDir() == r'%s'\n"""%test.workpath('sub1'))
73 test.run(arguments = '-U foo.out', chdir = 'sub1')
75 test.must_exist(test.workpath('sub1', 'foo.out'))
76 test.must_not_exist(test.workpath('sub2', 'bar.out'))
77 test.must_not_exist(test.workpath('sub2b', 'bar.out'))
78 test.must_not_exist(test.workpath('sub3', 'baz.out'))
79 test.must_not_exist(test.workpath('bar.out'))
80 test.must_not_exist(test.workpath('sub2/xxx.out'))
82 test.unlink(['sub1', 'foo.out'])
84 test.write('SConscript', """\
85 env = Environment(tools=[], )
86 assert env.GetLaunchDir() == r'%s'
87 """%test.workpath('sub1'))
88 test.run(arguments = '-U',
89 chdir = 'sub1',
90 stderr = "scons: *** No targets specified and no Default() targets found. Stop.\n",
91 status = 2)
92 test.must_not_exist(test.workpath('sub1', 'foo.out'))
93 test.must_not_exist(test.workpath('sub2', 'bar.out'))
94 test.must_not_exist(test.workpath('sub2b', 'bar.out'))
95 test.must_not_exist(test.workpath('sub3', 'baz.out'))
96 test.must_not_exist(test.workpath('bar.out'))
97 test.must_not_exist(test.workpath('sub2/xxx.out'))
100 if sys.platform == 'win32':
101 sub2 = 'SUB2'
102 else:
103 sub2 = 'sub2'
104 test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath(sub2))
105 test.run(chdir = sub2, arguments = '-U')
106 test.must_not_exist(test.workpath('sub1', 'foo.out'))
107 test.must_exist(test.workpath('sub2', 'bar.out'))
108 test.must_exist(test.workpath('sub2b', 'bar.out'))
109 test.must_not_exist(test.workpath('sub3', 'baz.out'))
110 test.must_exist(test.workpath('bar.out'))
111 test.must_not_exist(test.workpath('sub2/xxx.out'))
113 test.unlink(['sub2', 'bar.out'])
114 test.unlink(['sub2b', 'bar.out'])
115 test.unlink('bar.out')
117 test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath())
118 test.run(arguments='-U')
119 test.must_exist(test.workpath('sub1', 'foo.out'))
120 test.must_not_exist(test.workpath('sub2', 'bar.out'))
121 test.must_not_exist(test.workpath('sub2b', 'bar.out'))
122 test.must_exist(test.workpath('sub3', 'baz.out'))
123 test.must_not_exist(test.workpath('bar.out'))
124 test.must_exist(test.workpath('sub2/xxx.out'))
126 test.unlink(['sub1', 'foo.out'])
127 test.unlink(['sub3', 'baz.out'])
128 test.unlink(['sub2', 'xxx.out'])
130 test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath('sub3'))
131 test.run(chdir = 'sub3', arguments='-U bar')
132 test.must_not_exist(test.workpath('sub1', 'foo.out'))
133 test.must_exist(test.workpath('sub2', 'bar.out'))
134 test.must_exist(test.workpath('sub2b', 'bar.out'))
135 test.must_not_exist(test.workpath('sub3', 'baz.out'))
136 test.must_not_exist(test.workpath('bar.out'))
137 test.must_not_exist(test.workpath('sub2/xxx.out'))
139 test.pass_test()
141 # Local Variables:
142 # tab-width:4
143 # indent-tabs-mode:nil
144 # End:
145 # vim: set expandtab tabstop=4 shiftwidth=4: