Added fix for TeX includes with same name as subdirs.
[scons.git] / test / Move.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 """
28 Verify that the Move() Action works.
29 """
30
31 import TestSCons
32
33 test = TestSCons.TestSCons()
34
35 test.write('SConstruct', """
36 Execute(Move('f1.out', 'f1.in'))
37 Execute(Move('File-f1.out', File('f1.in-File')))
38 def cat(env, source, target):
39     target = str(target[0])
40     f = open(target, "wb")
41     for src in source:
42         f.write(open(str(src), "rb").read())
43     f.close()
44 Cat = Action(cat)
45 env = Environment()
46 env.Command('f2.out', 'f2.in', [Cat, Move("f3.out", "f3.in")])
47 env = Environment(OUT = 'f4.out', IN = 'f4.in')
48 env.Command('f5.out', 'f5.in', [Move("$OUT", "$IN"), Cat])
49 env.Command('f6.out', 'f6.in', [Cat, Move("Move-$TARGET", "$SOURCE-Move")])
50 """)
51
52 test.write('f1.in', "f1.in\n")
53 test.write('f1.in-File', "f1.in-File\n")
54 test.write('f2.in', "f2.in\n")
55 test.write('f3.in', "f3.in\n")
56 test.write('f4.in', "f4.in\n")
57 test.write('f5.in', "f5.in\n")
58 test.write('f6.in', "f6.in\n")
59 test.write('f6.in-Move', "f6.in-Move\n")
60
61 expect = test.wrap_stdout(read_str = """\
62 Move("f1.out", "f1.in")
63 Move("File-f1.out", "f1.in-File")
64 """,
65                           build_str = """\
66 cat(["f2.out"], ["f2.in"])
67 Move("f3.out", "f3.in")
68 Move("f4.out", "f4.in")
69 cat(["f5.out"], ["f5.in"])
70 cat(["f6.out"], ["f6.in"])
71 Move("Move-f6.out", "f6.in-Move")
72 """)
73 test.run(options = '-n', arguments = '.', stdout = expect)
74
75 test.must_not_exist('f1.out')
76 test.must_not_exist('File-f1.out')
77 test.must_not_exist('f2.out')
78 test.must_not_exist('f3.out')
79 test.must_not_exist('f4.out')
80 test.must_not_exist('f5.out')
81 test.must_not_exist('f6.out')
82 test.must_not_exist('Move-f6.out')
83
84 test.run()
85
86 test.must_match('f1.out', "f1.in\n")
87 test.must_match('File-f1.out', "f1.in-File\n")
88 test.must_match('f2.out', "f2.in\n")
89 test.must_not_exist('f3.in')
90 test.must_match('f3.out', "f3.in\n")
91 test.must_match('f4.out', "f4.in\n")
92 test.must_match('f5.out', "f5.in\n")
93 test.must_match('f6.out', "f6.in\n")
94 test.must_match('Move-f6.out', "f6.in-Move\n")
95
96 test.pass_test()
97
98 # Local Variables:
99 # tab-width:4
100 # indent-tabs-mode:nil
101 # End:
102 # vim: set expandtab tabstop=4 shiftwidth=4: