Added fix for TeX includes with same name as subdirs.
[scons.git] / test / CVSCOMSTR.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 Test customizing the output with the the $CVSCOMSTR variable.
29 """
30
31 import os.path
32
33 import TestSCons
34
35 _python_ = TestSCons._python_
36
37 test = TestSCons.TestSCons()
38
39 test.subdir('CVS', ['CVS', 'sub'], 'sub')
40
41 sub_CVS = os.path.join('sub', 'CVS')
42 sub_SConscript = os.path.join('sub', 'SConscript')
43 sub_all = os.path.join('sub', 'all')
44 sub_ddd_in = os.path.join('sub', 'ddd.in')
45 sub_ddd_out = os.path.join('sub', 'ddd.out')
46 sub_eee_in = os.path.join('sub', 'eee.in')
47 sub_eee_out = os.path.join('sub', 'eee.out')
48 sub_fff_in = os.path.join('sub', 'fff.in')
49 sub_fff_out = os.path.join('sub', 'fff.out')
50
51 test.write('my-cvs-co.py', """
52 import shutil
53 import sys
54 for f in sys.argv[1:]:
55     shutil.copy('CVS/'+f, f)
56 """)
57
58 test.write('SConstruct', """
59 def cat(env, source, target):
60     target = str(target[0])
61     f = open(target, "wb")
62     for src in source:
63         f.write(open(str(src), "rb").read())
64     f.close()
65 env = Environment(TOOLS = ['default', 'CVS'],
66                   BUILDERS={'Cat':Builder(action=cat)},
67                   CVSCOM='%(_python_)s my-cvs-co.py $TARGET',
68                   CVSCOMSTR='Checking out $TARGET from our fake CVS')
69 env.Cat('aaa.out', 'aaa.in')
70 env.Cat('bbb.out', 'bbb.in')
71 env.Cat('ccc.out', 'ccc.in')
72 env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
73 env.SourceCode('.', env.CVS(None))
74 SConscript('sub/SConscript', "env")
75 """ % locals())
76
77 test.write(['CVS', 'sub', 'SConscript'], """\
78 Import("env")
79 env.Cat('ddd.out', 'ddd.in')
80 env.Cat('eee.out', 'eee.in')
81 env.Cat('fff.out', 'fff.in')
82 env.Cat('all', ['ddd.out', 'eee.out', 'fff.out'])
83 """)
84
85 test.write(['CVS', 'aaa.in'], "CVS/aaa.in\n")
86 test.write('bbb.in', "checked-out bbb.in\n")
87 test.write(['CVS', 'ccc.in'], "CVS/ccc.in\n")
88
89 test.write(['CVS', 'sub', 'ddd.in'], "CVS/sub/ddd.in\n")
90 test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n")
91 test.write(['CVS', 'sub', 'fff.in'], "CVS/sub/fff.in\n")
92
93 test.run(arguments = '.',
94          stdout = test.wrap_stdout(read_str = """\
95 Checking out %(sub_SConscript)s from our fake CVS
96 """ % locals(),
97                                    build_str = """\
98 Checking out aaa.in from our fake CVS
99 cat(["aaa.out"], ["aaa.in"])
100 cat(["bbb.out"], ["bbb.in"])
101 Checking out ccc.in from our fake CVS
102 cat(["ccc.out"], ["ccc.in"])
103 cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
104 Checking out %(sub_ddd_in)s from our fake CVS
105 cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"])
106 cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"])
107 Checking out %(sub_fff_in)s from our fake CVS
108 cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"])
109 cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"])
110 """ % locals()))
111
112 test.must_match('all',
113                 "CVS/aaa.in\nchecked-out bbb.in\nCVS/ccc.in\n")
114
115 test.must_match(['sub', 'all'],
116                 "CVS/sub/ddd.in\nchecked-out sub/eee.in\nCVS/sub/fff.in\n")
117
118
119
120 #
121 test.pass_test()
122
123 # Local Variables:
124 # tab-width:4
125 # indent-tabs-mode:nil
126 # End:
127 # vim: set expandtab tabstop=4 shiftwidth=4: