Added fix for TeX includes with same name as subdirs.
[scons.git] / test / CVSCOM.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 setting the $CVSCOM 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 env.Cat('aaa.out', 'aaa.in')
69 env.Cat('bbb.out', 'bbb.in')
70 env.Cat('ccc.out', 'ccc.in')
71 env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
72 env.SourceCode('.', env.CVS(None))
73 SConscript('sub/SConscript', "env")
74 """ % locals())
75
76 test.write(['CVS', 'sub', 'SConscript'], """\
77 Import("env")
78 env.Cat('ddd.out', 'ddd.in')
79 env.Cat('eee.out', 'eee.in')
80 env.Cat('fff.out', 'fff.in')
81 env.Cat('all', ['ddd.out', 'eee.out', 'fff.out'])
82 """)
83
84 test.write(['CVS', 'aaa.in'], "CVS/aaa.in\n")
85 test.write('bbb.in', "checked-out bbb.in\n")
86 test.write(['CVS', 'ccc.in'], "CVS/ccc.in\n")
87
88 test.write(['CVS', 'sub', 'ddd.in'], "CVS/sub/ddd.in\n")
89 test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n")
90 test.write(['CVS', 'sub', 'fff.in'], "CVS/sub/fff.in\n")
91
92 test.run(arguments = '.',
93          stdout = test.wrap_stdout(read_str = """\
94 %(_python_)s my-cvs-co-.py %(sub_SConscript)s
95 """ % locals(),
96                                    build_str = """\
97 %(_python_)s my-cvs-co-.py aaa.in
98 cat(["aaa.out"], ["aaa.in"])
99 cat(["bbb.out"], ["bbb.in"])
100 %(_python_)s my-cvs-co-.py ccc.in
101 cat(["ccc.out"], ["ccc.in"])
102 cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
103 %(_python_)s my-cvs-co-.py %(sub_ddd_in)s
104 cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"])
105 cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"])
106 %(_python_)s my-cvs-co-.py %(sub_fff_in)s
107 cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"])
108 cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"])
109 """ % locals()))
110
111 test.must_match('all',
112                 "CVS/aaa.in\nchecked-out bbb.in\nCVS/ccc.in\n")
113
114 test.must_match(['sub', 'all'],
115                 "CVS/sub/ddd.in\nchecked-out sub/eee.in\nCVS/sub/fff.in\n")
116
117
118
119 #
120 test.pass_test()
121
122 # Local Variables:
123 # tab-width:4
124 # indent-tabs-mode:nil
125 # End:
126 # vim: set expandtab tabstop=4 shiftwidth=4: