Add emacs and vim editing settings to the bottom of *.py files.
[scons.git] / test / SCCS / diskcheck.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 transparent checkouts from SCCS files in an SCCS subdirectory.
29 """
30
31 import os.path
32 import string
33
34 import TestSCons
35
36 test = TestSCons.TestSCons()
37
38 sccs = test.where_is('sccs')
39 if not sccs:
40     test.skip_test("Could not find 'sccs'; skipping test(s).\n")
41
42
43
44 test.subdir('SCCS', 'sub', ['sub', 'SCCS'])
45
46 for f in ['aaa.in', 'bbb.in', 'ccc.in']:
47     test.write(f, "%%F%% %s\n" % f)
48     args = "create %s" % f
49     test.run(program = sccs, arguments = args, stderr = None)
50     test.unlink(f)
51     test.unlink(','+f)
52
53 test.write(['sub', 'SConscript'], """\
54 # %%F%%
55 Import("env")
56 env.Cat('ddd.out', 'ddd.in')
57 env.Cat('eee.out', 'eee.in')
58 env.Cat('fff.out', 'fff.in')
59 env.Cat('all', ['ddd.out', 'eee.out', 'fff.out'])
60 """)
61 args = "create SConscript"
62 test.run(chdir = 'sub', program = sccs, arguments = args, stderr = None)
63 test.unlink(['sub', 'SConscript'])
64 test.unlink(['sub', ',SConscript'])
65
66 for f in ['ddd.in', 'eee.in', 'fff.in']:
67     test.write(['sub', f], "%%F%% sub/%s\n" % f)
68     args = "create %s" % f
69     test.run(chdir = 'sub', program = sccs, arguments = args, stderr = None)
70     test.unlink(['sub', f])
71     test.unlink(['sub', ','+f])
72
73 test.write(['SConstruct'], """
74 DefaultEnvironment()['SCCSCOM'] = 'cd ${TARGET.dir} && $SCCS get ${TARGET.file}'
75 def cat(env, source, target):
76     target = str(target[0])
77     source = map(str, source)
78     f = open(target, "wb")
79     for src in source:
80         f.write(open(src, "rb").read())
81     f.close()
82 SetOption('diskcheck', ['match', 'rcs'])
83 env = Environment(BUILDERS={'Cat':Builder(action=cat)},
84                   SCCSFLAGS='-k')
85 env.Cat('aaa.out', 'aaa.in')
86 env.Cat('bbb.out', 'bbb.in')
87 env.Cat('ccc.out', 'ccc.in')
88 env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
89 SConscript('sub/SConscript', "env")
90 """)
91
92 test.write(['bbb.in'], "checked-out bbb.in\n")
93
94 test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n")
95
96 sub_SConscript = os.path.join('sub', 'SConscript')
97 SConstruct_file_line = test.python_file_line(test.workpath('SConstruct'), 17)[:-1]
98
99 expect = """\
100
101 scons: warning: Ignoring missing SConscript '%(sub_SConscript)s'
102 %(SConstruct_file_line)s
103 scons: *** [aaa.out] Source `aaa.in' not found, needed by target `aaa.out'.
104 """ % locals()
105
106 test.run(status=2, stderr=expect)
107
108 test.run(arguments = '--diskcheck=sccs', stderr = None)
109
110 lines = string.split("""
111 sccs get SConscript
112 sccs get aaa.in
113 cat(["aaa.out"], ["aaa.in"])
114 cat(["bbb.out"], ["bbb.in"])
115 sccs get ccc.in
116 cat(["ccc.out"], ["ccc.in"])
117 cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
118 sccs get ddd.in
119 cat(["sub/ddd.out"], ["sub/ddd.in"])
120 cat(["sub/eee.out"], ["sub/eee.in"])
121 sccs get fff.in
122 cat(["sub/fff.out"], ["sub/fff.in"])
123 cat(["sub/all"], ["sub/ddd.out", "sub/eee.out", "sub/fff.out"])
124 """, '\n')
125
126 test.must_contain_all_lines(test.stdout(), lines)
127
128 test.must_match('all', """\
129 s.aaa.in aaa.in
130 checked-out bbb.in
131 s.ccc.in ccc.in
132 """)
133
134 test.must_not_be_writable(test.workpath('sub', 'SConscript'))
135 test.must_not_be_writable(test.workpath('aaa.in'))
136 test.must_not_be_writable(test.workpath('ccc.in'))
137 test.must_not_be_writable(test.workpath('sub', 'ddd.in'))
138 test.must_not_be_writable(test.workpath('sub', 'fff.in'))
139
140
141
142 test.pass_test()
143
144 # Local Variables:
145 # tab-width:4
146 # indent-tabs-mode:nil
147 # End:
148 # vim: set expandtab tabstop=4 shiftwidth=4: