Merged revisions 1582-1665 via svnmerge from
[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     source = map(str, source)
62     f = open(target, "wb")
63     for src in source:
64         f.write(open(src, "rb").read())
65     f.close()
66 env = Environment(TOOLS = ['default', 'CVS'],
67                   BUILDERS={'Cat':Builder(action=cat)},
68                   CVSCOM='%(_python_)s my-cvs-co.py $TARGET',
69                   CVSCOMSTR='Checking out $TARGET from our fake CVS')
70 env.Cat('aaa.out', 'aaa.in')
71 env.Cat('bbb.out', 'bbb.in')
72 env.Cat('ccc.out', 'ccc.in')
73 env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
74 env.SourceCode('.', env.CVS(None))
75 SConscript('sub/SConscript', "env")
76 """ % locals())
77
78 test.write(['CVS', 'sub', 'SConscript'], """\
79 Import("env")
80 env.Cat('ddd.out', 'ddd.in')
81 env.Cat('eee.out', 'eee.in')
82 env.Cat('fff.out', 'fff.in')
83 env.Cat('all', ['ddd.out', 'eee.out', 'fff.out'])
84 """)
85
86 test.write(['CVS', 'aaa.in'], "CVS/aaa.in\n")
87 test.write('bbb.in', "checked-out bbb.in\n")
88 test.write(['CVS', 'ccc.in'], "CVS/ccc.in\n")
89
90 test.write(['CVS', 'sub', 'ddd.in'], "CVS/sub/ddd.in\n")
91 test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n")
92 test.write(['CVS', 'sub', 'fff.in'], "CVS/sub/fff.in\n")
93
94 test.run(arguments = '.',
95          stdout = test.wrap_stdout(read_str = """\
96 Checking out %(sub_SConscript)s from our fake CVS
97 """ % locals(),
98                                    build_str = """\
99 Checking out aaa.in from our fake CVS
100 cat(["aaa.out"], ["aaa.in"])
101 cat(["bbb.out"], ["bbb.in"])
102 Checking out ccc.in from our fake CVS
103 cat(["ccc.out"], ["ccc.in"])
104 cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
105 Checking out %(sub_ddd_in)s from our fake CVS
106 cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"])
107 cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"])
108 Checking out %(sub_fff_in)s from our fake CVS
109 cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"])
110 cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"])
111 """ % locals()))
112
113 test.must_match('all',
114                 "CVS/aaa.in\nchecked-out bbb.in\nCVS/ccc.in\n")
115
116 test.must_match(['sub', 'all'],
117                 "CVS/sub/ddd.in\nchecked-out sub/eee.in\nCVS/sub/fff.in\n")
118
119
120
121 #
122 test.pass_test()